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

View File

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

View File

@ -229,7 +229,7 @@ void ui_update_presence(const resource_presence_t resource_presence,
void ui_about(void); void ui_about(void);
void ui_statusbar_new(const int win); 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_clear(void);
void ui_input_nonblocking(gboolean); void ui_input_nonblocking(gboolean);
void ui_replace_input(char *input, const char * const new_input, int *size); 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_about(void) {}
void ui_statusbar_new(const int win) {} 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) {} void ui_input_clear(void) {}