mirror of
https://github.com/Tha14/toxic.git
synced 2025-07-09 21:56:46 +02:00
added ability to close and reopen chat windows & other minor changes
This commit is contained in:
15
chat.c
15
chat.c
@ -25,6 +25,8 @@ typedef struct {
|
||||
|
||||
} ChatContext;
|
||||
|
||||
extern void del_window(ToxWindow *w, int f_num);
|
||||
extern int focus_window(int num);
|
||||
extern void fix_name(uint8_t* name);
|
||||
void print_help(ChatContext* self);
|
||||
void execute(ToxWindow* self, ChatContext* ctx, char* cmd);
|
||||
@ -50,7 +52,7 @@ static void chat_onMessage(ToxWindow* self, int num, uint8_t* msg, uint16_t len)
|
||||
fix_name(nick);
|
||||
|
||||
wattron(ctx->history, COLOR_PAIR(2));
|
||||
wprintw(ctx->history, "%02d:%02d:%02d ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
||||
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
||||
wattroff(ctx->history, COLOR_PAIR(2));
|
||||
wattron(ctx->history, COLOR_PAIR(4));
|
||||
wprintw(ctx->history, "%s: ", nick);
|
||||
@ -116,7 +118,7 @@ static void chat_onKey(ToxWindow* self, int key) {
|
||||
if(!string_is_empty(ctx->line)) {
|
||||
/* make sure the string has at least non-space character */
|
||||
wattron(ctx->history, COLOR_PAIR(2));
|
||||
wprintw(ctx->history, "%02d:%02d:%02d ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
||||
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
||||
wattroff(ctx->history, COLOR_PAIR(2));
|
||||
wattron(ctx->history, COLOR_PAIR(1));
|
||||
wprintw(ctx->history, "you: ", ctx->line);
|
||||
@ -185,6 +187,12 @@ void execute(ToxWindow* self, ChatContext* ctx, char* cmd)
|
||||
}
|
||||
wprintw(ctx->history, "Your ID: %s\n", id);
|
||||
}
|
||||
else if (strcmp(ctx->line, "/close") == 0) {
|
||||
focus_window(0); // Go to prompt screen
|
||||
int f_num = ctx->friendnum;
|
||||
delwin(ctx->linewin);
|
||||
del_window(self, f_num);
|
||||
}
|
||||
else
|
||||
wprintw(ctx->history, "Invalid command.\n");
|
||||
}
|
||||
@ -256,6 +264,5 @@ ToxWindow new_chat(int friendnum) {
|
||||
x->friendnum = friendnum;
|
||||
|
||||
ret.x = (void*) x;
|
||||
free(x);
|
||||
return ret;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user