diff options
author | plutooo <tfy12vbr@student.lu.se> | 2013-07-31 11:20:16 -0700 |
---|---|---|
committer | plutooo <tfy12vbr@student.lu.se> | 2013-07-31 11:20:16 -0700 |
commit | 0815d1110d452f174bc523c11291b8da41e01d4a (patch) | |
tree | 4a177316087771d4fff0257a9fa5b14fa51b9db3 /testing/toxic/chat.c | |
parent | 2247b7fad552d75eb0e0f4407970aa76f64b8942 (diff) |
toxic: Made everything 1000x more userfriendly.
Diffstat (limited to 'testing/toxic/chat.c')
-rw-r--r-- | testing/toxic/chat.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c index 53cf3319..da9ad025 100644 --- a/testing/toxic/chat.c +++ b/testing/toxic/chat.c | |||
@@ -1,3 +1,7 @@ | |||
1 | /* | ||
2 | * Toxic -- Tox Curses Client | ||
3 | */ | ||
4 | |||
1 | #include <curses.h> | 5 | #include <curses.h> |
2 | #include <stdlib.h> | 6 | #include <stdlib.h> |
3 | #include <string.h> | 7 | #include <string.h> |
@@ -38,7 +42,13 @@ static void chat_onMessage(ToxWindow* self, int num, uint8_t* msg, uint16_t len) | |||
38 | fix_name(msg); | 42 | fix_name(msg); |
39 | fix_name(nick); | 43 | fix_name(nick); |
40 | 44 | ||
41 | wprintw(ctx->history, "%s: %s\n", nick, msg); | 45 | wattron(ctx->history, COLOR_PAIR(4)); |
46 | wprintw(ctx->history, "%s: ", nick); | ||
47 | wattroff(ctx->history, COLOR_PAIR(4)); | ||
48 | |||
49 | wprintw(ctx->history, "%s\n", msg); | ||
50 | |||
51 | self->blink = true; | ||
42 | } | 52 | } |
43 | 53 | ||
44 | static void chat_onNickChange(ToxWindow* self, int num, uint8_t* nick, uint16_t len) { | 54 | static void chat_onNickChange(ToxWindow* self, int num, uint8_t* nick, uint16_t len) { |
@@ -70,15 +80,27 @@ static void chat_onKey(ToxWindow* self, int key) { | |||
70 | } | 80 | } |
71 | } | 81 | } |
72 | else if(key == '\n') { | 82 | else if(key == '\n') { |
73 | wprintw(ctx->history, "you: %s\n", ctx->line); | 83 | wattron(ctx->history, COLOR_PAIR(1)); |
84 | wprintw(ctx->history, "you: ", ctx->line); | ||
85 | wattroff(ctx->history, COLOR_PAIR(1)); | ||
86 | |||
87 | wprintw(ctx->history, "%s\n", ctx->line); | ||
74 | 88 | ||
75 | if(m_sendmessage(ctx->friendnum, (uint8_t*) ctx->line, strlen(ctx->line)+1) < 0) { | 89 | if(m_sendmessage(ctx->friendnum, (uint8_t*) ctx->line, strlen(ctx->line)+1) < 0) { |
90 | wattron(ctx->history, COLOR_PAIR(3)); | ||
76 | wprintw(ctx->history, " * Failed to send message.\n"); | 91 | wprintw(ctx->history, " * Failed to send message.\n"); |
92 | wattroff(ctx->history, COLOR_PAIR(3)); | ||
77 | } | 93 | } |
78 | 94 | ||
79 | ctx->line[0] = '\0'; | 95 | ctx->line[0] = '\0'; |
80 | ctx->pos = 0; | 96 | ctx->pos = 0; |
81 | } | 97 | } |
98 | else if(key == 0x107) { | ||
99 | if(ctx->pos != 0) { | ||
100 | ctx->line[--ctx->pos] = '\0'; | ||
101 | } | ||
102 | } | ||
103 | |||
82 | } | 104 | } |
83 | 105 | ||
84 | static void chat_onDraw(ToxWindow* self) { | 106 | static void chat_onDraw(ToxWindow* self) { |
@@ -105,7 +127,6 @@ static void chat_onInit(ToxWindow* self) { | |||
105 | getmaxyx(self->window, y, x); | 127 | getmaxyx(self->window, y, x); |
106 | 128 | ||
107 | ctx->history = subwin(self->window, y - 4, x, 0, 0); | 129 | ctx->history = subwin(self->window, y - 4, x, 0, 0); |
108 | wprintw(ctx->history, "Here goes chat\n"); | ||
109 | scrollok(ctx->history, 1); | 130 | scrollok(ctx->history, 1); |
110 | 131 | ||
111 | ctx->linewin = subwin(self->window, 2, x, y - 3, 0); | 132 | ctx->linewin = subwin(self->window, 2, x, y - 3, 0); |