sources/interface.cpp

changeset 145
d0aedc9be448
parent 143
b9993733952a
child 150
37db42ad451a
child 156
ce66d7e374bf
equal deleted inserted replaced
144:e8d58327cd7f 145:d0aedc9be448
511 adminText.chars()); 511 adminText.chars());
512 } 512 }
513 break; 513 break;
514 } 514 }
515 515
516 if (not text.is_empty()) 516 if (not text.isEmpty())
517 text += " | "; 517 text += " | ";
518 518
519 text += "Ctrl+N to connect, Ctrl+Q to "; 519 text += "Ctrl+N to connect, Ctrl+Q to ";
520 text +=(m_session.state() == RCON_DISCONNECTED) ? "quit" : "disconnect"; 520 text +=(m_session.state() == RCON_DISCONNECTED) ? "quit" : "disconnect";
521 521
715 715
716 case KEY_BACKSPACE: 716 case KEY_BACKSPACE:
717 case '\b': 717 case '\b':
718 if (m_cursorPosition > 0) 718 if (m_cursorPosition > 0)
719 { 719 {
720 getEditableInput().remove_at(--m_cursorPosition); 720 getEditableInput().removeAt(--m_cursorPosition);
721 m_needInputRender = true; 721 m_needInputRender = true;
722 } 722 }
723 break; 723 break;
724 724
725 case KEY_DC: 725 case KEY_DC:
726 case 'D' - 'A' + 1: // readline ^D 726 case 'D' - 'A' + 1: // readline ^D
727 if (m_cursorPosition < getCurrentInput().length()) 727 if (m_cursorPosition < getCurrentInput().length())
728 { 728 {
729 getEditableInput().remove_at(m_cursorPosition); 729 getEditableInput().removeAt(m_cursorPosition);
730 m_needInputRender = true; 730 m_needInputRender = true;
731 } 731 }
732 break; 732 break;
733 733
734 case KEY_PPAGE: 734 case KEY_PPAGE:
756 case 'W' - 'A' + 1: // readline ^W - delete from previous word bounary to current 756 case 'W' - 'A' + 1: // readline ^W - delete from previous word bounary to current
757 yank(findPreviousWord(), m_cursorPosition); 757 yank(findPreviousWord(), m_cursorPosition);
758 break; 758 break;
759 759
760 case 'Y' - 'A' + 1: // readline ^Y - paste previously deleted text 760 case 'Y' - 'A' + 1: // readline ^Y - paste previously deleted text
761 if (not m_pasteBuffer.is_empty()) 761 if (not m_pasteBuffer.isEmpty())
762 { 762 {
763 getEditableInput().insert(m_cursorPosition, m_pasteBuffer); 763 getEditableInput().insert(m_cursorPosition, m_pasteBuffer);
764 m_cursorPosition += m_pasteBuffer.length(); 764 m_cursorPosition += m_pasteBuffer.length();
765 m_needInputRender = true; 765 m_needInputRender = true;
766 } 766 }
804 804
805 setInputState(INPUTSTATE_PASSWORD); 805 setInputState(INPUTSTATE_PASSWORD);
806 break; 806 break;
807 807
808 case INPUTSTATE_PASSWORD: 808 case INPUTSTATE_PASSWORD:
809 if (m_inputState == INPUTSTATE_PASSWORD and not getCurrentInput().is_empty()) 809 if (m_inputState == INPUTSTATE_PASSWORD and not getCurrentInput().isEmpty())
810 { 810 {
811 m_session.disconnect(); 811 m_session.disconnect();
812 m_session.set_password(getCurrentInput()); 812 m_session.set_password(getCurrentInput());
813 m_session.connect(m_remoteAddress); 813 m_session.connect(m_remoteAddress);
814 setInputState(INPUTSTATE_NORMAL); 814 setInputState(INPUTSTATE_NORMAL);
1032 // 1032 //
1033 void Interface::tabComplete(const String& part, String complete) 1033 void Interface::tabComplete(const String& part, String complete)
1034 { 1034 {
1035 String& input = getEditableInput(); 1035 String& input = getEditableInput();
1036 1036
1037 if (input.starts_with(part)) 1037 if (input.startsWith(part))
1038 { 1038 {
1039 if (input[part.length()] != ' ') 1039 if (input[part.length()] != ' ')
1040 complete += ' '; 1040 complete += ' ';
1041 1041
1042 input.replace(0, part.length(), complete); 1042 input.replace(0, part.length(), complete);
1051 { 1051 {
1052 if (input[0] != '/') 1052 if (input[0] != '/')
1053 return; 1053 return;
1054 1054
1055 StringList args = input.right(input.length() - 1).split(" "); 1055 StringList args = input.right(input.length() - 1).split(" ");
1056 String command = args[0].to_lowercase(); 1056 String command = args[0].toLowerCase();
1057 args.remove_at(0); 1057 args.remove_at(0);
1058 1058
1059 if (command == "connect") 1059 if (command == "connect")
1060 { 1060 {
1061 if (args.size() != 2) 1061 if (args.size() != 2)

mercurial