From f94b6ef0a213df2834ceece34036cf4c4990ba9a Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 31 Jan 2015 00:20:25 +0000 Subject: Added idle and activity handlers --- src/profanity.c | 2 ++ src/ui/inputwin.c | 25 +++++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/profanity.c b/src/profanity.c index f3c53003..cb3ce4eb 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -99,6 +99,7 @@ prof_run(const int disable_tls, char *log_level, char *account_name) void prof_handle_idle(void) { + cons_debug("IDLE"); jabber_conn_status_t status = jabber_get_connection_status(); if (status == JABBER_CONNECTED) { GSList *recipients = ui_get_chat_recipients(); @@ -120,6 +121,7 @@ prof_handle_idle(void) void prof_handle_activity(void) { + cons_debug("ACTIVITY"); win_type_t win_type = ui_current_win_type(); jabber_conn_status_t status = jabber_get_connection_status(); diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index 55bf8912..b736fca3 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -142,16 +142,6 @@ offset_to_col(char *str, int offset) return col; } -void -inp_write(char *line, int offset) -{ - int col = offset_to_col(line, offset); - werase(inp_win); - waddstr(inp_win, line); - wmove(inp_win, 0, col); - _inp_win_update_virtual(); -} - void inp_non_block(gint block_timeout) { @@ -164,6 +154,16 @@ inp_block(void) wtimeout(inp_win, -1); } +void +inp_write(char *line, int offset) +{ + int col = offset_to_col(line, offset); + werase(inp_win); + waddstr(inp_win, line); + wmove(inp_win, 0, col); + _inp_win_update_virtual(); +} + gboolean inp_readline(void) { @@ -177,7 +177,12 @@ inp_readline(void) if (FD_ISSET(fileno(rl_instream), &fds)) { rl_callback_read_char(); + if (rl_line_buffer && rl_line_buffer[0] != '/') { + prof_handle_activity(); + } inp_write(rl_line_buffer, rl_point); + } else { + prof_handle_idle(); } p_rl_timeout.tv_sec = 0; -- cgit 1.4.1-2-gfad0