comparison mcabber/src/screen.c @ 1291:9f64f548ac16

Better way of writing the nick
author Michal 'vorner' Vaner <vorner@ucw.cz>
date Sun, 26 Aug 2007 22:23:30 +0200
parents e42f48103609
children 382ec54b584e
comparison
equal deleted inserted replaced
1290:e42f48103609 1291:9f64f548ac16
811 int n; 811 int n;
812 int width; 812 int width;
813 hbb_line **lines, *line; 813 hbb_line **lines, *line;
814 GList *hbuf_head; 814 GList *hbuf_head;
815 char date[64]; 815 char date[64];
816 int color;
816 817
817 width = getmaxx(win_entry->win); 818 width = getmaxx(win_entry->win);
818 819
819 // Should the window be empty? 820 // Should the window be empty?
820 if (win_entry->bd->cleared) { 821 if (win_entry->bd->cleared) {
851 for (n = 0; n < CHAT_WIN_HEIGHT; n++) { 852 for (n = 0; n < CHAT_WIN_HEIGHT; n++) {
852 wmove(win_entry->win, n, 0); 853 wmove(win_entry->win, n, 0);
853 line = *(lines+n); 854 line = *(lines+n);
854 if (line) { 855 if (line) {
855 if (line->flags & HBB_PREFIX_HLIGHT_OUT) 856 if (line->flags & HBB_PREFIX_HLIGHT_OUT)
856 wattrset(win_entry->win, get_color(COLOR_MSGOUT)); 857 color = COLOR_MSGOUT;
857 else if (line->flags & HBB_PREFIX_HLIGHT) 858 else if (line->flags & HBB_PREFIX_HLIGHT)
858 wattrset(win_entry->win, get_color(COLOR_MSGHL)); 859 color = COLOR_MSGHL;
859 else if (line->flags & HBB_PREFIX_INFO) 860 else if (line->flags & HBB_PREFIX_INFO)
860 wattrset(win_entry->win, get_color(COLOR_INFO)); 861 color = COLOR_INFO;
861 else if (line->flags & HBB_PREFIX_IN) 862 else if (line->flags & HBB_PREFIX_IN)
862 wattrset(win_entry->win, get_color(COLOR_MSGIN)); 863 color = COLOR_MSGIN;
864 else
865 color = COLOR_GENERAL;
866
867 if (color != COLOR_GENERAL)
868 wattrset(win_entry->win, get_color(color));
863 869
864 if (line->timestamp && 870 if (line->timestamp &&
865 !(line->flags & (HBB_PREFIX_SPECIAL|HBB_PREFIX_CONT))) { 871 !(line->flags & (HBB_PREFIX_SPECIAL|HBB_PREFIX_CONT))) {
866 strftime(date, 30, gettprefix(), localtime(&line->timestamp)); 872 strftime(date, 30, gettprefix(), localtime(&line->timestamp));
867 } else 873 } else
897 wprintw(win_entry->win, " " ); 903 wprintw(win_entry->win, " " );
898 } 904 }
899 905
900 // Make sure we are at the right position 906 // Make sure we are at the right position
901 wmove(win_entry->win, n, getprefixwidth()-1); 907 wmove(win_entry->win, n, getprefixwidth()-1);
902 wprintw(win_entry->win, "%s", line->text); // Display text line
903 wclrtoeol(win_entry->win);
904 908
905 //The MUC nick - overwrite with propper color 909 //The MUC nick - overwrite with propper color
906 if (line->mucnicklen) { 910 if (line->mucnicklen && (line->flags & HBB_PREFIX_IN)) {
907 //Store the char after the nick 911 //Store the char after the nick
908 char tmp = line->text[line->mucnicklen]; 912 char tmp = line->text[line->mucnicklen];
909 //TODO choose the color in proper way 913 //TODO choose the color in proper way
910 wattrset(win_entry->win, get_color(COLOR_RED_BOLD_FG)); 914 wattrset(win_entry->win, get_color(COLOR_RED_BOLD_FG));
911 wmove(win_entry->win, n, getprefixwidth()-1);
912 //Terminate the string after the nick 915 //Terminate the string after the nick
913 line->text[line->mucnicklen] = '\0'; 916 line->text[line->mucnicklen] = '\0';
914 wprintw(win_entry->win, "%s", line->text); 917 wprintw(win_entry->win, "%s", line->text);
915 //Return the char 918 //Return the char
916 line->text[line->mucnicklen] = tmp; 919 line->text[line->mucnicklen] = tmp;
920 //Return the color back
921 wattrset(win_entry->win, get_color(color));
917 } 922 }
918 923
924 wprintw(win_entry->win, "%s", line->text+line->mucnicklen); // Display text line
925 wclrtoeol(win_entry->win);
926
919 // Return the color back 927 // Return the color back
920 if ((line->flags & (HBB_PREFIX_HLIGHT_OUT | HBB_PREFIX_HLIGHT 928 if (color != COLOR_GENERAL)
921 | HBB_PREFIX_INFO | HBB_PREFIX_IN)) || (line->mucnicklen))
922 wattrset(win_entry->win, get_color(COLOR_GENERAL)); 929 wattrset(win_entry->win, get_color(COLOR_GENERAL));
923 g_free(line->text); 930 g_free(line->text);
924 g_free(line); 931 g_free(line);
925 } else { 932 } else {
926 wclrtobot(win_entry->win); 933 wclrtobot(win_entry->win);