164 InputHistory.clear(); |
164 InputHistory.clear(); |
165 InputHistory << ""; |
165 InputHistory << ""; |
166 OutputLines.clear(); |
166 OutputLines.clear(); |
167 OutputLines << ColoredLine(); |
167 OutputLines << ColoredLine(); |
168 Session.set_interface (this); |
168 Session.set_interface (this); |
169 Title.sprintf (APPNAME " %s (%s)", full_version_string(), changeset_date_string()); |
169 reset_title(); |
170 |
170 |
171 if (::has_colors()) |
171 if (::has_colors()) |
172 { |
172 { |
173 ::start_color(); |
173 ::start_color(); |
174 ::use_default_colors(); |
174 ::use_default_colors(); |
225 render_titlebar(); |
225 render_titlebar(); |
226 } |
226 } |
227 |
227 |
228 // ------------------------------------------------------------------------------------------------- |
228 // ------------------------------------------------------------------------------------------------- |
229 // |
229 // |
230 void Interface::safe_disconnect (std::function<void()> afterwards) |
230 void Interface::safe_disconnect (std::function<void(bool)> afterwards) |
231 { |
231 { |
232 if (Session.is_active()) |
232 if (Session.is_active()) |
233 { |
233 { |
234 DisconnectConfirmFunction = afterwards; |
234 DisconnectConfirmFunction = afterwards; |
235 set_input_state (INPUTSTATE_CONFIRM_DISCONNECTION); |
235 set_input_state (INPUTSTATE_CONFIRM_DISCONNECTION); |
236 } |
236 } |
237 else |
237 else |
238 afterwards(); |
238 afterwards(false); |
239 } |
239 } |
240 |
240 |
241 // ------------------------------------------------------------------------------------------------- |
241 // ------------------------------------------------------------------------------------------------- |
242 // |
242 // |
243 int Interface::nicklist_width() |
243 int Interface::nicklist_width() |
635 if (CurrentInputState == INPUTSTATE_CONFIRM_DISCONNECTION) |
635 if (CurrentInputState == INPUTSTATE_CONFIRM_DISCONNECTION) |
636 { |
636 { |
637 if (ch == 'y' or ch == 'Y') |
637 if (ch == 'y' or ch == 'Y') |
638 { |
638 { |
639 Session.disconnect(); |
639 Session.disconnect(); |
640 DisconnectConfirmFunction(); |
640 DisconnectConfirmFunction(true); |
641 } |
641 } |
642 else if (ch == 'n' or ch == 'N') |
642 else if (ch == 'n' or ch == 'N') |
643 set_input_state (INPUTSTATE_NORMAL); |
643 set_input_state (INPUTSTATE_NORMAL); |
644 |
644 |
645 return; |
645 return; |
842 } |
841 } |
843 break; |
842 break; |
844 |
843 |
845 case 'N' - 'A' + 1: // ^N |
844 case 'N' - 'A' + 1: // ^N |
846 if (CurrentInputState == INPUTSTATE_NORMAL) |
845 if (CurrentInputState == INPUTSTATE_NORMAL) |
847 safe_disconnect ([&]() {set_input_state (INPUTSTATE_ADDRESS);}); |
846 safe_disconnect ([&](bool){set_input_state (INPUTSTATE_ADDRESS);}); |
848 break; |
847 break; |
849 |
848 |
850 case '\x1b': // Escape |
849 case '\x1b': // Escape |
851 // We may have an alt key coming |
850 // We may have an alt key coming |
852 ch = ::getch(); |
851 ch = ::getch(); |
978 |
977 |
979 for (char* cp = timestamp; *cp != '\0'; ++cp) |
978 for (char* cp = timestamp; *cp != '\0'; ++cp) |
980 OutputLines.last().add_char (*cp); |
979 OutputLines.last().add_char (*cp); |
981 } |
980 } |
982 |
981 |
|
982 // Remove some lines if there's too many of them. 20,000 should be enough, I hope. |
|
983 while (OutputLines.size() > 20000) |
|
984 OutputLines.remove_at(0); |
|
985 |
983 OutputLines.last().add_char (ch); |
986 OutputLines.last().add_char (ch); |
984 } |
987 } |
985 |
988 |
986 NeedOutputRender = true; |
989 NeedOutputRender = true; |
987 } |
990 } |
1078 } |
1081 } |
1079 else |
1082 else |
1080 print_error("Unknown command %s\n", command.chars()); |
1083 print_error("Unknown command %s\n", command.chars()); |
1081 } |
1084 } |
1082 |
1085 |
|
1086 // ------------------------------------------------------------------------------------------------- |
|
1087 // |
|
1088 void Interface::disconnected() |
|
1089 { |
|
1090 print("Disconnected from %s\n", Session.address().to_string(IPAddress::WITH_PORT).chars()); |
|
1091 reset_title(); |
|
1092 render_full(); |
|
1093 } |
|
1094 |
|
1095 // ------------------------------------------------------------------------------------------------- |
|
1096 // |
|
1097 void Interface::reset_title() |
|
1098 { |
|
1099 Title.sprintf (APPNAME " %s (%s)", full_version_string(), changeset_date_string()); |
|
1100 } |
|
1101 |
1083 END_ZFC_NAMESPACE |
1102 END_ZFC_NAMESPACE |