1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Added idle and activity handlers

This commit is contained in:
James Booth 2015-01-31 00:20:25 +00:00
parent 1cf5592b1f
commit f94b6ef0a2
2 changed files with 17 additions and 10 deletions

View File

@ -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();

View File

@ -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;