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

Merge branch 'master' into inp-utf8

This commit is contained in:
James Booth 2015-01-15 22:25:15 +00:00
commit 173a3a82bb
4 changed files with 27 additions and 17 deletions

View File

@ -79,17 +79,15 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
_connect_default(account_name);
ui_update();
char inp[INP_WIN_MAX];
gboolean read_input = TRUE;
char *line = NULL;
gboolean cmd_result = TRUE;
log_info("Starting main event loop");
while(cmd_result == TRUE) {
read_input = TRUE;
while(read_input) {
while(cmd_result) {
while(!line) {
_check_autoaway();
read_input = ui_get_char(inp);
line = ui_readline();
#ifdef HAVE_LIBOTR
otr_poll();
#endif
@ -97,8 +95,9 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
jabber_process_events();
ui_update();
}
cmd_result = cmd_process_input(inp);
cmd_result = cmd_process_input(line);
ui_input_clear();
line = NULL;
}
}

View File

@ -73,6 +73,8 @@
#include "xmpp/xmpp.h"
static char *win_title;
static char input[INP_WIN_MAX];
static int inp_size;
#ifdef HAVE_LIBXSS
@ -176,14 +178,24 @@ ui_close(void)
endwin();
}
gboolean
ui_get_char(char *input)
char*
ui_readline(void)
{
int result = 0;
gboolean return_line = FALSE;
wint_t ch = inp_get_char(input, &inp_size, &result);
if (ch == '\n') {
input[inp_size++] = '\0';
inp_size = 0;
return_line = TRUE;
}
_win_handle_switch(ch);
ProfWin *current = wins_get_current();
win_handle_page(current, ch, result);
if (ch == KEY_RESIZE) {
ui_resize();
}
@ -195,12 +207,11 @@ ui_get_char(char *input)
ui_input_nonblocking(FALSE);
}
if (ch == '\n') {
input[inp_size++] = '\0';
inp_size = 0;
if (return_line) {
return input;
} else {
return NULL;
}
return (ch != '\n');
}
void

View File

@ -229,7 +229,7 @@ void ui_update_presence(const resource_presence_t resource_presence,
void ui_about(void);
void ui_statusbar_new(const int win);
gboolean ui_get_char(char *input);
char * ui_readline(void);
void ui_input_clear(void);
void ui_input_nonblocking(gboolean);
void ui_replace_input(char *input, const char * const new_input, int *size);

View File

@ -323,9 +323,9 @@ void ui_update_presence(const resource_presence_t resource_presence,
void ui_about(void) {}
void ui_statusbar_new(const int win) {}
gboolean ui_get_char(char *input)
char * ui_readline(void)
{
return FALSE;
return NULL;
}
void ui_input_clear(void) {}