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); |
974 time(&now); |
974 time(&now); |
975 char timestamp[32]; |
975 char timestamp[32]; |
976 strftime(timestamp, sizeof timestamp, "[%H:%M:%S] ", localtime(&now)); |
976 strftime(timestamp, sizeof timestamp, "[%H:%M:%S] ", localtime(&now)); |
977 |
977 |
978 for (char ch : String(timestamp)) |
978 for (char ch : String(timestamp)) |
979 m_outputLines.last().add_char(ch); |
979 m_outputLines.last().addChar(ch); |
980 } |
980 } |
981 |
981 |
982 // Remove some lines if there's too many of them. 20,000 should be enough, I hope. |
982 // Remove some lines if there's too many of them. 20,000 should be enough, I hope. |
983 while (m_outputLines.size() > 20000) |
983 while (m_outputLines.size() > 20000) |
984 m_outputLines.remove_at(0); |
984 m_outputLines.remove_at(0); |
985 |
985 |
986 m_outputLines.last().add_char(ch); |
986 m_outputLines.last().addChar(ch); |
987 } |
987 } |
988 |
988 |
989 m_needOutputRender = true; |
989 m_needOutputRender = true; |
990 } |
990 } |
991 |
991 |
1018 m_playerNames.clear(); |
1018 m_playerNames.clear(); |
1019 |
1019 |
1020 for (const String& name : names) |
1020 for (const String& name : names) |
1021 { |
1021 { |
1022 ColoredLine coloredname; |
1022 ColoredLine coloredname; |
1023 coloredname.add_string(name); |
1023 coloredname.addString(name); |
1024 coloredname.finalize(); |
1024 coloredname.finalize(); |
1025 m_playerNames.append(coloredname); |
1025 m_playerNames.append(coloredname); |
1026 } |
1026 } |
1027 |
1027 |
1028 m_needNicklistRender = true; |
1028 m_needNicklistRender = true; |
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); |