summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorSean Qureshi <stqism@risingstormgames.com>2013-08-03 11:45:07 -0700
committerSean Qureshi <stqism@risingstormgames.com>2013-08-03 11:45:07 -0700
commit6209d103f46758c0501eeaa00dcf66cd8ed8236c (patch)
tree4e2508c6446d0f4b08fd500ba3225740ac9619ca /testing
parente4d63c63c7ee02f144e7f061cbe3e5f631ad95d8 (diff)
parent5c136b116dda312fca5cc17d4028513e244551c3 (diff)
Merge branch 'master' of https://github.com/stqism/ProjectTox-Core
Diffstat (limited to 'testing')
-rw-r--r--testing/toxic/chat.c34
1 files changed, 4 insertions, 30 deletions
diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c
index 19f5c972..7cae1c0a 100644
--- a/testing/toxic/chat.c
+++ b/testing/toxic/chat.c
@@ -47,21 +47,8 @@ static void chat_onMessage(ToxWindow* self, int num, uint8_t* msg, uint16_t len)
47 fix_name(msg); 47 fix_name(msg);
48 fix_name(nick); 48 fix_name(nick);
49 49
50 int inthour = timeinfo->tm_hour;
51 int intmin = timeinfo->tm_min;
52 char min[2];
53 char hour[2];
54 sprintf(hour,"%d",inthour);
55 if (intmin < 10) {
56 sprintf(min,"0%d",intmin);
57 } else {
58 sprintf(min,"%d",intmin);
59 }
60
61
62 wattron(ctx->history, COLOR_PAIR(2)); 50 wattron(ctx->history, COLOR_PAIR(2));
63 wprintw(ctx->history,"%s",hour); 51 wprintw(ctx->history, "%02d:%02d:%02d ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
64 wprintw(ctx->history,":%s ",min);
65 wattron(ctx->history, COLOR_PAIR(4)); 52 wattron(ctx->history, COLOR_PAIR(4));
66 wprintw(ctx->history, "%s: ", nick); 53 wprintw(ctx->history, "%s: ", nick);
67 wattroff(ctx->history, COLOR_PAIR(4)); 54 wattroff(ctx->history, COLOR_PAIR(4));
@@ -106,24 +93,11 @@ static void chat_onKey(ToxWindow* self, int key) {
106 } 93 }
107 } 94 }
108 else if(key == '\n') { 95 else if(key == '\n') {
109
110 int inthour = timeinfo->tm_hour; //Pretty bad, but it gets the job done
111 int intmin = timeinfo->tm_min;
112 char min[2];
113 char hour[2];
114 sprintf(hour,"%d",inthour);
115 if (intmin < 10) {
116 sprintf(min,"0%d",intmin);
117 } else {
118 sprintf(min,"%d",intmin);
119 }
120 wattron(ctx->history, COLOR_PAIR(2)); 96 wattron(ctx->history, COLOR_PAIR(2));
121 wprintw(ctx->history,"%s",hour); 97 wprintw(ctx->history, "%02d:%02d:%02d ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
122 wprintw(ctx->history,":%s ",min);
123 wattron(ctx->history, COLOR_PAIR(1)); 98 wattron(ctx->history, COLOR_PAIR(1));
124 wprintw(ctx->history, "you: ", ctx->line); 99 wprintw(ctx->history, "you: ", ctx->line);
125 wattroff(ctx->history, COLOR_PAIR(1)); 100 wattroff(ctx->history, COLOR_PAIR(1));
126
127 wprintw(ctx->history, "%s\n", ctx->line); 101 wprintw(ctx->history, "%s\n", ctx->line);
128 102
129 if(m_sendmessage(ctx->friendnum, (uint8_t*) ctx->line, strlen(ctx->line)+1) < 0) { 103 if(m_sendmessage(ctx->friendnum, (uint8_t*) ctx->line, strlen(ctx->line)+1) < 0) {
@@ -140,7 +114,7 @@ static void chat_onKey(ToxWindow* self, int key) {
140 ctx->line[--ctx->pos] = '\0'; 114 ctx->line[--ctx->pos] = '\0';
141 } 115 }
142 } 116 }
143 117
144} 118}
145 119
146static void chat_onDraw(ToxWindow* self) { 120static void chat_onDraw(ToxWindow* self) {
@@ -188,7 +162,7 @@ ToxWindow new_chat(int friendnum) {
188 uint8_t nick[MAX_NAME_LENGTH] = {0}; 162 uint8_t nick[MAX_NAME_LENGTH] = {0};
189 getname(friendnum, (uint8_t*) &nick); 163 getname(friendnum, (uint8_t*) &nick);
190 fix_name(nick); 164 fix_name(nick);
191 165
192 snprintf(ret.title, sizeof(ret.title), "[%s (%d)]", nick, friendnum); 166 snprintf(ret.title, sizeof(ret.title), "[%s (%d)]", nick, friendnum);
193 167
194 ChatContext* x = calloc(1, sizeof(ChatContext)); 168 ChatContext* x = calloc(1, sizeof(ChatContext));