summaryrefslogtreecommitdiff
path: root/testing/toxic/chat.c
diff options
context:
space:
mode:
Diffstat (limited to 'testing/toxic/chat.c')
-rw-r--r--testing/toxic/chat.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c
index da1f9f4a..7262e722 100644
--- a/testing/toxic/chat.c
+++ b/testing/toxic/chat.c
@@ -25,6 +25,8 @@ typedef struct {
25 25
26} ChatContext; 26} ChatContext;
27 27
28extern int w_active;
29extern void del_window(ToxWindow *w, int f_num);
28extern void fix_name(uint8_t* name); 30extern void fix_name(uint8_t* name);
29void print_help(ChatContext* self); 31void print_help(ChatContext* self);
30void execute(ToxWindow* self, ChatContext* ctx, char* cmd); 32void 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)
50 fix_name(nick); 52 fix_name(nick);
51 53
52 wattron(ctx->history, COLOR_PAIR(2)); 54 wattron(ctx->history, COLOR_PAIR(2));
53 wprintw(ctx->history, "%02d:%02d:%02d ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec); 55 wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
54 wattroff(ctx->history, COLOR_PAIR(2)); 56 wattroff(ctx->history, COLOR_PAIR(2));
55 wattron(ctx->history, COLOR_PAIR(4)); 57 wattron(ctx->history, COLOR_PAIR(4));
56 wprintw(ctx->history, "%s: ", nick); 58 wprintw(ctx->history, "%s: ", nick);
@@ -118,7 +120,7 @@ static void chat_onKey(ToxWindow* self, int key) {
118 if(!string_is_empty(ctx->line)) { 120 if(!string_is_empty(ctx->line)) {
119 /* make sure the string has at least non-space character */ 121 /* make sure the string has at least non-space character */
120 wattron(ctx->history, COLOR_PAIR(2)); 122 wattron(ctx->history, COLOR_PAIR(2));
121 wprintw(ctx->history, "%02d:%02d:%02d ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec); 123 wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
122 wattroff(ctx->history, COLOR_PAIR(2)); 124 wattroff(ctx->history, COLOR_PAIR(2));
123 wattron(ctx->history, COLOR_PAIR(1)); 125 wattron(ctx->history, COLOR_PAIR(1));
124 wprintw(ctx->history, "you: ", ctx->line); 126 wprintw(ctx->history, "you: ", ctx->line);
@@ -187,6 +189,12 @@ void execute(ToxWindow* self, ChatContext* ctx, char* cmd)
187 } 189 }
188 wprintw(ctx->history, "Your ID: %s\n", id); 190 wprintw(ctx->history, "Your ID: %s\n", id);
189 } 191 }
192 else if (strcmp(ctx->line, "/close") == 0) {
193 w_active = 0; // Go to prompt screen
194 int f_num = ctx->friendnum;
195 delwin(ctx->linewin);
196 del_window(self, f_num);
197 }
190 else 198 else
191 wprintw(ctx->history, "Invalid command.\n"); 199 wprintw(ctx->history, "Invalid command.\n");
192} 200}
@@ -219,17 +227,19 @@ static void chat_onInit(ToxWindow* self) {
219 scrollok(ctx->history, 1); 227 scrollok(ctx->history, 1);
220 228
221 ctx->linewin = subwin(self->window, 2, x, y - 3, 0); 229 ctx->linewin = subwin(self->window, 2, x, y - 3, 0);
230 print_help(ctx);
222} 231}
223 232
224void print_help(ChatContext* self) { 233void print_help(ChatContext* self) {
225 wattron(self->history, COLOR_PAIR(2) | A_BOLD); 234 wattron(self->history, COLOR_PAIR(2) | A_BOLD);
226 wprintw(self->history, "\nCommands:\n"); 235 wprintw(self->history, "Commands:\n");
227 wattroff(self->history, A_BOLD); 236 wattroff(self->history, A_BOLD);
228 237
229 wprintw(self->history, " /status <message> : Set your status\n"); 238 wprintw(self->history, " /status <message> : Set your status\n");
230 wprintw(self->history, " /nick <nickname> : Set your nickname\n"); 239 wprintw(self->history, " /nick <nickname> : Set your nickname\n");
231 wprintw(self->history, " /myid : Print your ID\n"); 240 wprintw(self->history, " /myid : Print your ID\n");
232 wprintw(self->history, " /clear : Clear the screen\n"); 241 wprintw(self->history, " /clear : Clear the screen\n");
242 wprintw(self->history, " /close : Close the current chat window\n");
233 wprintw(self->history, " /quit or /exit : Exit program\n"); 243 wprintw(self->history, " /quit or /exit : Exit program\n");
234 wprintw(self->history, " /help : Print this message again\n\n"); 244 wprintw(self->history, " /help : Print this message again\n\n");
235 245