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.309 by root, Mon Jul 21 16:51:31 2008 UTC vs.
Revision 1.319 by root, Tue Nov 4 23:08:44 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
145 scr_overlay_off ();
146#endif
147
148 rvideo_mode = false;
149 view_start = 0; 163 view_start = 0;
150 num_scr = 0; 164 num_scr = 0;
151 165
152 if (ncol == 0) 166 if (ncol == 0)
153 ncol = 80; 167 ncol = 80;
155 if (nrow == 0) 169 if (nrow == 0)
156 nrow = 24; 170 nrow = 24;
157 171
158 if (ncol == prev_ncol && nrow == prev_nrow) 172 if (ncol == prev_ncol && nrow == prev_nrow)
159 return; 173 return;
160
161 if (current_screen != PRIMARY)
162 scr_swap_screen ();
163 174
164 // we need at least two lines for wrapping to work correctly 175 // we need at least two lines for wrapping to work correctly
165 while (nrow + saveLines < 2) 176 while (nrow + saveLines < 2)
166 { 177 {
167 //TODO//FIXME 178 //TODO//FIXME
380 delete old_ta; 391 delete old_ta;
381 delete old_ra; 392 delete old_ra;
382 393
383 clamp_it (screen.cur.row, 0, nrow - 1); 394 clamp_it (screen.cur.row, 0, nrow - 1);
384 clamp_it (screen.cur.col, 0, ncol - 1); 395 clamp_it (screen.cur.col, 0, ncol - 1);
385
386 free (tabs);
387 } 396 }
388 397
389 CLEAR_ALL_SELECTION (); 398 CLEAR_ALL_SELECTION ();
390 399
391 prev_nrow = nrow; 400 prev_nrow = nrow;
392 prev_ncol = ncol; 401 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 402
402 tt_winch (); 403 tt_winch ();
403 404
404 HOOK_INVOKE ((this, HOOK_RESET, DT_END)); 405 HOOK_INVOKE ((this, HOOK_RESET, DT_END));
405} 406}
417 delete ralloc; ralloc = 0; 418 delete ralloc; ralloc = 0;
418 419
419 free (row_buf); 420 free (row_buf);
420 free (swap_buf); 421 free (swap_buf);
421 free (drawn_buf); 422 free (drawn_buf);
423 row_buf = 0; // signal that we freed all the arrays above
424
422 free (tabs); 425 free (tabs);
423 426 tabs = 0;
424 row_buf = 0; // signal that we freed all the arrays
425 } 427 }
426} 428}
427 429
428/* ------------------------------------------------------------------------- */ 430/* ------------------------------------------------------------------------- */
429/* 431/*
430 * Hard reset 432 * Hard/Soft reset
431 */ 433 */
432void 434void
433rxvt_term::scr_poweron () 435rxvt_term::scr_poweron ()
434{ 436{
435 scr_release (); 437 scr_release ();
436 prev_nrow = prev_ncol = 0; 438 prev_nrow = prev_ncol = 0;
439 scr_soft_reset ();
437 scr_reset (); 440 scr_reset ();
438 441
439 scr_clear (true); 442 scr_clear (true);
440 scr_refresh (); 443 scr_refresh ();
444}
445
446void
447rxvt_term::scr_soft_reset ()
448{
449 /* only affects modes, nothing drastic such as clearing the screen */
450#if ENABLE_OVERLAY
451 scr_overlay_off ();
452#endif
453
454 rvideo_mode = false;
455
456 if (current_screen != PRIMARY)
457 scr_swap_screen ();
458
459 free (tabs);
460 tabs = (char *)rxvt_malloc (ncol);
461
462 for (int col = ncol; --col; )
463 tabs [col] = col % TABSIZE == 0;
464
465 scr_scroll_region (0, MAX_ROWS - 1);
466 scr_rendition (0, ~RS_None);
467 scr_insert_mode (0);
441} 468}
442 469
443/* ------------------------------------------------------------------------- * 470/* ------------------------------------------------------------------------- *
444 * PROCESS SCREEN COMMANDS * 471 * PROCESS SCREEN COMMANDS *
445 * ------------------------------------------------------------------------- */ 472 * ------------------------------------------------------------------------- */
880 if (expect_false ( 907 if (expect_false (
881 line->t[screen.cur.col] == NOCHAR 908 line->t[screen.cur.col] == NOCHAR
882 || (screen.cur.col < ncol - 1 909 || (screen.cur.col < ncol - 1
883 && line->t[screen.cur.col + 1] == NOCHAR) 910 && line->t[screen.cur.col + 1] == NOCHAR)
884 )) 911 ))
885 { 912 scr_kill_char (*line, screen.cur.col);
886 int col = screen.cur.col;
887
888 // find begin
889 while (col > 0 && line->t[col] == NOCHAR)
890 col--;
891
892 rend_t rend = SET_FONT (line->r[col], FONTSET (line->r[col])->find_font (' '));
893
894 // found begin, nuke
895 do {
896 line->t[col] = ' ';
897 line->r[col] = rend;
898 col++;
899 } while (col < ncol && line->t[col] == NOCHAR);
900 }
901 913
902 rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c)); 914 rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c));
903 915
904 // if the character doesn't fit into the remaining columns... 916 // if the character doesn't fit into the remaining columns...
905 if (expect_false (screen.cur.col > ncol - width && ncol >= width)) 917 if (expect_false (screen.cur.col > ncol - width && ncol >= width))
906 { 918 {
907 // ...output spaces 919 // ... artificially enlargen the previous one
908 c = ' '; 920 c = NOCHAR;
909 // and try the same character next loop iteration 921 // and try the same character next loop iteration
910 --str; 922 --str;
911 } 923 }
912 924
913 line->touch (); 925 line->touch ();
1442 * Insert/Delete <count> characters from the current position 1454 * Insert/Delete <count> characters from the current position
1443 */ 1455 */
1444void 1456void
1445rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW 1457rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW
1446{ 1458{
1447 int col, row;
1448 rend_t tr;
1449
1450 want_refresh = 1; 1459 want_refresh = 1;
1451 ZERO_SCROLLBACK (); 1460 ZERO_SCROLLBACK ();
1452 1461
1453 if (count <= 0) 1462 if (count <= 0)
1454 return; 1463 return;
1456 scr_do_wrap (); 1465 scr_do_wrap ();
1457 1466
1458 selection_check (1); 1467 selection_check (1);
1459 min_it (count, ncol - screen.cur.col); 1468 min_it (count, ncol - screen.cur.col);
1460 1469
1461 row = screen.cur.row; 1470 int row = screen.cur.row;
1462 1471
1463 line_t *line = &ROW(row); 1472 line_t *line = &ROW(row);
1464 1473
1465 line->touch (); 1474 line->touch ();
1466 line->is_longer (0); 1475 line->is_longer (0);
1467 1476
1477 // nuke wide spanning the start
1478 if (line->t[screen.cur.col] == NOCHAR)
1479 scr_kill_char (*line, screen.cur.col);
1480
1468 switch (insdel) 1481 switch (insdel)
1469 { 1482 {
1470 case INSERT: 1483 case INSERT:
1471 for (col = ncol - 1; (col - count) >= screen.cur.col; col--) 1484 line->l = min (line->l + count, ncol);
1485
1486 if (line->t[screen.cur.col] == NOCHAR)
1487 scr_kill_char (*line, screen.cur.col);
1488
1489 for (int col = ncol - 1; (col - count) >= screen.cur.col; col--)
1472 { 1490 {
1473 line->t[col] = line->t[col - count]; 1491 line->t[col] = line->t[col - count];
1474 line->r[col] = line->r[col - count]; 1492 line->r[col] = line->r[col - count];
1475 } 1493 }
1476
1477 line->l = min (line->l + count, ncol);
1478 1494
1479 if (selection.op && current_screen == selection.screen 1495 if (selection.op && current_screen == selection.screen
1480 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) 1496 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur))
1481 { 1497 {
1482 if (selection.end.row != screen.cur.row 1498 if (selection.end.row != screen.cur.row
1497 case ERASE: 1513 case ERASE:
1498 screen.cur.col += count; /* don't worry if > ncol */ 1514 screen.cur.col += count; /* don't worry if > ncol */
1499 selection_check (1); 1515 selection_check (1);
1500 screen.cur.col -= count; 1516 screen.cur.col -= count;
1501 1517
1502 line->l = max (line->l - count, 0); 1518 // nuke wide char after the end
1519 if (screen.cur.col + count < ncol && line->t[screen.cur.col + count] == NOCHAR)
1520 scr_kill_char (*line, screen.cur.col + count);
1521
1503 scr_blank_line (*line, screen.cur.col, count, rstyle); 1522 scr_blank_line (*line, screen.cur.col, count, rstyle);
1504 break; 1523 break;
1505 1524
1506 case DELETE: 1525 case DELETE:
1507 tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); 1526 line->l = max (line->l - count, 0);
1508 1527
1528 // nuke wide char spanning the end
1529 if (screen.cur.col + count < ncol && line->t[screen.cur.col + count] == NOCHAR)
1530 scr_kill_char (*line, screen.cur.col + count);
1531
1509 for (col = screen.cur.col; (col + count) < ncol; col++) 1532 for (int col = screen.cur.col; (col + count) < ncol; col++)
1510 { 1533 {
1511 line->t[col] = line->t[col + count]; 1534 line->t[col] = line->t[col + count];
1512 line->r[col] = line->r[col + count]; 1535 line->r[col] = line->r[col + count];
1513 } 1536 }
1514 1537
1515 line->l = max (line->l - count, 0);
1516 scr_blank_line (*line, ncol - count, count, tr); 1538 scr_blank_line (*line, ncol - count, count,
1539 line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask));
1517 1540
1518 if (selection.op && current_screen == selection.screen 1541 if (selection.op && current_screen == selection.screen
1519 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) 1542 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur))
1520 { 1543 {
1521 if (selection.end.row != screen.cur.row 1544 if (selection.end.row != screen.cur.row
1899 XMapWindow (dpy, parent[0]); 1922 XMapWindow (dpy, parent[0]);
1900# endif 1923# endif
1901 1924
1902# if ENABLE_FRILLS 1925# if ENABLE_FRILLS
1903 if (option (Opt_urgentOnBell)) 1926 if (option (Opt_urgentOnBell))
1904 { 1927 set_urgency (1);
1905 if (XWMHints *h = XGetWMHints(dpy, parent[0]))
1906 {
1907 h->flags |= XUrgencyHint;
1908 XSetWMHints (dpy, parent[0], h);
1909 }
1910 }
1911# endif 1928# endif
1912 1929
1913 if (option (Opt_visualBell)) 1930 if (option (Opt_visualBell))
1914 { 1931 {
1915 rvideo_bell = true; 1932 rvideo_bell = true;
2210 continue; 2227 continue;
2211 2228
2212 // redraw one or more characters 2229 // redraw one or more characters
2213 2230
2214 // seek to the beginning of wide characters 2231 // seek to the beginning of wide characters
2215 while (stp[col] == NOCHAR && col > 0) 2232 while (expect_false (stp[col] == NOCHAR && col > 0))
2216 --col; 2233 --col;
2217 2234
2218 rend_t rend = srp[col]; /* screen rendition (target rendtion) */ 2235 rend_t rend = srp[col]; /* screen rendition (target rendtion) */
2219 text_t *text = stp + col; 2236 text_t *text = stp + col;
2220 int count = 1; 2237 int count = 1;
2257 2274
2258 col--; /* went one too far. move back */ 2275 col--; /* went one too far. move back */
2259 count -= i; /* dump any matching trailing chars */ 2276 count -= i; /* dump any matching trailing chars */
2260 2277
2261 // sometimes we optimize away the trailing NOCHAR's, add them back 2278 // sometimes we optimize away the trailing NOCHAR's, add them back
2262 while (i && text[count] == NOCHAR) 2279 while (expect_false (i && text[count] == NOCHAR))
2263 count++, i--; 2280 count++, i--;
2264 2281
2265 /* 2282 /*
2266 * Determine the attributes for the string 2283 * Determine the attributes for the string
2267 */ 2284 */
2268 int fore = fgcolor_of (rend); // desired foreground 2285 int fore = fgcolor_of (rend); // desired foreground
2269 int back = bgcolor_of (rend); // desired background 2286 int back = bgcolor_of (rend); // desired background
2270 2287
2271 // only do special processing if any attributes are set, which is unlikely 2288 // only do special processing if any attributes are set, which is unlikely
2272 if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) 2289 if (expect_false (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)))
2273 { 2290 {
2274 bool invert = rend & RS_RVid; 2291 bool invert = rend & RS_RVid;
2275 2292
2276#ifndef NO_BOLD_UNDERLINE_REVERSE 2293#ifndef NO_BOLD_UNDERLINE_REVERSE
2277 if (rend & RS_Bold && fore == Color_fg) 2294 if (rend & RS_Bold && fore == Color_fg)
2360 /* 2377 /*
2361 * Actually do the drawing of the string here 2378 * Actually do the drawing of the string here
2362 */ 2379 */
2363 rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; 2380 rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)];
2364 2381
2365 if (have_bg && back == Color_bg) 2382 if (expect_true (have_bg && back == Color_bg))
2366 { 2383 {
2367 // this is very ugly, maybe push it into ->draw? 2384 // this is very ugly, maybe push it into ->draw?
2368 2385
2369 for (i = 0; i < count; i++) /* don't draw empty strings */ 2386 for (i = 0; i < count; i++) /* don't draw empty strings */
2370 if (text[i] != ' ') 2387 if (text[i] != ' ')
2377 did_clear: ; 2394 did_clear: ;
2378 } 2395 }
2379 else 2396 else
2380 font->draw (*drawable, xpixel, ypixel, text, count, fore, back); 2397 font->draw (*drawable, xpixel, ypixel, text, count, fore, back);
2381 2398
2382 if (rend & RS_Uline && font->descent > 1 && fore != back) 2399 if (expect_false (rend & RS_Uline && font->descent > 1 && fore != back))
2383 { 2400 {
2384#if ENABLE_FRILLS 2401#if ENABLE_FRILLS
2385 if (ISSET_PIXCOLOR (Color_underline)) 2402 if (ISSET_PIXCOLOR (Color_underline))
2386 XSetForeground (dpy, gc, pix_colors[Color_underline]); 2403 XSetForeground (dpy, gc, pix_colors[Color_underline]);
2387 else 2404 else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines