diff options
Diffstat (limited to 'testing/toxic')
-rw-r--r-- | testing/toxic/chat.c | 34 |
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 | ||
146 | static void chat_onDraw(ToxWindow* self) { | 120 | static 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)); |