diff options
author | James Booth <boothj5@gmail.com> | 2014-09-01 19:14:52 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-09-01 19:14:52 +0100 |
commit | bc3c4e09a194acba2f5947b62b8913d7311fb1cb (patch) | |
tree | 7313a3acc3db68bc4d78bef7be65963cd86f096d /src | |
parent | c73c4b20efef6d412d48be241b84f4374dacc4f7 (diff) | |
download | profani-tty-bc3c4e09a194acba2f5947b62b8913d7311fb1cb.tar.gz |
Always update UI in event loop, removed updates from rest of code
Diffstat (limited to 'src')
-rw-r--r-- | src/command/commands.c | 4 | ||||
-rw-r--r-- | src/otr/otr.c | 2 | ||||
-rw-r--r-- | src/profanity.c | 6 | ||||
-rw-r--r-- | src/server_events.c | 28 | ||||
-rw-r--r-- | src/ui/console.c | 156 | ||||
-rw-r--r-- | src/ui/core.c | 179 | ||||
-rw-r--r-- | src/ui/ui.h | 4 |
7 files changed, 13 insertions, 366 deletions
diff --git a/src/command/commands.c b/src/command/commands.c index 6dd7c238..1760d18c 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -478,7 +478,6 @@ cmd_disconnect(gchar **args, struct cmd_help_t help) muc_clear_invites(); chat_sessions_clear(); ui_disconnected(); - ui_current_page_off(); free(jid); } else { cons_show("You are not currently connected."); @@ -1233,7 +1232,6 @@ cmd_group(gchar **args, struct cmd_help_t help) if (p_contact_in_group(pcontact, group)) { const char *display_name = p_contact_name_or_jid(pcontact); ui_contact_already_in_group(display_name, group); - ui_current_page_off(); } else { roster_send_add_to_group(group, pcontact); } @@ -1265,7 +1263,6 @@ cmd_group(gchar **args, struct cmd_help_t help) if (!p_contact_in_group(pcontact, group)) { const char *display_name = p_contact_name_or_jid(pcontact); ui_contact_not_in_group(display_name, group); - ui_current_page_off(); } else { roster_send_remove_from_group(group, pcontact); } @@ -2827,7 +2824,6 @@ cmd_otr(gchar **args, struct cmd_help_t help) } else if (strcmp(args[0], "warn") == 0) { gboolean result = _cmd_set_boolean_preference(args[1], help, "OTR warning message", PREF_OTR_WARN); - ui_current_update_virtual(); return result; } else if (strcmp(args[0], "libver") == 0) { diff --git a/src/otr/otr.c b/src/otr/otr.c index fe0a114d..7e955900 100644 --- a/src/otr/otr.c +++ b/src/otr/otr.c @@ -306,8 +306,6 @@ _otr_keygen(ProfAccount *account) log_debug("Generating private key file %s for %s", keysfilename->str, jid); cons_show("Generating private key, this may take some time."); cons_show("Moving the mouse randomly around the screen may speed up the process!"); - ui_current_page_off(); - ui_update_screen(); err = otrl_privkey_generate(user_state, keysfilename->str, account->jid, "xmpp"); if (!err == GPG_ERR_NO_ERROR) { g_string_free(basedir, TRUE); diff --git a/src/profanity.c b/src/profanity.c index 3236a816..c8e55201 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -82,8 +82,6 @@ prof_run(const int disable_tls, char *log_level, char *account_name) char inp[INP_WIN_MAX]; int size = 0; - ui_update_screen(); - char *pref_connect_account = prefs_get_string(PREF_CONNECT_ACCOUNT); if (account_name != NULL) { char *cmd = "/connect"; @@ -95,6 +93,7 @@ prof_run(const int disable_tls, char *log_level, char *account_name) process_input(inp); } prefs_free_string(pref_connect_account); + ui_update(); while(cmd_result == TRUE) { wint_t ch = ERR; @@ -115,11 +114,11 @@ prof_run(const int disable_tls, char *log_level, char *account_name) } ui_handle_special_keys(&ch, inp, size); - ui_update_screen(); #ifdef HAVE_LIBOTR otr_poll(); #endif jabber_process_events(); + ui_update(); ch = ui_get_char(inp, &size); } @@ -218,7 +217,6 @@ process_input(char *inp) ui_input_clear(); roster_reset_search_attempts(); - ui_current_page_off(); return result; } diff --git a/src/server_events.c b/src/server_events.c index e2029cee..d48cfb23 100644 --- a/src/server_events.c +++ b/src/server_events.c @@ -132,7 +132,6 @@ handle_lost_connection(void) muc_clear_invites(); chat_sessions_clear(); ui_disconnected(); - ui_current_page_off(); } void @@ -140,7 +139,6 @@ handle_failed_login(void) { cons_show_error("Login failed."); log_info("Login failed"); - ui_current_page_off(); } void @@ -148,28 +146,24 @@ handle_software_version_result(const char * const jid, const char * const prese const char * const name, const char * const version, const char * const os) { cons_show_software_version(jid, presence, name, version, os); - ui_current_page_off(); } void handle_disco_info(const char *from, GSList *identities, GSList *features) { cons_show_disco_info(from, identities, features); - ui_current_page_off(); } void handle_room_list(GSList *rooms, const char *conference_node) { cons_show_room_list(rooms, conference_node); - ui_current_page_off(); } void handle_disco_items(GSList *items, const char *jid) { cons_show_disco_items(items, jid); - ui_current_page_off(); } void @@ -180,7 +174,6 @@ handle_room_invite(jabber_invite_t invite_type, if (!muc_room_is_active(room) && !muc_invites_include(room)) { cons_show_room_invite(invitor, room, reason); muc_add_invite(room); - ui_current_page_off(); } } @@ -190,7 +183,6 @@ handle_room_broadcast(const char *const room_jid, { if (muc_get_roster_received(room_jid)) { ui_room_broadcast(room_jid, message); - ui_current_page_off(); } else { muc_add_pending_broadcast(room_jid, message); } @@ -202,7 +194,6 @@ handle_room_subject(const char * const room_jid, const char * const subject) muc_set_subject(room_jid, subject); if (muc_get_roster_received(room_jid)) { ui_room_subject(room_jid, subject); - ui_current_page_off(); } } @@ -211,7 +202,6 @@ handle_room_history(const char * const room_jid, const char * const nick, GTimeVal tv_stamp, const char * const message) { ui_room_history(room_jid, nick, tv_stamp, message); - ui_current_page_off(); } void @@ -231,7 +221,6 @@ void handle_duck_result(const char * const result) { ui_duck_result(result); - ui_current_page_off(); } void @@ -332,14 +321,12 @@ void handle_typing(char *from) { ui_contact_typing(from); - ui_current_page_off(); } void handle_gone(const char * const from) { ui_recipient_gone(from); - ui_current_page_off(); } void @@ -351,7 +338,6 @@ handle_subscription(const char *from, jabber_subscr_t type) cons_show("Received authorization request from %s", from); log_info("Received authorization request from %s", from); ui_print_system_msg_from_recipient(from, "Authorization request, type '/sub allow' to accept or '/sub deny' to reject"); - ui_current_page_off(); if (prefs_get_boolean(PREF_NOTIFY_SUB)) { notify_subscription(from); } @@ -360,13 +346,11 @@ handle_subscription(const char *from, jabber_subscr_t type) cons_show("Subscription received from %s", from); log_info("Subscription received from %s", from); ui_print_system_msg_from_recipient(from, "Subscribed"); - ui_current_page_off(); break; case PRESENCE_UNSUBSCRIBED: cons_show("%s deleted subscription", from); log_info("%s deleted subscription", from); ui_print_system_msg_from_recipient(from, "Unsubscribed"); - ui_current_page_off(); break; default: /* unknown type */ @@ -463,7 +447,6 @@ handle_room_nick_change(const char * const room, const char * const nick) { ui_room_nick_change(room, nick); - ui_current_page_off(); } void @@ -482,7 +465,6 @@ handle_room_roster_complete(const char * const room) char *subject = muc_get_subject(room); if (subject != NULL) { ui_room_subject(room, subject); - ui_current_page_off(); } GList *pending_broadcasts = muc_get_pending_broadcasts(room); @@ -492,7 +474,6 @@ handle_room_roster_complete(const char * const room) ui_room_broadcast(room, curr->data); curr = g_list_next(curr); } - ui_current_page_off(); } } @@ -507,7 +488,6 @@ handle_room_member_presence(const char * const room, char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC); if (g_strcmp0(muc_status_pref, "all") == 0) { ui_room_member_presence(room, nick, show, status); - ui_current_page_off(); } prefs_free_string(muc_status_pref); } @@ -523,7 +503,6 @@ handle_room_member_online(const char * const room, const char * const nick, char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC); if (g_strcmp0(muc_status_pref, "none") != 0) { ui_room_member_online(room, nick, show, status); - ui_current_page_off(); } prefs_free_string(muc_status_pref); } @@ -537,7 +516,6 @@ handle_room_member_offline(const char * const room, const char * const nick, char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC); if (g_strcmp0(muc_status_pref, "none") != 0) { ui_room_member_offline(room, nick); - ui_current_page_off(); } prefs_free_string(muc_status_pref); } @@ -547,7 +525,6 @@ handle_room_member_nick_change(const char * const room, const char * const old_nick, const char * const nick) { ui_room_member_nick_change(room, old_nick, nick); - ui_current_page_off(); } void @@ -555,7 +532,6 @@ handle_group_add(const char * const contact, const char * const group) { ui_group_added(contact, group); - ui_current_page_off(); } void @@ -563,21 +539,18 @@ handle_group_remove(const char * const contact, const char * const group) { ui_group_removed(contact, group); - ui_current_page_off(); } void handle_roster_remove(const char * const barejid) { ui_roster_remove(barejid); - ui_current_page_off(); } void handle_roster_add(const char * const barejid, const char * const name) { ui_roster_add(barejid, name); - ui_current_page_off(); } void @@ -585,7 +558,6 @@ handle_autoping_cancel(void) { prefs_set_autoping(0); cons_show_error("Server ping not supported, autoping disabled."); - ui_current_page_off(); } void diff --git a/src/ui/console.c b/src/ui/console.c index 3b8242cf..583900d9 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -67,10 +67,6 @@ _cons_show_time(void) { ProfWin *console = wins_get_console(); win_save_print(console, '-', NULL, NO_EOL, 0, "", ""); - - if (wins_is_current(console)) { - win_update_virtual(console); - } } static void @@ -78,10 +74,6 @@ _cons_show_word(const char * const word) { ProfWin *console = wins_get_console(); win_save_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", word); - - if (wins_is_current(console)) { - win_update_virtual(console); - } } static void @@ -96,14 +88,6 @@ _cons_debug(const char * const msg, ...) win_save_println(console, fmt_msg->str); g_string_free(fmt_msg, TRUE); va_end(arg); - - if (wins_is_current(console)) { - win_update_virtual(console); - } - cons_alert(); - - ui_current_page_off(); - ui_update_screen(); } } @@ -118,10 +102,6 @@ _cons_show(const char * const msg, ...) win_save_println(console, fmt_msg->str); g_string_free(fmt_msg, TRUE); va_end(arg); - - if (wins_is_current(console)) { - win_update_virtual(console); - } } static void @@ -136,10 +116,6 @@ _cons_show_error(const char * const msg, ...) g_string_free(fmt_msg, TRUE); va_end(arg); - if (wins_is_current(console)) { - win_update_virtual(console); - } - cons_alert(); } @@ -160,11 +136,6 @@ _cons_show_typing(const char * const barejid) } win_save_vprint(console, '-', NULL, 0, COLOUR_TYPING, "", "!! %s is typing a message...", display_usr); - - if (wins_is_current(console)) { - win_update_virtual(console); - } - cons_alert(); } @@ -179,10 +150,6 @@ _cons_show_incoming_message(const char * const short_from, const int win_index) } win_save_vprint(console, '-', NULL, 0, COLOUR_INCOMING, "", "<< incoming from %s (%d)", short_from, ui_index); - if (wins_is_current(console)) { - win_update_virtual(console); - } - cons_alert(); } @@ -223,10 +190,6 @@ _cons_about(void) pnoutrefresh(console->win, 0, 0, 1, 0, rows-3, cols-1); - if (wins_is_current(console)) { - win_update_virtual(console); - } - cons_alert(); } @@ -252,10 +215,6 @@ _cons_check_version(gboolean not_available_msg) } } - if (wins_is_current(console)) { - win_update_virtual(console); - } - cons_alert(); } } @@ -275,9 +234,6 @@ _cons_show_login_success(ProfAccount *account) win_save_vprint(console, '-', NULL, NO_DATE | NO_EOL, 0, "", " (priority %d)", accounts_get_priority_for_presence_type(account->name, presence)); win_save_print(console, '-', NULL, NO_DATE, 0, "", "."); - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } @@ -296,16 +252,12 @@ _cons_show_wins(void) } cons_show(""); - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } static void _cons_show_room_invites(GSList *invites) { - ProfWin *console = wins_get_console(); cons_show(""); if (invites == NULL) { cons_show("No outstanding chat room invites."); @@ -317,9 +269,6 @@ _cons_show_room_invites(GSList *invites) } } - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } @@ -329,9 +278,6 @@ _cons_show_info(PContact pcontact) ProfWin *console = wins_get_console(); win_show_info(console, pcontact); - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } @@ -346,7 +292,6 @@ _cons_show_caps(const char * const contact, Resource *resource) win_save_vprint(console, '-', NULL, NO_EOL, presence_colour, "", "%s", contact); win_save_print(console, '-', NULL, NO_DATE, 0, "", ":"); - if (resource->caps_str != NULL) { Capabilities *caps = caps_get(resource->caps_str); if (caps != NULL) { @@ -400,9 +345,6 @@ _cons_show_caps(const char * const contact, Resource *resource) } } - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } @@ -427,9 +369,6 @@ _cons_show_software_version(const char * const jid, const char * const presence cons_show("OS : %s", os); } - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } @@ -492,9 +431,6 @@ _cons_show_room_list(GSList *rooms, const char * const conference_node) cons_show("No chat rooms at %s", conference_node); } - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } @@ -538,10 +474,6 @@ _cons_show_bookmarks(const GList *list) win_save_newline(console); list = g_list_next(list); } - - if (wins_is_current(console)) { - win_update_virtual(console); - } } cons_alert(); } @@ -549,7 +481,6 @@ _cons_show_bookmarks(const GList *list) static void _cons_show_disco_info(const char *jid, GSList *identities, GSList *features) { - ProfWin *console = wins_get_console(); if (((identities != NULL) && (g_slist_length(identities) > 0)) || ((features != NULL) && (g_slist_length(features) > 0))) { cons_show(""); @@ -585,9 +516,6 @@ _cons_show_disco_info(const char *jid, GSList *identities, GSList *features) features = g_slist_next(features); } - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } } @@ -613,9 +541,6 @@ _cons_show_disco_items(GSList *items, const char * const jid) cons_show("No service discovery items for %s", jid); } - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } @@ -631,9 +556,6 @@ _cons_show_status(const char * const barejid) cons_show("No such contact \"%s\" in roster.", barejid); } - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } @@ -641,7 +563,6 @@ static void _cons_show_room_invite(const char * const invitor, const char * const room, const char * const reason) { - ProfWin *console = wins_get_console(); char *display_from = NULL; PContact contact = roster_get_contact(invitor); if (contact != NULL) { @@ -671,9 +592,6 @@ _cons_show_room_invite(const char * const invitor, const char * const room, free(display_from); - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } @@ -701,9 +619,6 @@ _cons_show_account_list(gchar **accounts) cons_show(""); } - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } @@ -867,9 +782,6 @@ _cons_show_account(ProfAccount *account) } } - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } @@ -991,7 +903,6 @@ _cons_titlebar_setting(void) static void _cons_show_ui_prefs(void) { - ProfWin *console = wins_get_console(); cons_show("UI preferences:"); cons_show(""); cons_theme_setting(); @@ -1003,9 +914,6 @@ _cons_show_ui_prefs(void) cons_statuses_setting(); cons_titlebar_setting(); - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } @@ -1080,14 +988,10 @@ _cons_notify_setting(void) static void _cons_show_desktop_prefs(void) { - ProfWin *console = wins_get_console(); cons_show("Desktop notification preferences:"); cons_show(""); cons_notify_setting(); - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } @@ -1143,7 +1047,6 @@ _cons_history_setting(void) static void _cons_show_chat_prefs(void) { - ProfWin *console = wins_get_console(); cons_show("Chat preferences:"); cons_show(""); cons_states_setting(); @@ -1152,9 +1055,6 @@ _cons_show_chat_prefs(void) cons_gone_setting(); cons_history_setting(); - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } @@ -1196,16 +1096,12 @@ _cons_grlog_setting(void) static void _cons_show_log_prefs(void) { - ProfWin *console = wins_get_console(); cons_show("Logging preferences:"); cons_show(""); cons_log_setting(); cons_chlog_setting(); cons_grlog_setting(); - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } @@ -1241,14 +1137,10 @@ _cons_autoaway_setting(void) static void _cons_show_presence_prefs(void) { - ProfWin *console = wins_get_console(); cons_show("Presence preferences:"); cons_show(""); cons_autoaway_setting(); - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } @@ -1288,23 +1180,18 @@ _cons_priority_setting(void) static void _cons_show_connection_prefs(void) { - ProfWin *console = wins_get_console(); cons_show("Connection preferences:"); cons_show(""); cons_reconnect_setting(); cons_autoping_setting(); cons_autoconnect_setting(); - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } static void _cons_show_otr_prefs(void) { - ProfWin *console = wins_get_console(); cons_show("OTR preferences:"); cons_show(""); @@ -1328,16 +1215,12 @@ _cons_show_otr_prefs(void) } prefs_free_string(log_value); - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } static void _cons_show_themes(GSList *themes) { - ProfWin *console = wins_get_console(); cons_show(""); if (themes == NULL) { @@ -1350,16 +1233,12 @@ _cons_show_themes(GSList *themes) } } - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } static void _cons_prefs(void) { - ProfWin *console = wins_get_console(); cons_show(""); cons_show_ui_prefs(); cons_show(""); @@ -1376,16 +1255,12 @@ _cons_prefs(void) cons_show_otr_prefs(); cons_show(""); - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } static void _cons_help(void) { - ProfWin *console = wins_get_console(); cons_show(""); cons_show("Choose a help option:"); cons_show(""); @@ -1402,16 +1277,12 @@ _cons_help(void) cons_show("/help [command] - Detailed help on a specific command."); cons_show(""); - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } static void _cons_navigation_help(void) { - ProfWin *console = wins_get_console(); cons_show(""); cons_show("Navigation:"); cons_show(""); @@ -1427,16 +1298,12 @@ _cons_navigation_help(void) cons_show("PAGE UP, PAGE DOWN : Page the main window."); cons_show(""); - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } static void _cons_show_roster_group(const char * const group, GSList *list) { - ProfWin *console = wins_get_console(); cons_show(""); if (list != NULL) { @@ -1446,23 +1313,18 @@ _cons_show_roster_group(const char * const group, GSList *list) } _show_roster_contacts(list, FALSE); - if (wins_is_current(console)) { - win_update_virtual(console); - } + cons_alert(); } static void _cons_show_roster(GSList *list) { - ProfWin *console = wins_get_console(); cons_show(""); cons_show("Roster: jid (nick) - subscription - groups"); _show_roster_contacts(list, TRUE); - if (wins_is_current(console)) { - win_update_virtual(console); - } + cons_alert(); } @@ -1477,11 +1339,6 @@ _cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_ "++", "online"); free(display_str); - - if (wins_is_current(console)) { - ui_current_page_off(); - win_update_virtual(console); - } } static void @@ -1493,11 +1350,6 @@ _cons_show_contact_offline(PContact contact, char *resource, char *status) win_show_status_string(console, display_str, "offline", status, NULL, "--", "offline"); free(display_str); - - if (wins_is_current(console)) { - ui_current_page_off(); - win_update_virtual(console); - } } static void @@ -1514,10 +1366,6 @@ _cons_show_contacts(GSList *list) } curr = g_slist_next(curr); } - - if (wins_is_current(console)) { - win_update_virtual(console); - } cons_alert(); } diff --git a/src/ui/core.c b/src/ui/core.c index 6f82d558..4ad38fc2 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -113,8 +113,14 @@ _ui_init(void) } static void -_ui_update_screen(void) +_ui_update(void) { + ProfWin *current = wins_get_current(); + if (current->paged == 0) { + win_move_to_end(current); + win_update_virtual(current); + } + if (prefs_get_boolean(PREF_TITLEBAR)) { _ui_draw_term_title(); } @@ -129,9 +135,6 @@ _ui_about(void) { cons_show(""); cons_about(); - if (ui_current_win_type() != WIN_CONSOLE) { - status_bar_new(1); - } } static unsigned long @@ -256,11 +259,6 @@ _ui_handle_stanza(const char * const msg) win_save_print(xmlconsole, '-', NULL, NO_DATE, COLOUR_AWAY, "", &msg[6]); win_save_print(xmlconsole, '-', NULL, NO_DATE, COLOUR_AWAY, "", ""); } - - if (wins_is_current(xmlconsole)) { - win_update_virtual(xmlconsole); - ui_current_page_off(); - } } } @@ -268,7 +266,6 @@ static void _ui_contact_typing(const char * const barejid) { ProfWin *window = wins_get_by_recipient(barejid); - ProfWin *current = wins_get_current(); if (prefs_get_boolean(PREF_INTYPE)) { // no chat window for user @@ -278,7 +275,6 @@ _ui_contact_typing(const char * const barejid) // have chat window but not currently in it } else if (!wins_is_current(window)) { cons_show_typing(barejid); - win_update_virtual(current); // in chat window with user } else { @@ -286,7 +282,6 @@ _ui_contact_typing(const char * const barejid) int num = wins_get_num(window); status_bar_active(num); - win_update_virtual(current); } } @@ -358,7 +353,6 @@ _ui_incoming_msg(const char * const from, const char * const message, win_print_incoming_message(window, tv_stamp, display_from, message); title_bar_set_typing(FALSE); status_bar_active(num); - win_update_virtual(window); // not currently viewing chat window with sender } else { @@ -402,12 +396,6 @@ _ui_incoming_msg(const char * const from, const char * const message, } free(display_from); - - ProfWin *current = wins_get_current(); - if (!current->paged) { - win_move_to_end(current); - win_update_virtual(current); - } } static void @@ -461,7 +449,6 @@ _ui_auto_away(void) cons_show("Idle for %d minutes, status set to away (priority %d), \"%s\".", prefs_get_autoaway_time(), pri, pref_autoaway_message); title_bar_set_presence(CONTACT_AWAY); - ui_current_page_off(); } else { int pri = accounts_get_priority_for_presence_type(jabber_get_account_name(), @@ -469,7 +456,6 @@ _ui_auto_away(void) cons_show("Idle for %d minutes, status set to away (priority %d).", prefs_get_autoaway_time(), pri); title_bar_set_presence(CONTACT_AWAY); - ui_current_page_off(); } prefs_free_string(pref_autoaway_message); } @@ -481,7 +467,6 @@ _ui_end_auto_away(void) accounts_get_priority_for_presence_type(jabber_get_account_name(), RESOURCE_ONLINE); cons_show("No longer idle, status set to online (priority %d).", pri); title_bar_set_presence(CONTACT_ONLINE); - ui_current_page_off(); } static void @@ -497,7 +482,6 @@ _ui_handle_login_account_success(ProfAccount *account) contact_presence_t contact_presence = contact_presence_from_resource_presence(resource_presence); cons_show_login_success(account); title_bar_set_presence(contact_presence); - ui_current_page_off(); status_bar_print_message(account->jid); status_bar_update_virtual(); } @@ -540,9 +524,6 @@ _ui_handle_recipient_not_found(const char * const recipient, const char * const win_save_print(win, '!', NULL, 0, COLOUR_ERROR, "", msg->str); } - ProfWin *current = wins_get_current(); - win_update_virtual(current); - g_string_free(msg, TRUE); } @@ -561,9 +542,6 @@ _ui_handle_recipient_error(const char * const recipient, const char * const err_ win_save_print(win, '!', NULL, 0, COLOUR_ERROR, "", msg->str); } - ProfWin *current = wins_get_current(); - win_update_virtual(current); - g_string_free(msg, TRUE); } @@ -575,9 +553,6 @@ _ui_handle_error(const char * const err_msg) cons_show_error(msg->str); - ProfWin *current = wins_get_current(); - win_update_virtual(current); - g_string_free(msg, TRUE); } @@ -617,7 +592,6 @@ _ui_handle_special_keys(const wint_t * const ch, const char * const inp, if (*ch == KEY_RESIZE) { ui_resize(*ch, inp, size); } - } static void @@ -725,7 +699,6 @@ _ui_switch_win(const int i) if (ui_win_exists(i)) { ProfWin *new_current = wins_get_by_num(i); wins_set_current_by_num(i); - ui_current_page_off(); new_current->unread = 0; @@ -740,7 +713,6 @@ _ui_switch_win(const int i) status_bar_current(i); status_bar_active(i); } - win_update_virtual(new_current); return TRUE; } else { return FALSE; @@ -748,19 +720,11 @@ _ui_switch_win(const int i) } static void -_ui_current_update_virtual(void) -{ - ui_switch_win(wins_get_current_num()); -} - -static void _ui_next_win(void) { - ui_current_page_off(); ProfWin *new_current = wins_get_next(); int i = wins_get_num(new_current); wins_set_current_by_num(i); - ui_current_page_off(); new_current->unread = 0; @@ -775,7 +739,6 @@ _ui_next_win(void) status_bar_current(i); status_bar_active(i); } - win_update_virtual(new_current); } static void @@ -798,8 +761,6 @@ _ui_gone_secure(const char * const recipient, gboolean trusted) GString *recipient_str = _get_recipient_string(window); title_bar_set_recipient(recipient_str->str); g_string_free(recipient_str, TRUE); - win_update_virtual(window); - ui_current_page_off(); } else { int num = wins_get_num(window); status_bar_new(num); @@ -809,10 +770,6 @@ _ui_gone_secure(const char * const recipient, gboolean trusted) ui_index = 0; } cons_show("%s started an OTR session (%d).", recipient, ui_index); - ProfWin *console = wins_get_console(); - if (wins_is_current(console)) { - ui_current_page_off(); - } cons_alert(); } } @@ -825,10 +782,6 @@ _ui_smp_recipient_initiated(const char * const recipient) return; } else { win_save_vprint(window, '!', NULL, 0, 0, "", "%s wants to authenticate your identity, use '/otr secret <secret>'.", recipient); - win_update_virtual(window); - if (wins_is_current(window)) { - ui_current_page_off(); - } } } @@ -842,10 +795,6 @@ _ui_smp_recipient_initiated_q(const char * const recipient, const char *question win_save_vprint(window, '!', NULL, 0, 0, "", "%s wants to authenticate your identity with the following question:", recipient); win_save_vprint(window, '!', NULL, 0, 0, "", " %s", question); win_save_print(window, '!', NULL, 0, 0, "", "use '/otr answer <answer>'."); - win_update_virtual(window); - if (wins_is_current(window)) { - ui_current_page_off(); - } } } @@ -857,10 +806,6 @@ _ui_smp_unsuccessful_sender(const char * const recipient) return; } else { win_save_vprint(window, '!', NULL, 0, 0, "", "Authentication failed, the secret you entered does not match the secret entered by %s.", recipient); - win_update_virtual(window); - if (wins_is_current(window)) { - ui_current_page_off(); - } } } @@ -872,10 +817,6 @@ _ui_smp_unsuccessful_receiver(const char * const recipient) return; } else { win_save_vprint(window, '!', NULL, 0, 0, "", "Authentication failed, the secret entered by %s does not match yours.", recipient); - win_update_virtual(window); - if (wins_is_current(window)) { - ui_current_page_off(); - } } } @@ -887,10 +828,6 @@ _ui_smp_aborted(const char * const recipient) return; } else { win_save_print(window, '!', NULL, 0, 0, "", "SMP session aborted."); - win_update_virtual(window); - if (wins_is_current(window)) { - ui_current_page_off(); - } } } @@ -902,10 +839,6 @@ _ui_smp_successful(const char * const recipient) return; } else { win_save_print(window, '!', NULL, 0, 0, "", "Authentication successful."); - win_update_virtual(window); - if (wins_is_current(window)) { - ui_current_page_off(); - } } } @@ -917,10 +850,6 @@ _ui_smp_answer_success(const char * const recipient) return; } else { win_save_vprint(window, '!', NULL, 0, 0, "", "%s successfully authenticated you.", recipient); - win_update_virtual(window); - if (wins_is_current(window)) { - ui_current_page_off(); - } } } @@ -932,10 +861,6 @@ _ui_smp_answer_failure(const char * const recipient) return; } else { win_save_vprint(window, '!', NULL, 0, 0, "", "%s failed to authenticate you.", recipient); - win_update_virtual(window); - if (wins_is_current(window)) { - ui_current_page_off(); - } } } @@ -952,8 +877,6 @@ _ui_gone_insecure(const char * const recipient) GString *recipient_str = _get_recipient_string(window); title_bar_set_recipient(recipient_str->str); g_string_free(recipient_str, TRUE); - win_update_virtual(window); - ui_current_page_off(); } } } @@ -971,8 +894,6 @@ _ui_trust(const char * const recipient) GString *recipient_str = _get_recipient_string(window); title_bar_set_recipient(recipient_str->str); g_string_free(recipient_str, TRUE); - win_update_virtual(window); - ui_current_page_off(); } } } @@ -990,8 +911,6 @@ _ui_untrust(const char * const recipient) GString *recipient_str = _get_recipient_string(window); title_bar_set_recipient(recipient_str->str); g_string_free(recipient_str, TRUE); - win_update_virtual(window); - ui_current_page_off(); } } } @@ -999,11 +918,9 @@ _ui_untrust(const char * const recipient) static void _ui_previous_win(void) { - ui_current_page_off(); ProfWin *new_current = wins_get_previous(); int i = wins_get_num(new_current); wins_set_current_by_num(i); - ui_current_page_off(); new_current->unread = 0; @@ -1018,7 +935,6 @@ _ui_previous_win(void) status_bar_current(i); status_bar_active(i); } - win_update_virtual(new_current); } static void @@ -1045,9 +961,6 @@ _ui_close_win(int index) title_bar_console(); status_bar_current(1); status_bar_active(1); - - ProfWin *current = wins_get_current(); - win_update_virtual(current); } static void @@ -1142,10 +1055,6 @@ _ui_otr_authenticating(const char * const recipient) return; } else { win_save_vprint(window, '!', NULL, 0, 0, "", "Authenticating %s...", recipient); - win_update_virtual(window); - if (wins_is_current(window)) { - ui_current_page_off(); - } } } @@ -1157,10 +1066,6 @@ _ui_otr_authetication_waiting(const char * const recipient) return; } else { win_save_vprint(window, '!', NULL, 0, 0, "", "Awaiting authentication from %s...", recipient); - win_update_virtual(window); - if (wins_is_current(window)) { - ui_current_page_off(); - } } } @@ -1202,7 +1107,6 @@ _ui_current_print_line(const char * const msg, ...) win_save_println(window, fmt_msg->str); va_end(arg); g_string_free(fmt_msg, TRUE); - win_update_virtual(window); } static void @@ -1216,7 +1120,6 @@ _ui_current_print_formatted_line(const char show_char, int attrs, const char * c win_save_print(current, show_char, NULL, 0, attrs, "", fmt_msg->str); va_end(arg); g_string_free(fmt_msg, TRUE); - win_update_virtual(current); } static void @@ -1224,15 +1127,6 @@ _ui_current_error_line(const char * const msg) { ProfWin *current = wins_get_current(); win_save_print(current, '-', NULL, 0, COLOUR_ERROR, "", msg); - win_update_virtual(current); -} - -static void -_ui_current_page_off(void) -{ - ProfWin *current = wins_get_current(); - win_move_to_end(current); - win_update_virtual(current); } static void @@ -1259,11 +1153,6 @@ _ui_print_system_msg_from_recipient(const char * const from, const char *message win_save_vprint(window, '-', NULL, 0, 0, "", "*%s %s", jid->barejid, message); - // this is the current window - if (wins_is_current(window)) { - win_update_virtual(window); - } - jid_destroy(jid); } @@ -1288,9 +1177,6 @@ _ui_recipient_gone(const char * const barejid) ProfWin *window = wins_get_by_recipient(barejid); if (window != NULL) { win_save_vprint(window, '!', NULL, 0, COLOUR_GONE, "", "<- %s has left the conversation.", display_usr); - if (wins_is_current(window)) { - win_update_virtual(window); - } } } @@ -1455,7 +1341,6 @@ _ui_outgoing_msg(const char * const from, const char * const to, } win_save_print(window, '-', NULL, 0, 0, from, message); - ui_switch_win(num); } static void @@ -1478,7 +1363,6 @@ _ui_room_join(const char * const room, gboolean focus) ProfWin *console = wins_get_console(); char *nick = muc_get_room_nick(room); win_save_vprint(console, '!', NULL, 0, COLOUR_TYPING, "", "-> Autojoined %s as %s (%d).", room, nick, num); - win_update_virtual(console); } } @@ -1523,10 +1407,6 @@ _ui_room_roster(const char * const room, GList *roster, const char * const prese win_save_print(window, '!', NULL, NO_DATE, COLOUR_ONLINE, "", ""); } - - if (wins_is_current(window)) { - win_update_virtual(window); - } } } @@ -1544,9 +1424,6 @@ _ui_room_member_offline(const char * const room, const char * const nick) log_error("Received offline presence for room participant %s, but no window open for %s.", nick, room); } else { win_save_vprint(window, '!', NULL, 0, COLOUR_OFFLINE, "", "<- %s has left the room.", nick); - if (wins_is_current(window)) { - win_update_virtual(window); - } } } @@ -1559,9 +1436,6 @@ _ui_room_member_online(const char * const room, const char * const nick, log_error("Received online presence for room participant %s, but no window open for %s.", nick, room); } else { win_save_vprint(window, '!', NULL, 0, COLOUR_ONLINE, "", "-> %s has joined the room.", nick); - if (wins_is_current(window)) { - win_update_virtual(window); - } } } @@ -1574,9 +1448,6 @@ _ui_room_member_presence(const char * const room, const char * const nick, log_error("Received presence for room participant %s, but no window open for %s.", nick, room); } else { win_show_status_string(window, nick, show, status, NULL, "++", "online"); - if (wins_is_current(window)) { - win_update_virtual(window); - } } } @@ -1589,9 +1460,6 @@ _ui_room_member_nick_change(const char * const room, log_error("Received nick change for room participant %s, but no window open for %s.", old_nick, room); } else { win_save_vprint(window, '!', NULL, 0, COLOUR_THEM, "", "** %s is now known as %s", old_nick, nick); - if (wins_is_current(window)) { - win_update_virtual(window); - } } } @@ -1603,9 +1471,6 @@ _ui_room_nick_change(const char * const room, const char * const nick) log_error("Received self nick change %s, but no window open for %s.", nick, room); } else { win_save_vprint(window, '!', NULL, 0, COLOUR_ME, "", "** You are now known as %s", nick); - if (wins_is_current(window)) { - win_update_virtual(window); - } } } @@ -1638,10 +1503,6 @@ _ui_room_history(const char * const room_jid, const char * const nick, win_save_print(window, '-', NULL, NO_DATE, 0, "", line->str); g_string_free(line, TRUE); - - if (wins_is_current(window)) { - win_update_virtual(window); - } } } @@ -1669,16 +1530,11 @@ _ui_room_message(const char * const room_jid, const char * const nick, // currently in groupchat window if (wins_is_current(window)) { status_bar_active(num); - win_update_virtual(window); // not currenlty on groupchat window } else { status_bar_new(num); cons_show_incoming_message(nick, num); - if (wins_get_current_num() == 0) { - ProfWin *current = wins_get_current(); - win_update_virtual(current); - } if (strcmp(nick, my_nick) != 0) { if (prefs_get_boolean(PREF_FLASH)) { @@ -1728,12 +1584,6 @@ _ui_room_message(const char * const room_jid, const char * const nick, } } } - - ProfWin *current = wins_get_current(); - if (!current->paged) { - win_move_to_end(current); - win_update_virtual(current); - } } } @@ -1752,7 +1602,6 @@ _ui_room_subject(const char * const room_jid, const char * const subject) // currently in groupchat window if (wins_is_current(window)) { status_bar_active(num); - win_update_virtual(window); // not currenlty on groupchat window } else { @@ -1776,7 +1625,6 @@ _ui_room_broadcast(const char * const room_jid, const char * const message) // currently in groupchat window if (wins_is_current(window)) { status_bar_active(num); - win_update_virtual(window); // not currenlty on groupchat window } else { @@ -1913,10 +1761,6 @@ _ui_chat_win_contact_online(PContact contact, Resource *resource, GDateTime *las win_show_status_string(window, display_str, show, resource->status, last_activity, "++", "online"); - if (wins_is_current(window)) { - win_update_virtual(window); - ui_current_page_off(); - } } free(display_str); @@ -1932,11 +1776,6 @@ _ui_chat_win_contact_offline(PContact contact, char *resource, char *status) if (window != NULL) { win_show_status_string(window, display_str, "offline", status, NULL, "--", "offline"); - - if (wins_is_current(window)) { - win_update_virtual(window); - ui_current_page_off(); - } } free(display_str); @@ -2117,7 +1956,6 @@ void ui_init_module(void) { ui_init = _ui_init; - ui_update_screen = _ui_update_screen; ui_get_idle_time = _ui_get_idle_time; ui_reset_idle_time = _ui_reset_idle_time; ui_close = _ui_close; @@ -2155,7 +1993,6 @@ ui_init_module(void) ui_current_print_line = _ui_current_print_line; ui_current_print_formatted_line = _ui_current_print_formatted_line; ui_current_error_line = _ui_current_error_line; - ui_current_page_off = _ui_current_page_off; ui_print_system_msg_from_recipient = _ui_print_system_msg_from_recipient; ui_recipient_gone = _ui_recipient_gone; ui_new_chat_win = _ui_new_chat_win; @@ -2205,7 +2042,6 @@ ui_init_module(void) ui_handle_recipient_not_found = _ui_handle_recipient_not_found; ui_handle_recipient_error = _ui_handle_recipient_error; ui_handle_error = _ui_handle_error; - ui_current_update_virtual = _ui_current_update_virtual; ui_clear_win_title = _ui_clear_win_title; ui_auto_away = _ui_auto_away; ui_end_auto_away = _ui_end_auto_away; @@ -2225,4 +2061,5 @@ ui_init_module(void) ui_open_xmlconsole_win = _ui_open_xmlconsole_win; ui_handle_room_join_error = _ui_handle_room_join_error; ui_swap_wins = _ui_swap_wins; + ui_update = _ui_update; } diff --git a/src/ui/ui.h b/src/ui/ui.h index 5a079f7d..7787a101 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -60,7 +60,7 @@ void notifier_init_module(void); // ui startup and control void (*ui_init)(void); void (*ui_load_colours)(void); -void (*ui_update_screen)(void); +void (*ui_update)(void); void (*ui_close)(void); void (*ui_resize)(const int ch, const char * const input, const int size); @@ -106,8 +106,6 @@ char* (*ui_current_recipient)(void); void (*ui_current_print_line)(const char * const msg, ...); void (*ui_current_print_formatted_line)(const char show_char, int attrs, const char * const msg, ...); void (*ui_current_error_line)(const char * const msg); -void (*ui_current_page_off)(void); -void (*ui_current_update_virtual)(void); void (*ui_otr_authenticating)(const char * const recipient); void (*ui_otr_authetication_waiting)(const char * const recipient); |