… | |
… | |
283 | // to come up with a lean and mean algorithm. |
283 | // to come up with a lean and mean algorithm. |
284 | |
284 | |
285 | row_col_t ocur = screen.cur; |
285 | row_col_t ocur = screen.cur; |
286 | ocur.row = MOD (term_start + ocur.row, prev_total_rows); |
286 | ocur.row = MOD (term_start + ocur.row, prev_total_rows); |
287 | |
287 | |
288 | while (p != pend && q > 0) |
288 | do |
289 | { |
289 | { |
290 | p = MOD (p - 1, prev_total_rows); |
290 | p = MOD (p - 1, prev_total_rows); |
291 | #ifdef DEBUG_STRICT |
291 | #ifdef DEBUG_STRICT |
292 | assert (old_buf [MOD (p, prev_total_rows)].t); |
292 | assert (old_buf [MOD (p, prev_total_rows)].t); |
293 | #endif |
293 | #endif |
… | |
… | |
329 | int prow = lofs / prev_ncol; |
329 | int prow = lofs / prev_ncol; |
330 | int pcol = lofs % prev_ncol; |
330 | int pcol = lofs % prev_ncol; |
331 | |
331 | |
332 | prow = MOD (p + prow, prev_total_rows); |
332 | prow = MOD (p + prow, prev_total_rows); |
333 | |
333 | |
334 | // we only adjust the cursor _row_, as this seems to upset |
334 | // we only adjust the cursor _row_ and put it into |
|
|
335 | // the topmost line of "long line" it was in, as |
335 | // applications/shells/readline least. |
336 | // this seems to upset applications/shells/readline |
|
|
337 | // least. |
336 | if (prow == ocur.row) |
338 | if (prow == ocur.row) |
337 | screen.cur.row = qrow - (total_rows - nrow); |
339 | screen.cur.row = q - (total_rows - nrow); |
338 | |
340 | |
339 | line_t &pline = old_buf [prow]; |
341 | line_t &pline = old_buf [prow]; |
340 | |
342 | |
341 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
343 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
342 | |
344 | |
… | |
… | |
350 | qcol += len; |
352 | qcol += len; |
351 | } |
353 | } |
352 | } |
354 | } |
353 | |
355 | |
354 | qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1; |
356 | qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1; |
|
|
357 | printf ("qline->l %d = llen %d < ncol %d ? %d : MOD %d\n", qline->l,llen,ncol,llen,MOD (llen - 1, ncol) + 1);//D |
355 | scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); |
358 | scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); |
356 | } |
359 | } |
|
|
360 | while (p != pend && q > 0); |
357 | |
361 | |
358 | term_start = total_rows - nrow; |
362 | term_start = total_rows - nrow; |
359 | view_start = 0; |
|
|
360 | nsaved = term_start - q; |
363 | nsaved = term_start - q; |
361 | |
364 | |
362 | // make sure all terminal lines exist |
365 | // make sure all terminal lines exist |
363 | while (nsaved < 0) |
366 | while (nsaved < 0) |
364 | scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE); |
367 | scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE); |
… | |
… | |
381 | { |
384 | { |
382 | row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); |
385 | row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); |
383 | } |
386 | } |
384 | |
387 | |
385 | term_start = 0; |
388 | term_start = 0; |
386 | view_start = 0; |
|
|
387 | } |
389 | } |
388 | |
390 | |
389 | #ifdef DEBUG_STRICT |
391 | #ifdef DEBUG_STRICT //TODO: remove |
390 | for (int i = -nsaved; i < nrow; i++) |
392 | for (int i = -nsaved; i < nrow; i++) |
391 | assert (ROW (i).t); |
393 | assert (ROW (i).t); |
392 | #endif |
394 | #endif |
393 | |
395 | |
394 | free (old_buf); |
396 | free (old_buf); |
… | |
… | |
619 | { |
621 | { |
620 | selection.beg.row -= count; |
622 | selection.beg.row -= count; |
621 | selection.end.row -= count; |
623 | selection.end.row -= count; |
622 | selection.mark.row -= count; |
624 | selection.mark.row -= count; |
623 | |
625 | |
624 | selection_check (0); |
626 | if (selection.beg.row < -nsaved |
|
|
627 | || selection.end.row < -nsaved |
|
|
628 | || selection.mark.row < -nsaved) |
|
|
629 | { |
|
|
630 | CLEAR_ALL_SELECTION (); |
|
|
631 | selection.op = SELECTION_CLEAR; |
|
|
632 | } |
625 | } |
633 | } |
626 | |
634 | |
627 | for (int i = count; i--; ) |
635 | for (int i = count; i--; ) |
|
|
636 | { |
|
|
637 | ROW(row2 - i).l = 0; |
628 | scr_blank_screen_mem (ROW(row2 - i), rstyle); |
638 | scr_blank_screen_mem (ROW(row2 - i), rstyle); |
|
|
639 | } |
629 | |
640 | |
630 | if ((options & Opt_scrollWithBuffer) |
641 | if ((options & Opt_scrollWithBuffer) |
631 | && view_start != 0 |
642 | && view_start != 0 |
632 | && view_start != saveLines) |
643 | && view_start != saveLines) |
633 | scr_page (UP, count); |
644 | scr_page (UP, count); |
634 | } |
645 | } |
635 | else |
646 | else |
636 | { |
647 | { |
637 | if (selection.op && current_screen == selection.screen) |
648 | if (selection.op && current_screen == selection.screen) |
638 | { |
649 | { |
639 | int i = selection.beg.row; |
650 | if ((selection.beg.row < row1 && selection.end.row > row1) |
640 | int j = selection.end.row; |
651 | || (selection.beg.row < row2 && selection.end.row > row2) |
641 | |
|
|
642 | if ((i < row1 && j > row1) |
|
|
643 | || (i < row2 && j > row2) |
|
|
644 | || (i - count < row1 && i >= row1) |
652 | || (selection.beg.row - count < row1 && selection.beg.row >= row1) |
645 | || (i - count > row2 && i <= row2) |
653 | || (selection.beg.row - count > row2 && selection.beg.row <= row2) |
646 | || (j - count < row1 && j >= row1) |
654 | || (selection.end.row - count < row1 && selection.end.row >= row1) |
647 | || (j - count > row2 && j <= row2)) |
655 | || (selection.end.row - count > row2 && selection.end.row <= row2)) |
648 | { |
656 | { |
649 | CLEAR_ALL_SELECTION (); |
657 | CLEAR_ALL_SELECTION (); |
650 | selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */ |
658 | selection.op = SELECTION_CLEAR; |
651 | } |
659 | } |
652 | else if (j >= row1 && j <= row2) |
660 | else if (selection.end.row >= row1 && selection.end.row <= row2) |
653 | { |
661 | { |
654 | /* move selected region too */ |
662 | /* move selected region too */ |
655 | selection.beg.row -= count; |
663 | selection.beg.row -= count; |
656 | selection.end.row -= count; |
664 | selection.end.row -= count; |
657 | selection.mark.row -= count; |
665 | selection.mark.row -= count; |
… | |
… | |
692 | if (len <= 0) /* sanity */ |
700 | if (len <= 0) /* sanity */ |
693 | return; |
701 | return; |
694 | |
702 | |
695 | unsigned char checksel; |
703 | unsigned char checksel; |
696 | unicode_t c; |
704 | unicode_t c; |
697 | int row, last_col; |
705 | int last_col; |
698 | const unicode_t *strend = str + len; |
706 | const unicode_t *strend = str + len; |
699 | |
707 | |
700 | want_refresh = 1; |
708 | want_refresh = 1; |
701 | ZERO_SCROLLBACK (); |
709 | ZERO_SCROLLBACK (); |
702 | last_col = ncol; |
710 | last_col = ncol; |
… | |
… | |
717 | #ifdef DEBUG_STRICT |
725 | #ifdef DEBUG_STRICT |
718 | assert (screen.cur.col < last_col); |
726 | assert (screen.cur.col < last_col); |
719 | assert (screen.cur.row < nrow |
727 | assert (screen.cur.row < nrow |
720 | && screen.cur.row >= -nsaved); |
728 | && screen.cur.row >= -nsaved); |
721 | #endif |
729 | #endif |
722 | row = screen.cur.row; |
730 | int row = screen.cur.row; |
723 | |
731 | |
724 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
732 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
725 | |
733 | |
726 | line_t *line = &ROW(row); |
734 | line_t *line = &ROW(row); |
727 | |
735 | |
… | |
… | |
729 | { |
737 | { |
730 | c = *str++; |
738 | c = *str++; |
731 | |
739 | |
732 | if (c < 0x20) |
740 | if (c < 0x20) |
733 | if (c == C0_LF) |
741 | if (c == C0_LF) |
734 | { |
742 | { |
735 | if (!line->is_longer ()) /* XXX: think about this */ |
743 | if (!line->is_longer ()) /* XXX: think about this */ |
736 | max_it (line->l, screen.cur.col); |
744 | max_it (line->l, screen.cur.col); |
737 | |
745 | |
738 | screen.flags &= ~Screen_WrapNext; |
746 | screen.flags &= ~Screen_WrapNext; |
739 | |
747 | |
… | |
… | |
984 | |
992 | |
985 | if (count == 0) |
993 | if (count == 0) |
986 | return; |
994 | return; |
987 | else if (count > 0) |
995 | else if (count > 0) |
988 | { |
996 | { |
989 | int row = screen.cur.row; |
|
|
990 | |
|
|
991 | line_t &l = ROW(row); |
997 | line_t &l = ROW(screen.cur.row); |
992 | rend_t base_rend = l.r[i]; |
998 | rend_t base_rend = l.r[i]; |
993 | ht &= l.t[i] == ' '; |
999 | ht &= l.t[i] == ' '; |
994 | |
1000 | |
995 | for (; ++i < ncol; ) |
1001 | for (; ++i < ncol; ) |
996 | if (tabs[i]) |
1002 | if (tabs[i]) |
… | |
… | |
1071 | */ |
1077 | */ |
1072 | #if ENABLE_FRILLS |
1078 | #if ENABLE_FRILLS |
1073 | void |
1079 | void |
1074 | rxvt_term::scr_forwardindex () |
1080 | rxvt_term::scr_forwardindex () |
1075 | { |
1081 | { |
1076 | int row; |
|
|
1077 | |
|
|
1078 | if (screen.cur.col < ncol - 1) |
1082 | if (screen.cur.col < ncol - 1) |
1079 | scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); |
1083 | scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); |
1080 | else |
1084 | else |
1081 | { |
1085 | { |
1082 | row = screen.cur.row; |
|
|
1083 | |
|
|
1084 | if (ROW(row).is_longer ()) //TODO//FIXME//LEN |
1086 | if (ROW(screen.cur.row).is_longer ()) //TODO//FIXME//LEN |
1085 | ROW(row).l = ncol; |
1087 | ROW(screen.cur.row).l = ncol; |
1086 | |
1088 | |
1087 | scr_gotorc (0, 0, R_RELATIVE); |
1089 | scr_gotorc (0, 0, R_RELATIVE); |
1088 | scr_insdel_chars (1, DELETE); |
1090 | scr_insdel_chars (1, DELETE); |
1089 | scr_gotorc (0, ncol - 1, R_RELATIVE); |
1091 | scr_gotorc (0, ncol - 1, R_RELATIVE); |
1090 | } |
1092 | } |
… | |
… | |
1173 | * XTERM_SEQ: Clear whole line : ESC [ 2 K |
1175 | * XTERM_SEQ: Clear whole line : ESC [ 2 K |
1174 | */ |
1176 | */ |
1175 | void |
1177 | void |
1176 | rxvt_term::scr_erase_line (int mode) |
1178 | rxvt_term::scr_erase_line (int mode) |
1177 | { |
1179 | { |
1178 | unsigned int row, col, num; |
1180 | unsigned int col, num; |
1179 | |
1181 | |
1180 | want_refresh = 1; |
1182 | want_refresh = 1; |
1181 | ZERO_SCROLLBACK (); |
1183 | ZERO_SCROLLBACK (); |
1182 | |
1184 | |
1183 | selection_check (1); |
1185 | selection_check (1); |
1184 | |
1186 | |
1185 | row = screen.cur.row; |
1187 | line_t &line = ROW(screen.cur.row); |
1186 | |
1188 | |
1187 | switch (mode) |
1189 | switch (mode) |
1188 | { |
1190 | { |
1189 | case 0: /* erase to end of line */ |
1191 | case 0: /* erase to end of line */ |
1190 | col = screen.cur.col; |
1192 | col = screen.cur.col; |
1191 | num = ncol - col; |
1193 | num = ncol - col; |
1192 | min_it (ROW(row).l, col); |
1194 | min_it (line.l, col); |
1193 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1195 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1194 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1196 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1195 | CLEAR_SELECTION (); |
1197 | CLEAR_SELECTION (); |
1196 | break; |
1198 | break; |
1197 | case 1: /* erase to beginning of line */ |
1199 | case 1: /* erase to beginning of line */ |
… | |
… | |
1202 | CLEAR_SELECTION (); |
1204 | CLEAR_SELECTION (); |
1203 | break; |
1205 | break; |
1204 | case 2: /* erase whole line */ |
1206 | case 2: /* erase whole line */ |
1205 | col = 0; |
1207 | col = 0; |
1206 | num = ncol; |
1208 | num = ncol; |
1207 | ROW(row).l = 0; |
1209 | line.l = 0; |
1208 | if (selection.beg.row <= screen.cur.row |
1210 | if (selection.beg.row <= screen.cur.row |
1209 | && selection.end.row >= screen.cur.row) |
1211 | && selection.end.row >= screen.cur.row) |
1210 | CLEAR_SELECTION (); |
1212 | CLEAR_SELECTION (); |
1211 | break; |
1213 | break; |
1212 | default: |
1214 | default: |
1213 | return; |
1215 | return; |
1214 | } |
1216 | } |
1215 | |
1217 | |
1216 | scr_blank_line (ROW(row), col, num, rstyle); |
1218 | scr_blank_line (line, col, num, rstyle); |
1217 | } |
1219 | } |
1218 | |
1220 | |
1219 | /* ------------------------------------------------------------------------- */ |
1221 | /* ------------------------------------------------------------------------- */ |
1220 | /* |
1222 | /* |
1221 | * Erase part of whole of the screen |
1223 | * Erase part of whole of the screen |
… | |
… | |
1285 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1287 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1286 | } |
1288 | } |
1287 | |
1289 | |
1288 | for (; num--; row++) |
1290 | for (; num--; row++) |
1289 | { |
1291 | { |
|
|
1292 | ROW (row).l = 0; |
1290 | scr_blank_screen_mem (ROW (row), rstyle); |
1293 | scr_blank_screen_mem (ROW (row), rstyle); |
1291 | ROW (row).l = 0; |
|
|
1292 | scr_blank_line (drawn_buf [row], 0, ncol, ren); |
1294 | scr_blank_line (drawn_buf [row], 0, ncol, ren); |
1293 | } |
1295 | } |
1294 | } |
1296 | } |
1295 | |
1297 | |
1296 | #if ENABLE_FRILLS |
1298 | #if ENABLE_FRILLS |
… | |
… | |
2454 | row = selection.beg.row; |
2456 | row = selection.beg.row; |
2455 | } |
2457 | } |
2456 | else |
2458 | else |
2457 | { |
2459 | { |
2458 | col = 0; |
2460 | col = 0; |
2459 | row = view_start; |
2461 | row = -view_start; |
2460 | } |
2462 | } |
2461 | |
2463 | |
2462 | for (; row < min (selection.end.row, view_end); row++, col = 0) |
2464 | for (; row < min (selection.end.row, view_end); row++, col = 0) |
2463 | for (rend_t *srp = ROW(row).r; col < ncol; col++) |
2465 | for (rend_t *srp = ROW(row).r; col < ncol; col++) |
2464 | srp[col] ^= RS_RVid; |
2466 | srp[col] ^= RS_RVid; |