summaryrefslogtreecommitdiff
path: root/testing/toxic
diff options
context:
space:
mode:
Diffstat (limited to 'testing/toxic')
-rw-r--r--testing/toxic/chat.c2
-rw-r--r--testing/toxic/main.c4
-rw-r--r--testing/toxic/prompt.c2
-rw-r--r--testing/toxic/windows.c46
4 files changed, 30 insertions, 24 deletions
diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c
index d3e68ec6..c7979843 100644
--- a/testing/toxic/chat.c
+++ b/testing/toxic/chat.c
@@ -123,7 +123,7 @@ static void chat_onStatusChange(ToxWindow *self, int num, uint8_t *status, uint1
123 123
124 status[len - 1] = '\0'; 124 status[len - 1] = '\0';
125 fix_name(status); 125 fix_name(status);
126 126
127 wattron(ctx->history, COLOR_PAIR(3)); 127 wattron(ctx->history, COLOR_PAIR(3));
128 wprintw(ctx->history, "* Your partner changed status to '%s'\n", status); 128 wprintw(ctx->history, "* Your partner changed status to '%s'\n", status);
129 wattroff(ctx->history, COLOR_PAIR(3)); 129 wattroff(ctx->history, COLOR_PAIR(3));
diff --git a/testing/toxic/main.c b/testing/toxic/main.c
index 6f6c9db4..e5525e94 100644
--- a/testing/toxic/main.c
+++ b/testing/toxic/main.c
@@ -93,7 +93,7 @@ static Messenger *init_tox()
93int init_connection(Messenger *m) 93int init_connection(Messenger *m)
94{ 94{
95 FILE *fp = NULL; 95 FILE *fp = NULL;
96 96
97 if (DHT_isconnected(m->dht)) 97 if (DHT_isconnected(m->dht))
98 return 0; 98 return 0;
99 99
@@ -297,7 +297,7 @@ int main(int argc, char *argv[])
297 strcpy(DATA_FILE, user_config_dir); 297 strcpy(DATA_FILE, user_config_dir);
298 strcat(DATA_FILE, CONFIGDIR); 298 strcat(DATA_FILE, CONFIGDIR);
299 strcat(DATA_FILE, "data"); 299 strcat(DATA_FILE, "data");
300 300
301 SRVLIST_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("DHTservers") + 1); 301 SRVLIST_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("DHTservers") + 1);
302 strcpy(SRVLIST_FILE, user_config_dir); 302 strcpy(SRVLIST_FILE, user_config_dir);
303 strcat(SRVLIST_FILE, CONFIGDIR); 303 strcat(SRVLIST_FILE, CONFIGDIR);
diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c
index 12f8a201..e194a90e 100644
--- a/testing/toxic/prompt.c
+++ b/testing/toxic/prompt.c
@@ -365,7 +365,9 @@ static void execute(ToxWindow *self, Messenger *m, char *u_cmd)
365 cmd[i] = '\0'; 365 cmd[i] = '\0';
366 366
367 int j = i; 367 int j = i;
368
368 while (++j < MAX_STR_SIZE && isspace(cmd[j])); 369 while (++j < MAX_STR_SIZE && isspace(cmd[j]));
370
369 i = j - 1; 371 i = j - 1;
370 372
371 numargs++; 373 numargs++;
diff --git a/testing/toxic/windows.c b/testing/toxic/windows.c
index de924329..8fdf4e19 100644
--- a/testing/toxic/windows.c
+++ b/testing/toxic/windows.c
@@ -88,23 +88,25 @@ int add_window(Messenger *m, ToxWindow w)
88{ 88{
89 if (LINES < 2) 89 if (LINES < 2)
90 return -1; 90 return -1;
91 91
92 int i; 92 int i;
93 for(i = 0; i < MAX_WINDOWS_NUM; i++) { 93
94 if (windows[i].window) 94 for (i = 0; i < MAX_WINDOWS_NUM; i++) {
95 if (windows[i].window)
95 continue; 96 continue;
96 97
97 w.window = newwin(LINES - 2, COLS, 0, 0); 98 w.window = newwin(LINES - 2, COLS, 0, 0);
99
98 if (w.window == NULL) 100 if (w.window == NULL)
99 return -1; 101 return -1;
100 102
101 windows[i] = w; 103 windows[i] = w;
102 w.onInit(&w, m); 104 w.onInit(&w, m);
103 105
104 active_window = windows+i; 106 active_window = windows + i;
105 return i; 107 return i;
106 } 108 }
107 109
108 return -1; 110 return -1;
109} 111}
110 112
@@ -113,8 +115,10 @@ void del_window(ToxWindow *w)
113{ 115{
114 active_window = windows; // Go to prompt screen 116 active_window = windows; // Go to prompt screen
115 delwin(w->window); 117 delwin(w->window);
118
116 if (w->x) 119 if (w->x)
117 free(w->x); 120 free(w->x);
121
118 w->window = NULL; 122 w->window = NULL;
119 memset(w, 0, sizeof(ToxWindow)); 123 memset(w, 0, sizeof(ToxWindow));
120 clear(); 124 clear();
@@ -124,19 +128,19 @@ void del_window(ToxWindow *w)
124/* Shows next window when tab or back-tab is pressed */ 128/* Shows next window when tab or back-tab is pressed */
125void set_next_window(int ch) 129void set_next_window(int ch)
126{ 130{
127 ToxWindow *end = windows+MAX_WINDOWS_NUM-1; 131 ToxWindow *end = windows + MAX_WINDOWS_NUM - 1;
128 ToxWindow *inf = active_window; 132 ToxWindow *inf = active_window;
129 while(true) { 133
134 while (true) {
130 if (ch == '\t') { 135 if (ch == '\t') {
131 if (++active_window > end) 136 if (++active_window > end)
132 active_window = windows; 137 active_window = windows;
133 } else 138 } else if (--active_window < windows)
134 if (--active_window < windows) 139 active_window = end;
135 active_window = end; 140
136
137 if (active_window->window) 141 if (active_window->window)
138 return; 142 return;
139 143
140 if (active_window == inf) { // infinite loop check 144 if (active_window == inf) { // infinite loop check
141 endwin(); 145 endwin();
142 exit(2); 146 exit(2);
@@ -148,14 +152,14 @@ void set_active_window(int index)
148{ 152{
149 if (index < 0 || index >= MAX_WINDOWS_NUM) 153 if (index < 0 || index >= MAX_WINDOWS_NUM)
150 return; 154 return;
151 155
152 active_window = windows+index; 156 active_window = windows + index;
153} 157}
154 158
155ToxWindow *init_windows() 159ToxWindow *init_windows()
156{ 160{
157 int n_prompt = add_window(m, new_prompt()); 161 int n_prompt = add_window(m, new_prompt());
158 162
159 if (n_prompt == -1 163 if (n_prompt == -1
160 || add_window(m, new_friendlist()) == -1 164 || add_window(m, new_friendlist()) == -1
161 || add_window(m, new_dhtstatus()) == -1) { 165 || add_window(m, new_dhtstatus()) == -1) {
@@ -166,7 +170,7 @@ ToxWindow *init_windows()
166 170
167 prompt = &windows[n_prompt]; 171 prompt = &windows[n_prompt];
168 active_window = prompt; 172 active_window = prompt;
169 173
170 return prompt; 174 return prompt;
171} 175}
172 176
@@ -189,7 +193,7 @@ static void draw_bar()
189 193
190 for (i = 0; i < (MAX_WINDOWS_NUM); ++i) { 194 for (i = 0; i < (MAX_WINDOWS_NUM); ++i) {
191 if (windows[i].window) { 195 if (windows[i].window) {
192 if (windows+i == active_window) 196 if (windows + i == active_window)
193 attron(A_BOLD); 197 attron(A_BOLD);
194 198
195 odd = (odd + 1) % blinkrate; 199 odd = (odd + 1) % blinkrate;
@@ -197,13 +201,13 @@ static void draw_bar()
197 if (windows[i].blink && (odd < (blinkrate / 2))) 201 if (windows[i].blink && (odd < (blinkrate / 2)))
198 attron(COLOR_PAIR(3)); 202 attron(COLOR_PAIR(3));
199 203
200 clrtoeol(); 204 clrtoeol();
201 printw(" %s", windows[i].title); 205 printw(" %s", windows[i].title);
202 206
203 if (windows[i].blink && (odd < (blinkrate / 2))) 207 if (windows[i].blink && (odd < (blinkrate / 2)))
204 attroff(COLOR_PAIR(3)); 208 attroff(COLOR_PAIR(3));
205 209
206 if (windows+i == active_window) { 210 if (windows + i == active_window) {
207 attroff(A_BOLD); 211 attroff(A_BOLD);
208 } 212 }
209 } 213 }