diff options
author | James Booth <boothj5@gmail.com> | 2012-02-20 01:42:29 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-02-20 01:42:29 +0000 |
commit | 7dfea94c88a876c51b86b46578c4cf409605a6c3 (patch) | |
tree | 6d89f0cc73533e1af28dd08bfa0fa7b4ce3766ec /profanity.c | |
parent | b3f42cd300e703e4d411ed03cef138462ff34fbf (diff) | |
download | profani-tty-7dfea94c88a876c51b86b46578c4cf409605a6c3.tar.gz |
Merged input processing loops
Diffstat (limited to 'profanity.c')
-rw-r--r-- | profanity.c | 44 |
1 files changed, 6 insertions, 38 deletions
diff --git a/profanity.c b/profanity.c index 7e0dbe30..a4352c74 100644 --- a/profanity.c +++ b/profanity.c @@ -9,59 +9,27 @@ #include "jabber.h" #include "command.h" -static int _profanity_main(void); static void _profanity_event_loop(int *ch, char *cmd, int *size); static void _process_special_keys(int *ch); -int profanity_start(void) -{ - int exit_status = QUIT; - int cmd_result = AWAIT_COMMAND; - char cmd[50]; - - title_bar_disconnected(); - gui_refresh(); - - while (cmd_result == AWAIT_COMMAND) { - title_bar_refresh(); - status_bar_refresh(); - inp_get_command_str(cmd); - cmd_result = handle_start_command(cmd); - } - - if (cmd_result == START_MAIN) { - exit_status = _profanity_main(); - } - - return exit_status; -} - -static int _profanity_main(void) +void profanity_main(void) { int cmd_result = TRUE; inp_non_block(); while(cmd_result == TRUE) { int ch = ERR; - char cmd[100]; + char inp[100]; int size = 0; - while(ch != '\n') { - _profanity_event_loop(&ch, cmd, &size); - - int conn_status = jabber_connection_status(); - if (conn_status == DISCONNECTED) { - inp_block(); - return LOGIN_FAIL; - } - } + while(ch != '\n') + _profanity_event_loop(&ch, inp, &size); - cmd[size++] = '\0'; - cmd_result = handle_command(cmd); + inp[size++] = '\0'; + cmd_result = process_input(inp); } jabber_disconnect(); - return QUIT; } static void _profanity_event_loop(int *ch, char *cmd, int *size) |