summaryrefslogtreecommitdiff
path: root/testing/toxic
diff options
context:
space:
mode:
Diffstat (limited to 'testing/toxic')
-rw-r--r--testing/toxic/chat.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c
index 72fa5d4b..846bcf21 100644
--- a/testing/toxic/chat.c
+++ b/testing/toxic/chat.c
@@ -94,6 +94,11 @@ int string_is_empty(char *string)
94static void chat_onKey(ToxWindow* self, int key) { 94static void chat_onKey(ToxWindow* self, int key) {
95 ChatContext* ctx = (ChatContext*) self->x; 95 ChatContext* ctx = (ChatContext*) self->x;
96 96
97 time_t now;
98 time(&now);
99 struct tm * timeinfo;
100 timeinfo = localtime(&now);
101
97 /* PRINTABLE characters: Add to line */ 102 /* PRINTABLE characters: Add to line */
98 if(isprint(key)) { 103 if(isprint(key)) {
99 if(ctx->pos != sizeof(ctx->line)-1) { 104 if(ctx->pos != sizeof(ctx->line)-1) {
@@ -107,11 +112,15 @@ static void chat_onKey(ToxWindow* self, int key) {
107 if (ctx->line[0] == '/') 112 if (ctx->line[0] == '/')
108 execute(self, ctx, ctx->line); 113 execute(self, ctx, ctx->line);
109 else { 114 else {
110 wattron(ctx->history, COLOR_PAIR(1)); 115 if(!string_is_empty(ctx->line)) {
111 wprintw(ctx->history, "you: ", ctx->line); 116 /* make sure the string has at least non-space character */
112 wattroff(ctx->history, COLOR_PAIR(1)); 117 wattron(ctx->history, COLOR_PAIR(2));
113 wprintw(ctx->history, "%s\n", ctx->line); 118 wprintw(ctx->history, "%02d:%02d:%02d ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
114 119 wattron(ctx->history, COLOR_PAIR(1));
120 wprintw(ctx->history, "you: ", ctx->line);
121 wattroff(ctx->history, COLOR_PAIR(1));
122 wprintw(ctx->history, "%s\n", ctx->line);
123 }
115 if(m_sendmessage(ctx->friendnum, (uint8_t*) ctx->line, strlen(ctx->line)+1) < 0) { 124 if(m_sendmessage(ctx->friendnum, (uint8_t*) ctx->line, strlen(ctx->line)+1) < 0) {
116 wattron(ctx->history, COLOR_PAIR(3)); 125 wattron(ctx->history, COLOR_PAIR(3));
117 wprintw(ctx->history, " * Failed to send message.\n"); 126 wprintw(ctx->history, " * Failed to send message.\n");