Mercurial > hg
comparison mcabber/screen.c @ 3:582ef676a320
[/trunk] Changeset 18 by mikael
Work on display:
* Don't show incoming message when it doesn't match the current Window
* Leave cursor in input window
* Do not send ">>> " in outgoing messages!
* Make some variables static
author | mikael |
---|---|
date | Fri, 18 Mar 2005 22:07:31 +0000 |
parents | 63acb2dcaeea |
children | eb31418b48df |
comparison
equal
deleted
inserted
replaced
2:63acb2dcaeea | 3:582ef676a320 |
---|---|
28 } window_entry_t; | 28 } window_entry_t; |
29 | 29 |
30 LIST_HEAD(window_list); | 30 LIST_HEAD(window_list); |
31 | 31 |
32 /* Variables globales a SCREEN.C */ | 32 /* Variables globales a SCREEN.C */ |
33 WINDOW *rosterWnd, *chatWnd, *inputWnd; | 33 static WINDOW *rosterWnd, *chatWnd, *inputWnd; |
34 WINDOW *logWnd, *logWnd_border; | 34 static WINDOW *logWnd, *logWnd_border; |
35 PANEL *rosterPanel, *chatPanel, *inputPanel; | 35 static PANEL *rosterPanel, *chatPanel, *inputPanel; |
36 static PANEL *logPanel, *logPanel_border; | 36 static PANEL *logPanel, *logPanel_border; |
37 int maxY, maxX; | 37 static int maxY, maxX; |
38 window_entry_t *ventanaActual; | 38 static window_entry_t *currentWindow; |
39 | 39 |
40 char inputLine[INPUTLINE_LENGTH]; | 40 char inputLine[INPUTLINE_LENGTH]; |
41 char *ptr_inputline; | 41 char *ptr_inputline; |
42 | 42 |
43 | 43 |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
160 | 160 |
161 window_entry_t *scr_CreatePanel(char *title, int x, int y, int lines, | 161 window_entry_t *scr_CreatePanel(char *title, int x, int y, int lines, |
162 int cols) | 162 int cols, int dont_show) |
163 { | 163 { |
164 window_entry_t *tmp = calloc(1, sizeof(window_entry_t)); | 164 window_entry_t *tmp = calloc(1, sizeof(window_entry_t)); |
165 | 165 |
166 tmp->win = newwin(lines, cols, y, x); | 166 tmp->win = newwin(lines, cols, y, x); |
167 tmp->panel = new_panel(tmp->win); | 167 tmp->panel = new_panel(tmp->win); |
168 tmp->name = (char *) calloc(1, 1024); | 168 tmp->name = (char *) calloc(1, 1024); |
169 strncpy(tmp->name, title, 1024); | 169 strncpy(tmp->name, title, 1024); |
170 /* | |
171 if (!dont_show) { | |
172 currentWindow = tmp; | |
173 scr_draw_box(tmp->win, 0, 0, lines, cols, COLOR_GENERAL, 0, 0); | |
174 mvwprintw(tmp->win, 0, (cols - (2 + strlen(title))) / 2, " %s ", title); | |
175 } | |
176 */ | |
177 // *** | |
170 scr_draw_box(tmp->win, 0, 0, lines, cols, COLOR_GENERAL, 0, 0); | 178 scr_draw_box(tmp->win, 0, 0, lines, cols, COLOR_GENERAL, 0, 0); |
171 mvwprintw(tmp->win, 0, (cols - (2 + strlen(title))) / 2, " %s ", title); | 179 mvwprintw(tmp->win, 0, (cols - (2 + strlen(title))) / 2, " %s ", title); |
172 | 180 if (!dont_show) { |
181 currentWindow = tmp; | |
182 } else { | |
183 top_panel(currentWindow->panel); | |
184 } | |
185 // *** | |
173 list_add_tail(&tmp->list, &window_list); | 186 list_add_tail(&tmp->list, &window_list); |
174 update_panels(); | 187 update_panels(); |
175 | 188 |
176 return tmp; | 189 return tmp; |
177 } | 190 } |
308 | 321 |
309 void scr_RoolWindow(void) | 322 void scr_RoolWindow(void) |
310 { | 323 { |
311 } | 324 } |
312 | 325 |
313 window_entry_t *scr_SearchWindow(char *nombreVentana) | 326 window_entry_t *scr_SearchWindow(char *winId) |
314 { | 327 { |
315 struct list_head *pos, *n; | 328 struct list_head *pos, *n; |
316 window_entry_t *search_entry = NULL; | 329 window_entry_t *search_entry = NULL; |
317 | 330 |
318 list_for_each_safe(pos, n, &window_list) { | 331 list_for_each_safe(pos, n, &window_list) { |
319 search_entry = window_entry(pos); | 332 search_entry = window_entry(pos); |
320 if (search_entry->name) { | 333 if (search_entry->name) { |
321 if (!strcasecmp(search_entry->name, nombreVentana)) { | 334 if (!strcasecmp(search_entry->name, winId)) { |
322 return search_entry; | 335 return search_entry; |
323 } | 336 } |
324 } | 337 } |
325 } | 338 } |
326 return NULL; | 339 return NULL; |
327 } | 340 } |
328 | 341 |
329 void scr_ShowWindow(char *nombreVentana) | 342 void scr_ShowWindow(char *winId) |
330 { | 343 { |
331 int n, width, i; | 344 int n, width, i; |
332 window_entry_t *tmp = scr_SearchWindow(nombreVentana); | 345 window_entry_t *tmp = scr_SearchWindow(winId); |
333 if (tmp != NULL) { | 346 if (tmp != NULL) { |
334 top_panel(tmp->panel); | 347 top_panel(tmp->panel); |
348 currentWindow = tmp; | |
335 width = scr_WindowHeight(tmp->win); | 349 width = scr_WindowHeight(tmp->win); |
336 for (n = 0; n < tmp->nlines; n++) { | 350 for (n = 0; n < tmp->nlines; n++) { |
337 mvwprintw(tmp->win, n + 1, 1, ""); | 351 mvwprintw(tmp->win, n + 1, 1, ""); |
338 for (i = 0; i < width - 2; i++) | 352 for (i = 0; i < width - 2; i++) |
339 waddch(tmp->win, ' '); | 353 waddch(tmp->win, ' '); |
351 if (tmp->jid != NULL) | 365 if (tmp->jid != NULL) |
352 scr_ShowWindow(tmp->jid); | 366 scr_ShowWindow(tmp->jid); |
353 } | 367 } |
354 | 368 |
355 | 369 |
356 void scr_WriteInWindow(char *nombreVentana, char *texto, int TimeStamp) | 370 void scr_WriteInWindow(char *winId, char *texto, int TimeStamp) |
357 { | 371 { |
358 time_t ahora; | 372 time_t ahora; |
359 int n; | 373 int n; |
360 int i; | 374 int i; |
361 int width; | 375 int width; |
362 window_entry_t *tmp; | 376 window_entry_t *tmp; |
363 | 377 int dont_show = 0; |
364 tmp = scr_SearchWindow(nombreVentana); | 378 |
379 | |
380 tmp = scr_SearchWindow(winId); | |
381 | |
382 if ((currentWindow) && (currentWindow != tmp)) | |
383 dont_show = 1; | |
384 | |
365 if (tmp == NULL) { | 385 if (tmp == NULL) { |
366 tmp = scr_CreatePanel(nombreVentana, 20, 0, CHAT_WIN_HEIGHT, maxX - 20); | 386 tmp = scr_CreatePanel(winId, 20, 0, CHAT_WIN_HEIGHT, maxX - 20, dont_show); |
367 tmp->texto = (char **) calloc((CHAT_WIN_HEIGHT+1) * 3, sizeof(char *)); | 387 tmp->texto = (char **) calloc((CHAT_WIN_HEIGHT+1) * 3, sizeof(char *)); |
368 for (n = 0; n < CHAT_WIN_HEIGHT * 3; n++) | 388 for (n = 0; n < CHAT_WIN_HEIGHT * 3; n++) |
369 tmp->texto[n] = (char *) calloc(1, 1024); | 389 tmp->texto[n] = (char *) calloc(1, 1024); |
370 | 390 |
371 if (TimeStamp) { | 391 if (TimeStamp) { |
402 sprintf(tmp->texto[tmp->nlines - 1], " %s", texto); | 422 sprintf(tmp->texto[tmp->nlines - 1], " %s", texto); |
403 } | 423 } |
404 } | 424 } |
405 } | 425 } |
406 | 426 |
407 top_panel(tmp->panel); | 427 if (!dont_show) { |
408 width = scr_WindowHeight(tmp->win); | 428 top_panel(tmp->panel); |
409 for (n = 0; n < tmp->nlines; n++) { | 429 width = scr_WindowHeight(tmp->win); |
410 mvwprintw(tmp->win, n + 1, 1, ""); | 430 for (n = 0; n < tmp->nlines; n++) { |
411 for (i = 0; i < width - 2; i++) | 431 mvwprintw(tmp->win, n + 1, 1, ""); |
412 waddch(tmp->win, ' '); | 432 for (i = 0; i < width - 2; i++) |
413 mvwprintw(tmp->win, n + 1, 1, "%s", tmp->texto[n]); | 433 waddch(tmp->win, ' '); |
414 } | 434 mvwprintw(tmp->win, n + 1, 1, "%s", tmp->texto[n]); |
415 | 435 } |
416 update_panels(); | 436 |
417 doupdate(); | 437 update_panels(); |
438 doupdate(); | |
439 } | |
418 } | 440 } |
419 | 441 |
420 void scr_InitCurses(void) | 442 void scr_InitCurses(void) |
421 { | 443 { |
422 initscr(); | 444 initscr(); |
607 | 629 |
608 //move(CHAT_WIN_HEIGHT - 1, maxX - 1); | 630 //move(CHAT_WIN_HEIGHT - 1, maxX - 1); |
609 refresh(); | 631 refresh(); |
610 sprintf(buffer2, "%s@%s/%s", cfg_read("username"), | 632 sprintf(buffer2, "%s@%s/%s", cfg_read("username"), |
611 cfg_read("server"), cfg_read("resource")); | 633 cfg_read("server"), cfg_read("resource")); |
612 srv_sendtext(sock, tmp->jid, buffer, buffer2); | 634 srv_sendtext(sock, tmp->jid, msg, buffer2); |
613 free(buffer); | 635 free(buffer); |
614 free(buffer2); | 636 free(buffer2); |
615 | 637 |
616 top_panel(inputPanel); | 638 top_panel(inputPanel); |
617 } | 639 } |