--- a/sources/interface.cpp Sun Jan 10 19:38:11 2016 +0200 +++ b/sources/interface.cpp Sun Jan 10 20:04:28 2016 +0200 @@ -166,7 +166,7 @@ OutputLines.clear(); OutputLines << ColoredLine(); Session.set_interface (this); - Title.sprintf (APPNAME " %s (%s)", full_version_string(), changeset_date_string()); + reset_title(); if (::has_colors()) { @@ -227,7 +227,7 @@ // ------------------------------------------------------------------------------------------------- // -void Interface::safe_disconnect (std::function<void()> afterwards) +void Interface::safe_disconnect (std::function<void(bool)> afterwards) { if (Session.is_active()) { @@ -235,7 +235,7 @@ set_input_state (INPUTSTATE_CONFIRM_DISCONNECTION); } else - afterwards(); + afterwards(false); } // ------------------------------------------------------------------------------------------------- @@ -637,7 +637,7 @@ if (ch == 'y' or ch == 'Y') { Session.disconnect(); - DisconnectConfirmFunction(); + DisconnectConfirmFunction(true); } else if (ch == 'n' or ch == 'N') set_input_state (INPUTSTATE_NORMAL); @@ -659,11 +659,10 @@ break; case INPUTSTATE_NORMAL: - safe_disconnect ([&]() + safe_disconnect ([&](bool hadsession) { - if (Session.is_active()) + if (hadsession) { - Session.disconnect(); set_input_state (INPUTSTATE_NORMAL); } else @@ -844,7 +843,7 @@ case 'N' - 'A' + 1: // ^N if (CurrentInputState == INPUTSTATE_NORMAL) - safe_disconnect ([&]() {set_input_state (INPUTSTATE_ADDRESS);}); + safe_disconnect ([&](bool){set_input_state (INPUTSTATE_ADDRESS);}); break; case '\x1b': // Escape @@ -980,6 +979,10 @@ OutputLines.last().add_char (*cp); } + // Remove some lines if there's too many of them. 20,000 should be enough, I hope. + while (OutputLines.size() > 20000) + OutputLines.remove_at(0); + OutputLines.last().add_char (ch); } @@ -1080,4 +1083,20 @@ print_error("Unknown command %s\n", command.chars()); } +// ------------------------------------------------------------------------------------------------- +// +void Interface::disconnected() +{ + print("Disconnected from %s\n", Session.address().to_string(IPAddress::WITH_PORT).chars()); + reset_title(); + render_full(); +} + +// ------------------------------------------------------------------------------------------------- +// +void Interface::reset_title() +{ + Title.sprintf (APPNAME " %s (%s)", full_version_string(), changeset_date_string()); +} + END_ZFC_NAMESPACE