mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-25 23:06:21 +00:00
SImple window switching for message and console
This commit is contained in:
44
app.c
44
app.c
@@ -7,37 +7,49 @@
|
||||
#include "windows.h"
|
||||
#include "jabber.h"
|
||||
|
||||
#define CHAT 0
|
||||
#define CONS 1
|
||||
|
||||
static void main_event_loop(void);
|
||||
|
||||
void start_profanity(void)
|
||||
{
|
||||
char cmd[50];
|
||||
while (TRUE) {
|
||||
cmd_get_command_str(cmd);
|
||||
inp_get_command_str(cmd);
|
||||
|
||||
if (strcmp(cmd, "/quit") == 0) {
|
||||
break;
|
||||
} else if (strncmp(cmd, "/help", 5) == 0) {
|
||||
cons_help();
|
||||
cons_show();
|
||||
inp_clear();
|
||||
} else if (strncmp(cmd, "/connect ", 9) == 0) {
|
||||
char *user;
|
||||
user = strndup(cmd+9, strlen(cmd)-9);
|
||||
|
||||
bar_print_message("Enter password:");
|
||||
char passwd[20];
|
||||
cmd_get_password(passwd);
|
||||
inp_get_password(passwd);
|
||||
|
||||
bar_print_message(user);
|
||||
jabber_connect(user, passwd);
|
||||
chat_show();
|
||||
main_event_loop();
|
||||
break;
|
||||
} else {
|
||||
cmd_clear();
|
||||
cons_bad_command(cmd);
|
||||
cons_show();
|
||||
inp_clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void main_event_loop(void)
|
||||
{
|
||||
cmd_non_block();
|
||||
int showing = CHAT;
|
||||
|
||||
inp_non_block();
|
||||
|
||||
while(TRUE) {
|
||||
int ch = ERR;
|
||||
@@ -50,9 +62,20 @@ static void main_event_loop(void)
|
||||
|
||||
// handle incoming messages
|
||||
jabber_process_events();
|
||||
if (showing == CHAT) {
|
||||
chat_show();
|
||||
}
|
||||
|
||||
// determine if they changed windows
|
||||
if (ch == KEY_F(1)) {
|
||||
cons_show();
|
||||
showing = CONS;
|
||||
} else if (ch == KEY_F(2)) {
|
||||
chat_show();
|
||||
showing = CHAT;
|
||||
}
|
||||
// get another character from the command box
|
||||
cmd_poll_char(&ch, command, &size);
|
||||
inp_poll_char(&ch, command, &size);
|
||||
}
|
||||
|
||||
// null terminate the input
|
||||
@@ -61,10 +84,19 @@ static void main_event_loop(void)
|
||||
// newline was hit, check if /quit command issued
|
||||
if (strcmp(command, "/quit") == 0) {
|
||||
break;
|
||||
} else if (strncmp(command, "/help", 5) == 0) {
|
||||
cons_help();
|
||||
if (showing == CONS) {
|
||||
cons_show();
|
||||
}
|
||||
inp_clear();
|
||||
} else {
|
||||
jabber_send(command);
|
||||
show_outgoing_msg("me", command);
|
||||
cmd_clear();
|
||||
if (showing == CHAT) {
|
||||
chat_show();
|
||||
}
|
||||
inp_clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user