soc.2008.finch: ad64c39d: Added MISSPELL colors.

queueram at soc.pidgin.im queueram at soc.pidgin.im
Mon Jun 2 02:00:45 EDT 2008


-----------------------------------------------------------------
Revision: ad64c39d6dbc5c885a5d853ceb9c37c8433da09b
Ancestor: 745db5c00232365a89035a1968bfaaa0b89f66fe
Author: queueram at soc.pidgin.im
Date: 2008-06-02T05:54:37
Branch: im.pidgin.soc.2008.finch
URL: http://d.pidgin.im/viewmtn/revision/info/ad64c39d6dbc5c885a5d853ceb9c37c8433da09b

Modified files:
        doc/finch.1.in finch/libgnt/gntcolors.c
        finch/libgnt/gntcolors.h finch/libgnt/gntentry.c

ChangeLog: 

Added MISSPELL colors.

-------------- next part --------------
============================================================
--- doc/finch.1.in	b12643c7d316235a1993f35bb6f1abd861b0bfde
+++ doc/finch.1.in	19f529b244243c522185f2a4465907a409d8b811
@@ -257,6 +257,10 @@ urgent = green; black
 .br
 urgent = green; black
 .br
+misspell = red; blue
+.br
+misspelld = red; black
+.br
 
 .br
 # Remap some keys for GntEntry
============================================================
--- finch/libgnt/gntcolors.c	8829628b201259705884de48ead1eddad1a09a8d
+++ finch/libgnt/gntcolors.c	ed10e046a83fdbdbd012a14526470a99f1b19e22
@@ -106,6 +106,8 @@ void gnt_init_colors()
 		init_pair(GNT_COLOR_HIGHLIGHT_D, GNT_COLOR_BLACK, GNT_COLOR_GRAY);
 		init_pair(GNT_COLOR_DISABLED, GNT_COLOR_GRAY, GNT_COLOR_WHITE);
 		init_pair(GNT_COLOR_URGENT, GNT_COLOR_WHITE, GNT_COLOR_RED);
+		init_pair(GNT_COLOR_MISSPELL, GNT_COLOR_WHITE, GNT_COLOR_RED);
+		init_pair(GNT_COLOR_MISSPELL_D, COLOR_RED, GNT_COLOR_GRAY);
 	}
 	else
 	{
@@ -127,6 +129,8 @@ void gnt_init_colors()
 		init_pair(GNT_COLOR_TITLE_D, COLOR_WHITE, COLOR_BLACK);
 		init_pair(GNT_COLOR_TEXT_NORMAL, COLOR_WHITE, COLOR_BLUE);
 		init_pair(GNT_COLOR_HIGHLIGHT_D, COLOR_CYAN, COLOR_BLACK);
+		init_pair(GNT_COLOR_MISSPELL, COLOR_RED, COLOR_BLUE);
+		init_pair(GNT_COLOR_MISSPELL_D, COLOR_RED, COLOR_BLACK);
 	}
 }
 
@@ -269,6 +273,10 @@ void gnt_color_pairs_parse(GKeyFile *kfi
 				type = GNT_COLOR_DISABLED;
 			else if (strcmp(key, "urgent") == 0)
 				type = GNT_COLOR_URGENT;
+			else if (strcmp(key, "misspell") == 0)
+				type = GNT_COLOR_MISSPELL;
+			else if (strcmp(key, "misspelld") == 0)
+				type = GNT_COLOR_MISSPELL_D;
 			else {
 				g_free(key);
 				continue;
============================================================
--- finch/libgnt/gntcolors.h	d1bb00c5ac473a505f1ddfd0b24de0c36c555785
+++ finch/libgnt/gntcolors.h	85c4d48cb1aad5fb7bb13008a5756141e5d2ee6d
@@ -46,6 +46,8 @@ typedef enum
 	GNT_COLOR_TITLE,
 	GNT_COLOR_TITLE_D,
 	GNT_COLOR_URGENT,       /* this is for the 'urgent' windows */
+	GNT_COLOR_MISSPELL,     /* misspelled words, in focus */
+	GNT_COLOR_MISSPELL_D,   /* misspelled words, not in focus */
 	GNT_COLORS
 } GntColorType;
 
============================================================
--- finch/libgnt/gntentry.c	ba22a2b00b359d5f5112b97db5d68ab0f4d8fc09
+++ finch/libgnt/gntentry.c	409b2a8083832ceabed8382936fed2a3098ba182
@@ -381,6 +381,8 @@ gnt_entry_draw(GntWidget *widget)
 		 * out here so the spellchecking isn't always performed for each word on
 		 * a gnt_entry_draw */
 		char *s, *e;
+		int miss = gnt_color_pair(GNT_COLOR_MISSPELL);
+		int missd = gnt_color_pair(GNT_COLOR_MISSPELL_D);
 		/* only spell check if enabled and box isn't empty */
 		if(entry->spell->enable && (entry->start != entry->end)) {
 			wmove(widget->window, 0, 0);
@@ -398,9 +400,9 @@ gnt_entry_draw(GntWidget *widget)
 
 			/* TODO: pick better attribute for misspelled words */
 			if(!check_word(entry, s, e)) {
-				wattron(widget->window, A_REVERSE);
+				wattron(widget->window, (focus ? miss : missd));
 			} else {
-				wattroff(widget->window, A_REVERSE);
+				wattroff(widget->window, (focus ? miss : missd));
 			}
 			/* first word might be special case if scroll is in middle of word */
 			if(s < entry->scroll) {
@@ -412,7 +414,7 @@ gnt_entry_draw(GntWidget *widget)
 			s = g_utf8_find_next_char(e, entry->end);
 			while(s) {
 				/* print the whitespace and punctuation characters */
-				wattroff(widget->window, A_REVERSE);
+				wattroff(widget->window, (focus ? miss : missd));
 				e = get_beginning_of_next_word(s, entry->end);
 				if(!e && s < entry->end) {
 					/* the end is all non-letter characters */
@@ -426,9 +428,9 @@ gnt_entry_draw(GntWidget *widget)
 
 					/* TODO: pick better attribute for misspelled words */
 					if(!check_word(entry, s, e)) {
-						wattron(widget->window, A_REVERSE);
+						wattron(widget->window, (focus ? miss : missd));
 					} else {
-						wattroff(widget->window, A_REVERSE);
+						wattroff(widget->window, (focus ? miss : missd));
 					}
 					waddnstr(widget->window, s, e - s + 1);
 					s = g_utf8_find_next_char(e, entry->end);
@@ -437,14 +439,14 @@ gnt_entry_draw(GntWidget *widget)
 				}
 			}
 		} else {
+			wattroff(widget->window, (focus ? miss : missd));
 			mvwprintw(widget->window, 0, 0, "%s", entry->scroll);
 		}
+		wattroff(widget->window, (focus ? miss : missd));
 #else
 		mvwprintw(widget->window, 0, 0, "%s", entry->scroll);
 #endif
 	}
-
-	wattroff(widget->window, A_REVERSE);
 	stop = gnt_util_onscreen_width(entry->scroll, entry->end);
 	if (stop < widget->priv.width)
 		mvwhline(widget->window, 0, stop, ENTRY_CHAR, widget->priv.width - stop);


More information about the Commits mailing list