191:2e6cbacafdc7 | 192:94c67ae846fc |
---|---|
197 renderFull(); | 197 renderFull(); |
198 refresh(); | 198 refresh(); |
199 m_needRefresh = false; | 199 m_needRefresh = false; |
200 } | 200 } |
201 | 201 |
202 Interface::~Interface() | |
203 { | |
204 ::endwin(); | |
205 } | |
206 | |
202 // ------------------------------------------------------------------------------------------------- | 207 // ------------------------------------------------------------------------------------------------- |
203 // | 208 // |
204 void Interface::renderTitlebar() | 209 void Interface::renderTitlebar() |
205 { | 210 { |
206 if (static_cast<signed>(m_title.length()) <= COLS) | 211 if (static_cast<signed>(m_title.length()) <= COLS) |
626 } | 631 } |
627 } | 632 } |
628 | 633 |
629 // ------------------------------------------------------------------------------------------------- | 634 // ------------------------------------------------------------------------------------------------- |
630 // | 635 // |
631 void Interface::handleInput() | 636 void Interface::handleInput(bool* shouldquit) |
632 { | 637 { |
633 int ch = ::getch(); | 638 int ch = ::getch(); |
634 | 639 |
635 if (ch < 0) | 640 if (ch < 0) |
636 return; | 641 return; |
677 { | 682 { |
678 setInputState(INPUTSTATE_NORMAL); | 683 setInputState(INPUTSTATE_NORMAL); |
679 } | 684 } |
680 else | 685 else |
681 { | 686 { |
682 endwin(); | 687 *shouldquit = true; |
683 throw Exitception(); | |
684 } | 688 } |
685 }); | 689 }); |
686 break; | 690 break; |
687 | 691 |
688 case INPUTSTATE_PASSWORD: | 692 case INPUTSTATE_PASSWORD: |
831 break; | 835 break; |
832 | 836 |
833 case INPUTSTATE_NORMAL: | 837 case INPUTSTATE_NORMAL: |
834 if (getCurrentInput()[0] == '/') | 838 if (getCurrentInput()[0] == '/') |
835 { | 839 { |
836 handleCommand(getCurrentInput()); | 840 handleCommand(getCurrentInput(), shouldquit); |
837 flushInput(); | 841 flushInput(); |
838 } | 842 } |
839 else if (m_session.sendCommand(getCurrentInput())) | 843 else if (m_session.sendCommand(getCurrentInput())) |
840 { | 844 { |
841 flushInput(); | 845 flushInput(); |
1050 } | 1054 } |
1051 } | 1055 } |
1052 | 1056 |
1053 // ------------------------------------------------------------------------------------------------- | 1057 // ------------------------------------------------------------------------------------------------- |
1054 // | 1058 // |
1055 void Interface::handleCommand(const std::string& input) | 1059 void Interface::handleCommand(const std::string& input, bool* shouldquit) |
1056 { | 1060 { |
1057 if (input[0] != '/') | 1061 if (input[0] != '/') |
1058 return; | 1062 return; |
1059 | 1063 |
1060 std::vector<std::string> args = split(right(input, input.length() - 1), " "); | 1064 std::vector<std::string> args = split(right(input, input.length() - 1), " "); |
1077 m_session.disconnect(); | 1081 m_session.disconnect(); |
1078 } | 1082 } |
1079 else if (command == "quit") | 1083 else if (command == "quit") |
1080 { | 1084 { |
1081 m_session.disconnect(); | 1085 m_session.disconnect(); |
1082 endwin(); | 1086 *shouldquit = true; |
1083 throw Exitception(); | |
1084 } | 1087 } |
1085 else | 1088 else |
1086 printError("Unknown command: %s\n", command.data()); | 1089 printError("Unknown command: %s\n", command.data()); |
1087 } | 1090 } |
1088 | 1091 |