1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Inlined wins_update_virtual_console and wins_update_virtual_current

This commit is contained in:
James Booth 2014-04-06 21:06:50 +01:00
parent 6b2d2fd8e4
commit ccfea12674
4 changed files with 191 additions and 96 deletions

View File

@ -52,7 +52,10 @@ _cons_show_time(void)
{
ProfWin *console = wins_get_console();
win_print_time(console, '-');
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
}
static void
@ -60,7 +63,10 @@ _cons_show_word(const char * const word)
{
ProfWin *console = wins_get_console();
wprintw(console->win, "%s", word);
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
}
static void
@ -77,7 +83,9 @@ _cons_debug(const char * const msg, ...)
g_string_free(fmt_msg, TRUE);
va_end(arg);
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
ui_current_page_off();
@ -97,7 +105,10 @@ _cons_show(const char * const msg, ...)
wprintw(console->win, "%s\n", fmt_msg->str);
g_string_free(fmt_msg, TRUE);
va_end(arg);
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
}
static void
@ -115,7 +126,10 @@ _cons_show_error(const char * const msg, ...)
g_string_free(fmt_msg, TRUE);
va_end(arg);
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
@ -133,7 +147,10 @@ _cons_show_typing(const char * const barejid)
win_vprint_line(console, '-', COLOUR_TYPING, "!! %s is typing a message...", display_usr);
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
@ -151,7 +168,10 @@ _cons_show_incoming_message(const char * const short_from, const int win_index)
wprintw(console->win, "<< incoming from %s (%d)\n", short_from, ui_index);
wattroff(console->win, COLOUR_INCOMING);
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
@ -203,7 +223,10 @@ _cons_about(void)
pnoutrefresh(console->win, 0, 0, 1, 0, rows-3, cols-1);
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
@ -232,7 +255,10 @@ _cons_check_version(gboolean not_available_msg)
}
}
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
}
@ -254,7 +280,9 @@ _cons_show_login_success(ProfAccount *account)
wprintw(console->win, " (priority %d)",
accounts_get_priority_for_presence_type(account->name, presence));
wprintw(console->win, ".\n");
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
@ -275,13 +303,16 @@ _cons_show_wins(void)
}
cons_show("");
wins_update_virtual_console();
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.");
@ -293,7 +324,9 @@ _cons_show_room_invites(GSList *invites)
}
}
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
@ -426,7 +459,9 @@ _cons_show_info(PContact pcontact)
ordered_resources = g_list_next(ordered_resources);
}
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
@ -501,7 +536,9 @@ _cons_show_caps(const char * const contact, Resource *resource)
}
}
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
@ -528,7 +565,9 @@ _cons_show_software_version(const char * const jid, const char * const presence
cons_show("OS : %s", os);
}
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
@ -592,13 +631,16 @@ _cons_show_room_list(GSList *rooms, const char * const conference_node)
cons_show("No chat rooms at %s", conference_node);
}
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
static void
_cons_show_bookmarks(const GList *list)
{
ProfWin *console = wins_get_console();
Bookmark *item;
cons_show("");
@ -608,8 +650,6 @@ _cons_show_bookmarks(const GList *list)
while (list != NULL) {
item = list->data;
ProfWin *console = wins_get_console();
win_print_time(console, '-');
wprintw(console->win, " %s", item->jid);
if (item->nick != NULL) {
@ -622,13 +662,16 @@ _cons_show_bookmarks(const GList *list)
list = g_list_next(list);
}
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
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("");
@ -664,7 +707,9 @@ _cons_show_disco_info(const char *jid, GSList *identities, GSList *features)
features = g_slist_next(features);
}
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
}
@ -690,7 +735,10 @@ _cons_show_disco_items(GSList *items, const char * const jid)
cons_show("");
cons_show("No service discovery items for %s", jid);
}
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
@ -705,7 +753,10 @@ _cons_show_status(const char * const barejid)
} else {
cons_show("No such contact \"%s\" in roster.", barejid);
}
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
@ -713,6 +764,7 @@ 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) {
@ -742,7 +794,9 @@ _cons_show_room_invite(const char * const invitor, const char * const room,
free(display_from);
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
@ -772,7 +826,9 @@ _cons_show_account_list(gchar **accounts)
cons_show("");
}
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
@ -898,7 +954,9 @@ _cons_show_account(ProfAccount *account)
}
}
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
@ -1022,6 +1080,7 @@ _cons_otrwarn_setting(void)
static void
_cons_show_ui_prefs(void)
{
ProfWin *console = wins_get_console();
cons_show("UI preferences:");
cons_show("");
cons_theme_setting();
@ -1034,7 +1093,9 @@ _cons_show_ui_prefs(void)
cons_titlebar_setting();
cons_otrwarn_setting();
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
@ -1074,11 +1135,14 @@ _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();
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
@ -1134,6 +1198,7 @@ _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();
@ -1142,7 +1207,9 @@ _cons_show_chat_prefs(void)
cons_gone_setting();
cons_history_setting();
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
@ -1187,6 +1254,7 @@ _cons_otr_log_setting(void)
static void
_cons_show_log_prefs(void)
{
ProfWin *console = wins_get_console();
cons_show("Logging preferences:");
cons_show("");
cons_log_setting();
@ -1194,7 +1262,9 @@ _cons_show_log_prefs(void)
cons_grlog_setting();
cons_otr_log_setting();
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
@ -1226,11 +1296,14 @@ _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();
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
@ -1270,19 +1343,23 @@ _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();
wins_update_virtual_console();
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) {
@ -1295,13 +1372,16 @@ _cons_show_themes(GSList *themes)
}
}
wins_update_virtual_console();
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("");
@ -1316,13 +1396,16 @@ _cons_prefs(void)
cons_show_connection_prefs();
cons_show("");
wins_update_virtual_console();
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("");
@ -1339,13 +1422,16 @@ _cons_help(void)
cons_show("/help [command] - Detailed help on a specific command.");
cons_show("");
wins_update_virtual_console();
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("");
@ -1361,13 +1447,16 @@ _cons_navigation_help(void)
cons_show("PAGE UP, PAGE DOWN : Page the main window.");
cons_show("");
wins_update_virtual_console();
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) {
@ -1377,18 +1466,23 @@ _cons_show_roster_group(const char * const group, GSList *list)
}
_show_roster_contacts(list, FALSE);
wins_update_virtual_console();
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:");
_show_roster_contacts(list, TRUE);
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
@ -1407,7 +1501,9 @@ _cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_
if (wins_is_current(console)) {
ui_current_page_off();
}
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
}
static void
@ -1423,7 +1519,9 @@ _cons_show_contact_offline(PContact contact, char *resource, char *status)
if (wins_is_current(console)) {
ui_current_page_off();
}
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
}
static void
@ -1441,7 +1539,9 @@ _cons_show_contacts(GSList *list)
curr = g_slist_next(curr);
}
wins_update_virtual_console();
if (wins_is_current(console)) {
win_update_virtual(console);
}
cons_alert();
}
@ -1582,7 +1682,6 @@ _show_roster_contacts(GSList *list, gboolean show_groups)
curr = g_slist_next(curr);
}
}
void

View File

@ -94,7 +94,8 @@ _ui_init(void)
display = XOpenDisplay(0);
#endif
ui_idle_time = g_timer_new();
wins_update_virtual_current();
ProfWin *window = wins_get_current();
win_update_virtual(window);
}
static void
@ -150,7 +151,8 @@ _ui_resize(const int ch, const char * const input, const int size)
status_bar_resize();
wins_resize_all();
inp_win_resize(input, size);
wins_update_virtual_current();
ProfWin *window = wins_get_current();
win_update_virtual(window);
}
static void
@ -180,6 +182,7 @@ 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
@ -189,7 +192,7 @@ _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);
wins_update_virtual_current();
win_update_virtual(current);
// in chat window with user
} else {
@ -197,7 +200,7 @@ _ui_contact_typing(const char * const barejid)
int num = wins_get_num(window);
status_bar_active(num);
wins_update_virtual_current();
win_update_virtual(current);
}
}
@ -263,7 +266,7 @@ _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);
wins_update_virtual_current();
win_update_virtual(window);
// not currently viewing chat window with sender
} else {
@ -371,7 +374,8 @@ _ui_handle_recipient_not_found(const char * const recipient, const char * const
win_print_line(win, '!', COLOUR_ERROR, msg->str);
}
wins_update_virtual_current();
ProfWin *current = wins_get_current();
win_update_virtual(current);
g_string_free(msg, TRUE);
}
@ -391,7 +395,8 @@ _ui_handle_recipient_error(const char * const recipient, const char * const err_
win_print_line(win, '!', COLOUR_ERROR, msg->str);
}
wins_update_virtual_current();
ProfWin *current = wins_get_current();
win_update_virtual(current);
g_string_free(msg, TRUE);
}
@ -404,7 +409,8 @@ _ui_handle_error(const char * const err_msg)
cons_show_error(msg->str);
wins_update_virtual_current();
ProfWin *current = wins_get_current();
win_update_virtual(current);
g_string_free(msg, TRUE);
}
@ -551,7 +557,7 @@ _ui_switch_win(const int i)
status_bar_current(i);
status_bar_active(i);
}
wins_update_virtual_current();
win_update_virtual(new_current);
return TRUE;
} else {
return FALSE;
@ -586,7 +592,7 @@ _ui_next_win(void)
status_bar_current(i);
status_bar_active(i);
}
wins_update_virtual_current();
win_update_virtual(new_current);
}
static void
@ -606,7 +612,7 @@ _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);
wins_update_virtual_current();
win_update_virtual(window);
}
}
}
@ -624,7 +630,7 @@ _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);
wins_update_virtual_current();
win_update_virtual(window);
}
}
}
@ -642,7 +648,7 @@ _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);
wins_update_virtual_current();
win_update_virtual(window);
}
}
}
@ -660,7 +666,7 @@ _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);
wins_update_virtual_current();
win_update_virtual(window);
}
}
}
@ -687,7 +693,7 @@ _ui_previous_win(void)
status_bar_current(i);
status_bar_active(i);
}
wins_update_virtual_current();
win_update_virtual(new_current);
}
static void
@ -715,7 +721,8 @@ _ui_close_win(int index)
status_bar_current(1);
status_bar_active(1);
wins_update_virtual_current();
ProfWin *current = wins_get_current();
win_update_virtual(current);
}
static void
@ -895,7 +902,7 @@ _ui_print_system_msg_from_recipient(const char * const from, const char *message
// this is the current window
if (wins_is_current(window)) {
wins_update_virtual_current();
win_update_virtual(window);
}
jid_destroy(jid);
@ -919,7 +926,7 @@ _ui_recipient_gone(const char * const barejid)
if (window != NULL) {
win_vprint_line(window, '!', COLOUR_GONE, "<- %s has left the conversation.", display_usr);
if (wins_is_current(window)) {
wins_update_virtual_current();
win_update_virtual(window);
}
}
}
@ -1154,7 +1161,7 @@ _ui_room_roster(const char * const room, GList *roster, const char * const prese
}
if (wins_is_current(window)) {
wins_update_virtual_current();
win_update_virtual(window);
}
}
@ -1169,7 +1176,7 @@ _ui_room_member_offline(const char * const room, const char * const nick)
wattroff(window->win, COLOUR_OFFLINE);
if (wins_is_current(window)) {
wins_update_virtual_current();
win_update_virtual(window);
}
}
@ -1185,7 +1192,7 @@ _ui_room_member_online(const char * const room, const char * const nick,
wattroff(window->win, COLOUR_ONLINE);
if (wins_is_current(window)) {
wins_update_virtual_current();
win_update_virtual(window);
}
}
@ -1200,7 +1207,7 @@ _ui_room_member_presence(const char * const room, const char * const nick,
}
if (wins_is_current(window)) {
wins_update_virtual_current();
win_update_virtual(window);
}
}
@ -1216,7 +1223,7 @@ _ui_room_member_nick_change(const char * const room,
wattroff(window->win, COLOUR_THEM);
if (wins_is_current(window)) {
wins_update_virtual_current();
win_update_virtual(window);
}
}
@ -1231,7 +1238,7 @@ _ui_room_nick_change(const char * const room, const char * const nick)
wattroff(window->win, COLOUR_ME);
if (wins_is_current(window)) {
wins_update_virtual_current();
win_update_virtual(window);
}
}
@ -1257,7 +1264,7 @@ _ui_room_history(const char * const room_jid, const char * const nick,
}
if (wins_is_current(window)) {
wins_update_virtual_current();
win_update_virtual(window);
}
}
@ -1297,14 +1304,15 @@ _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);
wins_update_virtual_current();
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) {
wins_update_virtual_current();
ProfWin *current = wins_get_current();
win_update_virtual(current);
}
if (strcmp(nick, muc_get_room_nick(room_jid)) != 0) {
@ -1354,7 +1362,7 @@ _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);
wins_update_virtual_current();
win_update_virtual(window);
// not currenlty on groupchat window
} else {
@ -1377,7 +1385,7 @@ _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);
wins_update_virtual_current();
win_update_virtual(window);
// not currenlty on groupchat window
} else {
@ -1471,7 +1479,7 @@ _ui_chat_win_contact_online(PContact contact, Resource *resource, GDateTime *las
last_activity, "++", "online");
if (wins_is_current(window)) {
wins_update_virtual_current();
win_update_virtual(window);
ui_current_page_off();
}
}
@ -1491,7 +1499,7 @@ _ui_chat_win_contact_offline(PContact contact, char *resource, char *status)
"offline");
if (wins_is_current(window)) {
wins_update_virtual_current();
win_update_virtual(window);
ui_current_page_off();
}
}
@ -1618,7 +1626,7 @@ _win_handle_page(const wint_t * const ch)
*page_start = y - page_space;
current->paged = 1;
wins_update_virtual_current();
win_update_virtual(current);
} else if (mouse_event.bstate & BUTTON4_PRESSED) { // mouse wheel up
*page_start -= 4;
@ -1627,7 +1635,7 @@ _win_handle_page(const wint_t * const ch)
*page_start = 0;
current->paged = 1;
wins_update_virtual_current();
win_update_virtual(current);
}
}
}
@ -1642,7 +1650,7 @@ _win_handle_page(const wint_t * const ch)
*page_start = 0;
current->paged = 1;
wins_update_virtual_current();
win_update_virtual(current);
// page down
} else if (*ch == KEY_NPAGE) {
@ -1657,7 +1665,7 @@ _win_handle_page(const wint_t * const ch)
*page_start = y - page_space;
current->paged = 1;
wins_update_virtual_current();
win_update_virtual(current);
}
// switch off page if last line visible

View File

@ -194,29 +194,27 @@ wins_close_current(void)
void
wins_close_by_num(int i)
{
// console cannot be closed
if (i != 1) {
// go to console if closing current window
if (i == current) {
current = 1;
wins_update_virtual_current();
ProfWin *window = wins_get_current();
win_update_virtual(window);
}
g_hash_table_remove(windows, GINT_TO_POINTER(i));
status_bar_inactive(i);
}
}
void
wins_update_virtual_current(void)
{
ProfWin *window = wins_get_current();
win_update_virtual(window);
}
void
wins_clear_current(void)
{
ProfWin *window = wins_get_current();
werase(window->win);
wins_update_virtual_current();
win_update_virtual(window);
}
gboolean
@ -282,14 +280,6 @@ wins_resize_all(void)
pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, cols-1);
}
void
wins_update_virtual_console(void)
{
if (current == 0) {
wins_update_virtual_current();
}
}
gboolean
wins_duck_exists(void)
{
@ -356,7 +346,7 @@ wins_lost_connection(void)
// if current win, set current_win_dirty
if (wins_is_current(window)) {
wins_update_virtual_current();
win_update_virtual(window);
}
}
curr = g_list_next(curr);

View File

@ -35,8 +35,6 @@ int wins_get_num(ProfWin *window);
int wins_get_current_num(void);
void wins_close_current(void);
void wins_close_by_num(int i);
void wins_update_virtual_current(void);
void wins_update_virtual_console(void);
void wins_clear_current(void);
gboolean wins_is_current(ProfWin *window);
ProfWin * wins_new(const char * const from, win_type_t type);