Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/screen.c @ 2328:1e24d93746d6
Fix roster colors, closes issue #60
According to the X/Open Curses standard Issue 4 v2, it is unspecified
whether wattrset can change attributes except A_BLINK, A_BOLD, A_DIM,
A_REVERSE, A_STANDOUT, A_UNDERLINE. Thus we should use wbkgdset() for
changing colors.
author | franky |
---|---|
date | Thu, 09 May 2019 21:19:31 +0200 |
parents | 54b4272de463 |
children | 69d292ccf196 |
comparison
equal
deleted
inserted
replaced
2327:8ecc28068748 | 2328:1e24d93746d6 |
---|---|
1264 color = COLOR_MSGIN; | 1264 color = COLOR_MSGIN; |
1265 else | 1265 else |
1266 color = COLOR_GENERAL; | 1266 color = COLOR_GENERAL; |
1267 | 1267 |
1268 if (color != COLOR_GENERAL) | 1268 if (color != COLOR_GENERAL) |
1269 wattrset(win_entry->win, get_color(color)); | 1269 wbkgdset(win_entry->win, get_color(color)); |
1270 | 1270 |
1271 // Generate the prefix area and display it | 1271 // Generate the prefix area and display it |
1272 | 1272 |
1273 timelen = scr_line_prefix(line, pref, prefixwidth); | 1273 timelen = scr_line_prefix(line, pref, prefixwidth); |
1274 if (timelen && line->flags & HBB_PREFIX_DELAYED) { | 1274 if (timelen && line->flags & HBB_PREFIX_DELAYED) { |
1275 char tmp; | 1275 char tmp; |
1276 | 1276 |
1277 tmp = pref[timelen]; | 1277 tmp = pref[timelen]; |
1278 pref[timelen] = '\0'; | 1278 pref[timelen] = '\0'; |
1279 wattrset(win_entry->win, get_color(COLOR_TIMESTAMP)); | 1279 wbkgdset(win_entry->win, get_color(COLOR_TIMESTAMP)); |
1280 wprintw(win_entry->win, pref); | 1280 wprintw(win_entry->win, pref); |
1281 pref[timelen] = tmp; | 1281 pref[timelen] = tmp; |
1282 wattrset(win_entry->win, get_color(color)); | 1282 wbkgdset(win_entry->win, get_color(color)); |
1283 wprintw(win_entry->win, pref+timelen); | 1283 wprintw(win_entry->win, pref+timelen); |
1284 } else | 1284 } else |
1285 wprintw(win_entry->win, pref); | 1285 wprintw(win_entry->win, pref); |
1286 | 1286 |
1287 // Make sure we are at the right position | 1287 // Make sure we are at the right position |
1332 if (nickcolors) | 1332 if (nickcolors) |
1333 actual = g_hash_table_lookup(nickcolors, line->text); | 1333 actual = g_hash_table_lookup(nickcolors, line->text); |
1334 if (actual && ((type == MC_ALL) || (actual->manual)) | 1334 if (actual && ((type == MC_ALL) || (actual->manual)) |
1335 && (line->flags & HBB_PREFIX_IN) && | 1335 && (line->flags & HBB_PREFIX_IN) && |
1336 (!(line->flags & HBB_PREFIX_HLIGHT_OUT))) | 1336 (!(line->flags & HBB_PREFIX_HLIGHT_OUT))) |
1337 wattrset(win_entry->win, compose_color(actual->color)); | 1337 wbkgdset(win_entry->win, compose_color(actual->color)); |
1338 wprintw(win_entry->win, "%s", line->text); | 1338 wprintw(win_entry->win, "%s", line->text); |
1339 // Return the char | 1339 // Return the char |
1340 line->text[line->mucnicklen] = tmp; | 1340 line->text[line->mucnicklen] = tmp; |
1341 // Return the color back | 1341 // Return the color back |
1342 wattrset(win_entry->win, get_color(color)); | 1342 wbkgdset(win_entry->win, get_color(color)); |
1343 } | 1343 } |
1344 | 1344 |
1345 // Display text line | 1345 // Display text line |
1346 wprintw(win_entry->win, "%s", line->text+line->mucnicklen); | 1346 wprintw(win_entry->win, "%s", line->text+line->mucnicklen); |
1347 wclrtoeol(win_entry->win); | 1347 wclrtoeol(win_entry->win); |
1348 | |
1349 // Restore default ("general") color | |
1350 if (color != COLOR_GENERAL) | |
1351 wbkgdset(win_entry->win, get_color(COLOR_GENERAL)); | |
1348 | 1352 |
1349 scr_update_window_skipline: | 1353 scr_update_window_skipline: |
1350 skipline = FALSE; | 1354 skipline = FALSE; |
1351 if (readmark && line->flags & HBB_PREFIX_READMARK) { | 1355 if (readmark && line->flags & HBB_PREFIX_READMARK) { |
1352 int i, w; | 1356 int i, w; |
1353 mark_offset++; | 1357 mark_offset++; |
1354 | 1358 |
1355 // Display the mark | 1359 // Display the mark |
1356 winy = n + mark_offset; | 1360 winy = n + mark_offset; |
1357 wmove(win_entry->win, winy, 0); | 1361 wmove(win_entry->win, winy, 0); |
1358 color = COLOR_READMARK; | 1362 wbkgdset(win_entry->win, get_color(COLOR_READMARK)); |
1359 wattrset(win_entry->win, get_color(color)); | |
1360 g_snprintf(pref, prefixwidth, " == "); | 1363 g_snprintf(pref, prefixwidth, " == "); |
1361 wprintw(win_entry->win, pref); | 1364 wprintw(win_entry->win, pref); |
1362 w = scr_gettextwidth() / 3; | 1365 w = scr_gettextwidth() / 3; |
1363 for (i=0; i<w; i++) | 1366 for (i=0; i<w; i++) |
1364 wprintw(win_entry->win, "== "); | 1367 wprintw(win_entry->win, "== "); |
1365 wclrtoeol(win_entry->win); | 1368 wclrtoeol(win_entry->win); |
1366 wattrset(win_entry->win, get_color(COLOR_GENERAL)); | 1369 wbkgdset(win_entry->win, get_color(COLOR_GENERAL)); |
1367 } | 1370 } |
1368 | |
1369 // Restore default ("general") color | |
1370 if (color != COLOR_GENERAL) | |
1371 wattrset(win_entry->win, get_color(COLOR_GENERAL)); | |
1372 | |
1373 g_free(line->text); | 1371 g_free(line->text); |
1374 g_free(line); | 1372 g_free(line); |
1375 } else { | 1373 } else { |
1376 wclrtobot(win_entry->win); | 1374 wclrtobot(win_entry->win); |
1377 break; | 1375 break; |
1756 exit(EXIT_FAILURE); | 1754 exit(EXIT_FAILURE); |
1757 } | 1755 } |
1758 wbkgd(rosterWnd, get_color(COLOR_GENERAL)); | 1756 wbkgd(rosterWnd, get_color(COLOR_GENERAL)); |
1759 wbkgd(chatWnd, get_color(COLOR_GENERAL)); | 1757 wbkgd(chatWnd, get_color(COLOR_GENERAL)); |
1760 wbkgd(activechatWnd, get_color(COLOR_GENERAL)); | 1758 wbkgd(activechatWnd, get_color(COLOR_GENERAL)); |
1761 wbkgd(logWnd, get_color(COLOR_GENERAL)); | 1759 wbkgd(logWnd, get_color(COLOR_LOG)); |
1762 wbkgd(chatstatusWnd, get_color(COLOR_STATUS)); | 1760 wbkgd(chatstatusWnd, get_color(COLOR_STATUS)); |
1763 wbkgd(mainstatusWnd, get_color(COLOR_STATUS)); | 1761 wbkgd(mainstatusWnd, get_color(COLOR_STATUS)); |
1764 | |
1765 wattrset(logWnd, get_color(COLOR_LOG)); | |
1766 } else { | 1762 } else { |
1767 /* Resize/move windows */ | 1763 /* Resize/move windows */ |
1768 wresize(rosterWnd, CHAT_WIN_HEIGHT, Roster_Width); | 1764 wresize(rosterWnd, CHAT_WIN_HEIGHT, Roster_Width); |
1769 wresize(chatWnd, CHAT_WIN_HEIGHT, maxX - Roster_Width); | 1765 wresize(chatWnd, CHAT_WIN_HEIGHT, maxX - Roster_Width); |
1770 wresize(logWnd, Log_Win_Height-2, maxX); | 1766 wresize(logWnd, Log_Win_Height-2, maxX); |
2125 offset = 0; | 2121 offset = 0; |
2126 else | 2122 else |
2127 scr_update_chat_status(FALSE); | 2123 scr_update_chat_status(FALSE); |
2128 | 2124 |
2129 // Cleanup of roster window | 2125 // Cleanup of roster window |
2126 wbkgdset(rosterWnd, get_color(COLOR_GENERAL)); // clear background color | |
2130 werase(rosterWnd); | 2127 werase(rosterWnd); |
2131 | 2128 |
2132 if (Roster_Width) { | 2129 if (Roster_Width) { |
2133 int line_x_pos = roster_win_on_right ? 0 : Roster_Width-1; | 2130 int line_x_pos = roster_win_on_right ? 0 : Roster_Width-1; |
2134 // Redraw the vertical line (not very good...) | 2131 // Redraw the vertical line (not very good...) |
2135 wattrset(rosterWnd, get_color(COLOR_GENERAL)); | |
2136 for (i=0 ; i < CHAT_WIN_HEIGHT ; i++) | 2132 for (i=0 ; i < CHAT_WIN_HEIGHT ; i++) |
2137 mvwaddch(rosterWnd, i, line_x_pos, ACS_VLINE); | 2133 mvwaddch(rosterWnd, i, line_x_pos, ACS_VLINE); |
2138 } | 2134 } |
2139 | 2135 |
2140 // Leave now if buddylist is empty or the roster is hidden | 2136 // Leave now if buddylist is empty or the roster is hidden |
2240 if (budstate < imstatus_size) | 2236 if (budstate < imstatus_size) |
2241 status = imstatus2char[budstate]; | 2237 status = imstatus2char[budstate]; |
2242 } | 2238 } |
2243 if (buddy == current_buddy) { | 2239 if (buddy == current_buddy) { |
2244 if (pending == '#') | 2240 if (pending == '#') |
2245 wattrset(rosterWnd, get_color(COLOR_ROSTERSELNMSG)); | 2241 wbkgdset(rosterWnd, get_color(COLOR_ROSTERSELNMSG)); |
2246 else | 2242 else |
2247 wattrset(rosterWnd, get_color(COLOR_ROSTERSEL)); | 2243 wbkgdset(rosterWnd, get_color(COLOR_ROSTERSEL)); |
2248 // The 3 following lines aim at coloring the whole line | 2244 // The 3 following lines aim at coloring the whole line |
2249 wmove(rosterWnd, i, x_pos); | 2245 wmove(rosterWnd, i, x_pos); |
2250 for (n = 0; n < maxx; n++) | 2246 for (n = 0; n < maxx; n++) |
2251 waddch(rosterWnd, ' '); | 2247 waddch(rosterWnd, ' '); |
2252 } else { | 2248 } else { |
2253 if (pending == '#') | 2249 if (pending == '#') |
2254 wattrset(rosterWnd, get_color(COLOR_ROSTERNMSG)); | 2250 wbkgdset(rosterWnd, get_color(COLOR_ROSTERNMSG)); |
2255 else { | 2251 else { |
2256 int color = get_color(COLOR_ROSTER); | 2252 int color = get_color(COLOR_ROSTER); |
2257 if ((!isspe) && (!isgrp)) { // Look for color rules | 2253 if ((!isspe) && (!isgrp)) { // Look for color rules |
2258 GSList *head; | 2254 GSList *head; |
2259 const char *bjid = buddy_getjid(BUDDATA(buddy)); | 2255 const char *bjid = buddy_getjid(BUDDATA(buddy)); |
2264 color = compose_color(rc->color); | 2260 color = compose_color(rc->color); |
2265 break; | 2261 break; |
2266 } | 2262 } |
2267 } | 2263 } |
2268 } | 2264 } |
2269 wattrset(rosterWnd, color); | 2265 wbkgdset(rosterWnd, color); |
2270 } | 2266 } |
2271 } | 2267 } |
2272 | 2268 |
2273 name[0] = 0; | 2269 name[0] = 0; |
2274 unread[0] = 0; | 2270 unread[0] = 0; |