Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/screen.c @ 1298:af035a304bec
colorable muc nick fix
When ctrl+l is pressed, no error message is printed
Added command to recolor someone
author | Michal 'vorner' Vaner <vorner@ucw.cz> |
---|---|
date | Tue, 28 Aug 2007 18:56:50 +0200 |
parents | 7a0eaa53bd53 |
children | 0dda8238af21 |
comparison
equal
deleted
inserted
replaced
1297:60663a1f9e8d | 1298:af035a304bec |
---|---|
311 nc->manual = false; | 311 nc->manual = false; |
312 nc = g_hash_table_lookup(nickcolors, mnick); | 312 nc = g_hash_table_lookup(nickcolors, mnick); |
313 assert(nc);//Must have both at the same time | 313 assert(nc);//Must have both at the same time |
314 nc->manual = false; | 314 nc->manual = false; |
315 }// Else -> no color saved, nothing to delete | 315 }// Else -> no color saved, nothing to delete |
316 } | |
317 g_free(snick);//They are not saved in the hash | |
318 g_free(mnick); | |
319 need_update = true; | |
320 } else if (!strcmp(color, "!")) { | |
321 if (nickcolors) { | |
322 g_free(g_hash_table_lookup(nickcolors, snick)); | |
323 g_hash_table_remove(nickcolors, snick); | |
324 g_hash_table_remove(nickcolors, mnick); | |
316 } | 325 } |
317 g_free(snick);//They are not saved in the hash | 326 g_free(snick);//They are not saved in the hash |
318 g_free(mnick); | 327 g_free(mnick); |
319 need_update = true; | 328 need_update = true; |
320 } else { | 329 } else { |
505 for (i = COLOR_BLACK_FG; i < COLOR_max; i++) { | 514 for (i = COLOR_BLACK_FG; i < COLOR_max; i++) { |
506 init_pair(i, color_fg_to_color(i), FindColor(background)); | 515 init_pair(i, color_fg_to_color(i), FindColor(background)); |
507 if (i >= COLOR_BLACK_BOLD_FG) | 516 if (i >= COLOR_BLACK_BOLD_FG) |
508 COLOR_ATTRIB[i] = A_BOLD; | 517 COLOR_ATTRIB[i] = A_BOLD; |
509 } | 518 } |
510 char *ncolors = g_strdup(settings_opt_get("nick_colors")), | 519 if (!nickcols) { |
511 *ncolor_start = ncolors; | 520 char *ncolors = g_strdup(settings_opt_get("nick_colors")), |
512 if (ncolors) { | 521 *ncolor_start = ncolors; |
513 while (*ncolors) { | 522 if (ncolors) { |
514 if ((*ncolors == ' ') || (*ncolors == '\t')) { | 523 while (*ncolors) { |
515 ncolors ++; | 524 if ((*ncolors == ' ') || (*ncolors == '\t')) { |
516 } else { | 525 ncolors ++; |
517 char *end = ncolors; | |
518 bool ended = false; | |
519 while (*end && (*end != ' ') && (*end != '\t')) | |
520 end++; | |
521 if (!end) | |
522 ended = true; | |
523 *end = '\0'; | |
524 int cl = get_user_color(ncolors); | |
525 if (cl < 0) { | |
526 scr_LogPrint(LPRINT_NORMAL, "Unknown color %s", ncolors); | |
527 } else { | 526 } else { |
528 nickcols = g_realloc(nickcols, (++nickcolcount) * sizeof *nickcols); | 527 char *end = ncolors; |
529 nickcols[nickcolcount-1] = cl; | 528 bool ended = false; |
529 while (*end && (*end != ' ') && (*end != '\t')) | |
530 end++; | |
531 if (!end) | |
532 ended = true; | |
533 *end = '\0'; | |
534 int cl = get_user_color(ncolors); | |
535 if (cl < 0) { | |
536 scr_LogPrint(LPRINT_NORMAL, "Unknown color %s", ncolors); | |
537 } else { | |
538 nickcols = g_realloc(nickcols, (++nickcolcount) * sizeof *nickcols); | |
539 nickcols[nickcolcount-1] = cl; | |
540 } | |
541 if (ended) | |
542 ncolors = NULL; | |
543 else | |
544 ncolors = end+1; | |
530 } | 545 } |
531 if (ended) | |
532 ncolors = NULL; | |
533 else | |
534 ncolors = end+1; | |
535 } | 546 } |
536 } | 547 g_free(ncolor_start); |
537 g_free(ncolor_start); | 548 } |
538 } | 549 if (!nickcols) {//Fallback to have something |
539 if (!nickcols) {//Fallback to have something | 550 nickcolcount = 1; |
540 nickcolcount = 1; | 551 nickcols = g_new(int, 1); |
541 nickcols = g_new(int, 1); | 552 *nickcols = COLOR_GENERAL; |
542 *nickcols = COLOR_GENERAL; | 553 } |
543 } | 554 } |
544 } | 555 } |
545 | 556 |
546 static void init_keycodes(void) | 557 static void init_keycodes(void) |
547 { | 558 { |