ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/screen.C
(Generate patch)

Comparing rxvt-unicode/src/screen.C (file contents):
Revision 1.308 by root, Tue Jul 15 16:41:22 2008 UTC vs.
Revision 1.322 by root, Tue Nov 4 23:35:50 2008 UTC

132 132
133 l.l = 0; 133 l.l = 0;
134 l.f = 0; 134 l.f = 0;
135} 135}
136 136
137// nuke a single wide character at the given column
138void
139rxvt_term::scr_kill_char (line_t &l, int col) const NOTHROW
140{
141 // find begin
142 while (col > 0 && l.t[col] == NOCHAR)
143 col--;
144
145 rend_t rend = l.r[col] & ~RS_baseattrMask;
146 rend = SET_FONT (rend, FONTSET (rend)->find_font (' '));
147
148 // found start, nuke
149 do {
150 l.t[col] = ' ';
151 l.r[col] = rend;
152 col++;
153 } while (col < ncol && l.t[col] == NOCHAR);
154}
155
137/* ------------------------------------------------------------------------- * 156/* ------------------------------------------------------------------------- *
138 * SCREEN INITIALISATION * 157 * SCREEN INITIALISATION *
139 * ------------------------------------------------------------------------- */ 158 * ------------------------------------------------------------------------- */
140 159
141void 160void
142rxvt_term::scr_reset () 161rxvt_term::scr_reset ()
143{ 162{
144#if ENABLE_OVERLAY 163 scr_soft_reset ();
145 scr_overlay_off ();
146#endif
147 164
148 rvideo_mode = false;
149 view_start = 0; 165 view_start = 0;
150 num_scr = 0; 166 num_scr = 0;
151 167
152 if (ncol == 0) 168 if (ncol == 0)
153 ncol = 80; 169 ncol = 80;
155 if (nrow == 0) 171 if (nrow == 0)
156 nrow = 24; 172 nrow = 24;
157 173
158 if (ncol == prev_ncol && nrow == prev_nrow) 174 if (ncol == prev_ncol && nrow == prev_nrow)
159 return; 175 return;
160
161 if (current_screen != PRIMARY)
162 scr_swap_screen ();
163 176
164 // we need at least two lines for wrapping to work correctly 177 // we need at least two lines for wrapping to work correctly
165 while (nrow + saveLines < 2) 178 while (nrow + saveLines < 2)
166 { 179 {
167 //TODO//FIXME 180 //TODO//FIXME
380 delete old_ta; 393 delete old_ta;
381 delete old_ra; 394 delete old_ra;
382 395
383 clamp_it (screen.cur.row, 0, nrow - 1); 396 clamp_it (screen.cur.row, 0, nrow - 1);
384 clamp_it (screen.cur.col, 0, ncol - 1); 397 clamp_it (screen.cur.col, 0, ncol - 1);
385
386 free (tabs);
387 } 398 }
388 399
389 CLEAR_ALL_SELECTION (); 400 CLEAR_ALL_SELECTION ();
390 401
391 prev_nrow = nrow; 402 prev_nrow = nrow;
392 prev_ncol = ncol; 403 prev_ncol = ncol;
393
394 tabs = (char *)rxvt_malloc (ncol);
395
396 for (int col = ncol; --col; )
397 tabs [col] = col % TABSIZE == 0;
398
399 if (current_screen != PRIMARY)
400 scr_swap_screen ();
401 404
402 tt_winch (); 405 tt_winch ();
403 406
404 HOOK_INVOKE ((this, HOOK_RESET, DT_END)); 407 HOOK_INVOKE ((this, HOOK_RESET, DT_END));
405} 408}
417 delete ralloc; ralloc = 0; 420 delete ralloc; ralloc = 0;
418 421
419 free (row_buf); 422 free (row_buf);
420 free (swap_buf); 423 free (swap_buf);
421 free (drawn_buf); 424 free (drawn_buf);
425 row_buf = 0; // signal that we freed all the arrays above
426
422 free (tabs); 427 free (tabs);
423 428 tabs = 0;
424 row_buf = 0; // signal that we freed all the arrays
425 } 429 }
426} 430}
427 431
428/* ------------------------------------------------------------------------- */ 432/* ------------------------------------------------------------------------- */
429/* 433/*
430 * Hard reset 434 * Hard/Soft reset
431 */ 435 */
432void 436void
433rxvt_term::scr_poweron () 437rxvt_term::scr_poweron ()
434{ 438{
435 scr_release (); 439 scr_release ();
436 prev_nrow = prev_ncol = 0; 440 prev_nrow = prev_ncol = 0;
437 scr_reset (); 441 scr_reset ();
438 442
439 scr_clear (true); 443 scr_clear (true);
440 scr_refresh (); 444 scr_refresh ();
445}
446
447void
448rxvt_term::scr_soft_reset ()
449{
450 /* only affects modes, nothing drastic such as clearing the screen */
451#if ENABLE_OVERLAY
452 scr_overlay_off ();
453#endif
454
455 rvideo_mode = false;
456
457 if (current_screen != PRIMARY)
458 scr_swap_screen ();
459
460 free (tabs);
461 tabs = (char *)rxvt_malloc (ncol);
462
463 for (int col = ncol; --col; )
464 tabs [col] = col % TABSIZE == 0;
465
466 scr_scroll_region (0, MAX_ROWS - 1);
467 scr_rendition (0, ~RS_None);
468 scr_insert_mode (0);
441} 469}
442 470
443/* ------------------------------------------------------------------------- * 471/* ------------------------------------------------------------------------- *
444 * PROCESS SCREEN COMMANDS * 472 * PROCESS SCREEN COMMANDS *
445 * ------------------------------------------------------------------------- */ 473 * ------------------------------------------------------------------------- */
771 799
772 while (str < strend) 800 while (str < strend)
773 { 801 {
774 c = (unicode_t)*str++; // convert to rxvt-unicodes representation 802 c = (unicode_t)*str++; // convert to rxvt-unicodes representation
775 803
776 if (c < 0x20) 804 if (expect_false (c < 0x20))
777 if (c == C0_LF) 805 if (c == C0_LF)
778 { 806 {
779 max_it (line->l, screen.cur.col); 807 max_it (line->l, screen.cur.col);
780 808
781 screen.flags &= ~Screen_WrapNext; 809 screen.flags &= ~Screen_WrapNext;
800 { 828 {
801 scr_tab (1, true); 829 scr_tab (1, true);
802 continue; 830 continue;
803 } 831 }
804 832
833 if (expect_false (
805 if (checksel /* see if we're writing within selection */ 834 checksel /* see if we're writing within selection */
806 && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) 835 && !ROWCOL_IS_BEFORE (screen.cur, selection.beg)
807 && ROWCOL_IS_BEFORE (screen.cur, selection.end)) 836 && ROWCOL_IS_BEFORE (screen.cur, selection.end)
837 ))
808 { 838 {
809 checksel = 0; 839 checksel = 0;
810 /* 840 /*
811 * If we wrote anywhere in the selected area, kill the selection 841 * If we wrote anywhere in the selected area, kill the selection
812 * XXX: should we kill the mark too? Possibly, but maybe that 842 * XXX: should we kill the mark too? Possibly, but maybe that
813 * should be a similar check. 843 * should be a similar check.
814 */ 844 */
815 CLEAR_SELECTION (); 845 CLEAR_SELECTION ();
816 } 846 }
817 847
818 if (screen.flags & Screen_WrapNext) 848 if (expect_false (screen.flags & Screen_WrapNext))
819 { 849 {
820 scr_do_wrap (); 850 scr_do_wrap ();
821 851
822 line->l = ncol; 852 line->l = ncol;
823 line->is_longer (1); 853 line->is_longer (1);
825 row = screen.cur.row; 855 row = screen.cur.row;
826 line = &ROW(row); /* _must_ refresh */ 856 line = &ROW(row); /* _must_ refresh */
827 } 857 }
828 858
829 // some utf-8 decoders "decode" surrogate characters: let's fix this. 859 // some utf-8 decoders "decode" surrogate characters: let's fix this.
830 if (IN_RANGE_INC (c, 0xd800, 0xdfff)) 860 if (expect_false (IN_RANGE_INC (c, 0xd800, 0xdfff)))
831 c = 0xfffd; 861 c = 0xfffd;
832 862
833 // rely on wcwidth to tell us the character width, do wcwidth before 863 // rely on wcwidth to tell us the character width, do wcwidth before
834 // further replacements, as wcwidth might return -1 for the line 864 // further replacements, as wcwidth might return -1 for the line
835 // drawing characters below as they might be invalid in the current 865 // drawing characters below as they might be invalid in the current
836 // locale. 866 // locale.
837 int width = WCWIDTH (c); 867 int width = WCWIDTH (c);
838 868
839 if (charsets [screen.charset] == '0') // DEC SPECIAL 869 if (expect_false (charsets [screen.charset] == '0')) // DEC SPECIAL
840 { 870 {
841 // vt100 special graphics and line drawing 871 // vt100 special graphics and line drawing
842 // 5f-7e standard vt100 872 // 5f-7e standard vt100
843 // 40-5e rxvt extension for extra curses acs chars 873 // 40-5e rxvt extension for extra curses acs chars
844 static uint16_t vt100_0[62] = { // 41 .. 7e 874 static uint16_t vt100_0[62] = { // 41 .. 7e
857 c = vt100_0[c - 0x41]; 887 c = vt100_0[c - 0x41];
858 width = 1; // vt100 line drawing characters are always single-width 888 width = 1; // vt100 line drawing characters are always single-width
859 } 889 }
860 } 890 }
861 891
862 if (screen.flags & Screen_Insert) 892 if (expect_false (screen.flags & Screen_Insert))
863 scr_insdel_chars (width, INSERT); 893 scr_insdel_chars (width, INSERT);
864 894
865 if (width != 0) 895 if (width != 0)
866 { 896 {
867#if !UNICODE_3 897#if !UNICODE_3
873 c = 0xfffd; 903 c = 0xfffd;
874# endif 904# endif
875#endif 905#endif
876 906
877 // nuke the character at this position, if required 907 // nuke the character at this position, if required
908 if (expect_false (
878 if (line->t[screen.cur.col] == NOCHAR 909 line->t[screen.cur.col] == NOCHAR
879 || (screen.cur.col < ncol - 1 910 || (screen.cur.col < ncol - 1
880 && line->t[screen.cur.col + 1] == NOCHAR)) 911 && line->t[screen.cur.col + 1] == NOCHAR)
912 ))
913 scr_kill_char (*line, screen.cur.col);
914
915 rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c));
916
917 // if the character doesn't fit into the remaining columns...
918 if (expect_false (screen.cur.col > ncol - width && ncol >= width))
881 { 919 {
882 int col = screen.cur.col; 920 // ... artificially enlargen the previous one
883
884 // find begin
885 while (col > 0 && line->t[col] == NOCHAR)
886 col--;
887
888 rend_t rend = SET_FONT (line->r[col], FONTSET (line->r[col])->find_font (' '));
889
890 // found begin, nuke
891 do {
892 line->t[col] = ' ';
893 line->r[col] = rend;
894 col++;
895 } while (col < ncol && line->t[col] == NOCHAR);
896 }
897
898 rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c));
899
900 // if the character doesn't fit into the remaining columns...
901 if (screen.cur.col > ncol - width && ncol >= width)
902 {
903 // ...output spaces
904 c = ' '; 921 c = NOCHAR;
905 // and try the same character next loop iteration 922 // and try the same character next loop iteration
906 --str; 923 --str;
907 } 924 }
908 925
909 line->touch (); 926 line->touch ();
911 do 928 do
912 { 929 {
913 line->t[screen.cur.col] = c; 930 line->t[screen.cur.col] = c;
914 line->r[screen.cur.col] = rend; 931 line->r[screen.cur.col] = rend;
915 932
916 if (screen.cur.col < ncol - 1) 933 if (expect_true (screen.cur.col < ncol - 1))
917 screen.cur.col++; 934 screen.cur.col++;
918 else 935 else
919 { 936 {
920 line->l = ncol; 937 line->l = ncol;
921 if (screen.flags & Screen_Autowrap) 938 if (screen.flags & Screen_Autowrap)
923 break; 940 break;
924 } 941 }
925 942
926 c = NOCHAR; 943 c = NOCHAR;
927 } 944 }
928 while (--width > 0); 945 while (expect_false (--width > 0));
929 946
930 // pad with spaces when overwriting wide character with smaller one 947 // pad with spaces when overwriting wide character with smaller one
931 if (!width) 948 if (expect_false (!width))
932 { 949 {
933 line->touch (); 950 line->touch ();
934 951
935 for (int c = screen.cur.col; c < ncol && line->t[c] == NOCHAR; c++) 952 for (int c = screen.cur.col; c < ncol && line->t[c] == NOCHAR; c++)
936 { 953 {
937 line->t[c] = ' '; 954 line->t[c] = ' ';
938 line->r[c] = rend; 955 line->r[c] = rend;
939 } 956 }
940 } 957 }
941 } 958 }
959#if ENABLE_COMBINING
942 else // width == 0 960 else // width == 0
943 { 961 {
944#if ENABLE_COMBINING 962 if (c != 0xfeff) // ignore BOM
945 // handle combining characters
946 // we just tag the accent on the previous on-screen character.
947 // this is arguably not correct, but also arguably not wrong.
948 // we don't handle double-width characters nicely yet.
949 line_t *linep;
950 text_t *tp;
951 rend_t *rp;
952
953 if (screen.cur.col > 0)
954 { 963 {
964 // handle combining characters
965 // we just tag the accent on the previous on-screen character.
966 // this is arguably not correct, but also arguably not wrong.
967 // we don't handle double-width characters nicely yet.
968 line_t *linep;
969 text_t *tp;
970 rend_t *rp;
971
972 if (screen.cur.col > 0)
973 {
955 linep = line; 974 linep = line;
956 tp = line->t + screen.cur.col - 1; 975 tp = line->t + screen.cur.col - 1;
957 rp = line->r + screen.cur.col - 1; 976 rp = line->r + screen.cur.col - 1;
977 }
978 else if (screen.cur.row > 0
979 && ROW(screen.cur.row - 1).is_longer ())
980 {
981 linep = &ROW(screen.cur.row - 1);
982 tp = line->t + ncol - 1;
983 rp = line->r + ncol - 1;
984 }
985 else
986 continue;
987
988 linep->touch ();
989
990 while (*tp == NOCHAR && tp > linep->t)
991 tp--, rp--;
992
993 // first try to find a precomposed character
994 unicode_t n = rxvt_compose (*tp, c);
995 if (n == NOCHAR)
996 n = rxvt_composite.compose (*tp, c);
997
998 *tp = n;
999 *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp));
958 } 1000 }
959 else if (screen.cur.row > 0
960 && ROW(screen.cur.row - 1).is_longer ())
961 {
962 linep = &ROW(screen.cur.row - 1);
963 tp = line->t + ncol - 1;
964 rp = line->r + ncol - 1;
965 } 1001 }
966 else
967 continue;
968
969 linep->touch ();
970
971 while (*tp == NOCHAR && tp > linep->t)
972 tp--, rp--;
973
974 // first try to find a precomposed character
975 unicode_t n = rxvt_compose (*tp, c);
976 if (n == NOCHAR)
977 n = rxvt_composite.compose (*tp, c);
978
979 *tp = n;
980 *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp));
981#endif 1002#endif
982 }
983 } 1003 }
984 1004
985 max_it (line->l, screen.cur.col); 1005 max_it (line->l, screen.cur.col);
986 1006
987#ifdef DEBUG_STRICT 1007#ifdef DEBUG_STRICT
1331 { 1351 {
1332 ren = DEFAULT_RSTYLE; 1352 ren = DEFAULT_RSTYLE;
1333 1353
1334 if (mapped) 1354 if (mapped)
1335 XClearArea (dpy, vt, 0, 1355 XClearArea (dpy, vt, 0,
1336 Row2Pixel (row), (unsigned int)width, 1356 Row2Pixel (row - view_start), (unsigned int)width,
1337 (unsigned int)Height2Pixel (num), False); 1357 (unsigned int)Height2Pixel (num), False);
1338 } 1358 }
1339 else 1359 else
1340 { 1360 {
1341 ren = rstyle & (RS_fgMask | RS_bgMask); 1361 ren = rstyle & (RS_fgMask | RS_bgMask);
1342 1362
1343 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; 1363 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)];
1344 XChangeGC (dpy, gc, GCForeground, &gcvalue); 1364 XChangeGC (dpy, gc, GCForeground, &gcvalue);
1345 XFillRectangle (dpy, vt, gc, 1365 XFillRectangle (dpy, vt, gc,
1346 0, Row2Pixel (row), 1366 0, Row2Pixel (row - view_start),
1347 (unsigned int)width, 1367 (unsigned int)width,
1348 (unsigned int)Height2Pixel (num)); 1368 (unsigned int)Height2Pixel (num));
1349 gcvalue.foreground = pix_colors[Color_fg]; 1369 gcvalue.foreground = pix_colors[Color_fg];
1350 XChangeGC (dpy, gc, GCForeground, &gcvalue); 1370 XChangeGC (dpy, gc, GCForeground, &gcvalue);
1351 } 1371 }
1435 * Insert/Delete <count> characters from the current position 1455 * Insert/Delete <count> characters from the current position
1436 */ 1456 */
1437void 1457void
1438rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW 1458rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW
1439{ 1459{
1440 int col, row;
1441 rend_t tr;
1442
1443 want_refresh = 1; 1460 want_refresh = 1;
1444 ZERO_SCROLLBACK (); 1461 ZERO_SCROLLBACK ();
1445 1462
1446 if (count <= 0) 1463 if (count <= 0)
1447 return; 1464 return;
1449 scr_do_wrap (); 1466 scr_do_wrap ();
1450 1467
1451 selection_check (1); 1468 selection_check (1);
1452 min_it (count, ncol - screen.cur.col); 1469 min_it (count, ncol - screen.cur.col);
1453 1470
1454 row = screen.cur.row; 1471 int row = screen.cur.row;
1455 1472
1456 line_t *line = &ROW(row); 1473 line_t *line = &ROW(row);
1457 1474
1458 line->touch (); 1475 line->touch ();
1459 line->is_longer (0); 1476 line->is_longer (0);
1460 1477
1478 // nuke wide spanning the start
1479 if (line->t[screen.cur.col] == NOCHAR)
1480 scr_kill_char (*line, screen.cur.col);
1481
1461 switch (insdel) 1482 switch (insdel)
1462 { 1483 {
1463 case INSERT: 1484 case INSERT:
1464 for (col = ncol - 1; (col - count) >= screen.cur.col; col--) 1485 line->l = min (line->l + count, ncol);
1486
1487 if (line->t[screen.cur.col] == NOCHAR)
1488 scr_kill_char (*line, screen.cur.col);
1489
1490 for (int col = ncol - 1; (col - count) >= screen.cur.col; col--)
1465 { 1491 {
1466 line->t[col] = line->t[col - count]; 1492 line->t[col] = line->t[col - count];
1467 line->r[col] = line->r[col - count]; 1493 line->r[col] = line->r[col - count];
1468 } 1494 }
1469
1470 line->l = min (line->l + count, ncol);
1471 1495
1472 if (selection.op && current_screen == selection.screen 1496 if (selection.op && current_screen == selection.screen
1473 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) 1497 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur))
1474 { 1498 {
1475 if (selection.end.row != screen.cur.row 1499 if (selection.end.row != screen.cur.row
1490 case ERASE: 1514 case ERASE:
1491 screen.cur.col += count; /* don't worry if > ncol */ 1515 screen.cur.col += count; /* don't worry if > ncol */
1492 selection_check (1); 1516 selection_check (1);
1493 screen.cur.col -= count; 1517 screen.cur.col -= count;
1494 1518
1495 line->l = max (line->l - count, 0); 1519 // nuke wide char after the end
1520 if (screen.cur.col + count < ncol && line->t[screen.cur.col + count] == NOCHAR)
1521 scr_kill_char (*line, screen.cur.col + count);
1522
1496 scr_blank_line (*line, screen.cur.col, count, rstyle); 1523 scr_blank_line (*line, screen.cur.col, count, rstyle);
1497 break; 1524 break;
1498 1525
1499 case DELETE: 1526 case DELETE:
1500 tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); 1527 line->l = max (line->l - count, 0);
1501 1528
1529 // nuke wide char spanning the end
1530 if (screen.cur.col + count < ncol && line->t[screen.cur.col + count] == NOCHAR)
1531 scr_kill_char (*line, screen.cur.col + count);
1532
1502 for (col = screen.cur.col; (col + count) < ncol; col++) 1533 for (int col = screen.cur.col; (col + count) < ncol; col++)
1503 { 1534 {
1504 line->t[col] = line->t[col + count]; 1535 line->t[col] = line->t[col + count];
1505 line->r[col] = line->r[col + count]; 1536 line->r[col] = line->r[col + count];
1506 } 1537 }
1507 1538
1508 line->l = max (line->l - count, 0);
1509 scr_blank_line (*line, ncol - count, count, tr); 1539 scr_blank_line (*line, ncol - count, count,
1540 line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask));
1510 1541
1511 if (selection.op && current_screen == selection.screen 1542 if (selection.op && current_screen == selection.screen
1512 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) 1543 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur))
1513 { 1544 {
1514 if (selection.end.row != screen.cur.row 1545 if (selection.end.row != screen.cur.row
1892 XMapWindow (dpy, parent[0]); 1923 XMapWindow (dpy, parent[0]);
1893# endif 1924# endif
1894 1925
1895# if ENABLE_FRILLS 1926# if ENABLE_FRILLS
1896 if (option (Opt_urgentOnBell)) 1927 if (option (Opt_urgentOnBell))
1897 { 1928 set_urgency (1);
1898 if (XWMHints *h = XGetWMHints(dpy, parent[0]))
1899 {
1900 h->flags |= XUrgencyHint;
1901 XSetWMHints (dpy, parent[0], h);
1902 }
1903 }
1904# endif 1929# endif
1905 1930
1906 if (option (Opt_visualBell)) 1931 if (option (Opt_visualBell))
1907 { 1932 {
1908 rvideo_bell = true; 1933 rvideo_bell = true;
2203 continue; 2228 continue;
2204 2229
2205 // redraw one or more characters 2230 // redraw one or more characters
2206 2231
2207 // seek to the beginning of wide characters 2232 // seek to the beginning of wide characters
2208 while (stp[col] == NOCHAR && col > 0) 2233 while (expect_false (stp[col] == NOCHAR && col > 0))
2209 --col; 2234 --col;
2210 2235
2211 rend_t rend = srp[col]; /* screen rendition (target rendtion) */ 2236 rend_t rend = srp[col]; /* screen rendition (target rendtion) */
2212 text_t *text = stp + col; 2237 text_t *text = stp + col;
2213 int count = 1; 2238 int count = 1;
2250 2275
2251 col--; /* went one too far. move back */ 2276 col--; /* went one too far. move back */
2252 count -= i; /* dump any matching trailing chars */ 2277 count -= i; /* dump any matching trailing chars */
2253 2278
2254 // sometimes we optimize away the trailing NOCHAR's, add them back 2279 // sometimes we optimize away the trailing NOCHAR's, add them back
2255 while (i && text[count] == NOCHAR) 2280 while (expect_false (i && text[count] == NOCHAR))
2256 count++, i--; 2281 count++, i--;
2257 2282
2258 /* 2283 /*
2259 * Determine the attributes for the string 2284 * Determine the attributes for the string
2260 */ 2285 */
2261 int fore = fgcolor_of (rend); // desired foreground 2286 int fore = fgcolor_of (rend); // desired foreground
2262 int back = bgcolor_of (rend); // desired background 2287 int back = bgcolor_of (rend); // desired background
2263 2288
2264 // only do special processing if any attributes are set, which is unlikely 2289 // only do special processing if any attributes are set, which is unlikely
2265 if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) 2290 if (expect_false (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)))
2266 { 2291 {
2267 bool invert = rend & RS_RVid; 2292 bool invert = rend & RS_RVid;
2268 2293
2269#ifndef NO_BOLD_UNDERLINE_REVERSE 2294#ifndef NO_BOLD_UNDERLINE_REVERSE
2270 if (rend & RS_Bold && fore == Color_fg) 2295 if (rend & RS_Bold && fore == Color_fg)
2353 /* 2378 /*
2354 * Actually do the drawing of the string here 2379 * Actually do the drawing of the string here
2355 */ 2380 */
2356 rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; 2381 rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)];
2357 2382
2358 if (have_bg && back == Color_bg) 2383 if (expect_true (have_bg && back == Color_bg))
2359 { 2384 {
2360 // this is very ugly, maybe push it into ->draw? 2385 // this is very ugly, maybe push it into ->draw?
2361 2386
2362 for (i = 0; i < count; i++) /* don't draw empty strings */ 2387 for (i = 0; i < count; i++) /* don't draw empty strings */
2363 if (text[i] != ' ') 2388 if (text[i] != ' ')
2370 did_clear: ; 2395 did_clear: ;
2371 } 2396 }
2372 else 2397 else
2373 font->draw (*drawable, xpixel, ypixel, text, count, fore, back); 2398 font->draw (*drawable, xpixel, ypixel, text, count, fore, back);
2374 2399
2375 if (rend & RS_Uline && font->descent > 1 && fore != back) 2400 if (expect_false (rend & RS_Uline && font->descent > 1 && fore != back))
2376 { 2401 {
2377#if ENABLE_FRILLS 2402#if ENABLE_FRILLS
2378 if (ISSET_PIXCOLOR (Color_underline)) 2403 if (ISSET_PIXCOLOR (Color_underline))
2379 XSetForeground (dpy, gc, pix_colors[Color_underline]); 2404 XSetForeground (dpy, gc, pix_colors[Color_underline]);
2380 else 2405 else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines