… | |
… | |
280 | if (nsaved) |
280 | if (nsaved) |
281 | { |
281 | { |
282 | // re-wrap lines, this is rather ugly, possibly because I am too dumb |
282 | // re-wrap lines, this is rather ugly, possibly because I am too dumb |
283 | // to come up with a lean and mean algorithm. |
283 | // to come up with a lean and mean algorithm. |
284 | |
284 | |
285 | while (p != pend && q > 0) |
285 | row_col_t ocur = screen.cur; |
|
|
286 | ocur.row = MOD (term_start + ocur.row, prev_total_rows); |
|
|
287 | |
|
|
288 | do |
286 | { |
289 | { |
287 | p = MOD (p - 1, prev_total_rows); |
290 | p = MOD (p - 1, prev_total_rows); |
288 | #ifdef DEBUG_STRICT |
291 | #ifdef DEBUG_STRICT |
289 | assert (old_buf [MOD (p, prev_total_rows)].t); |
292 | assert (old_buf [MOD (p, prev_total_rows)].t); |
290 | #endif |
293 | #endif |
291 | |
294 | |
|
|
295 | int plines = 1; |
292 | int llen = old_buf [MOD (p, prev_total_rows)].l; |
296 | int llen = old_buf [MOD (p, prev_total_rows)].l; |
293 | |
297 | |
294 | while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ()) |
298 | while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ()) |
295 | { |
299 | { |
296 | p = MOD (p - 1, prev_total_rows); |
300 | p = MOD (p - 1, prev_total_rows); |
297 | |
301 | |
|
|
302 | plines++; |
298 | llen += prev_ncol; |
303 | llen += prev_ncol; |
299 | } |
304 | } |
300 | |
305 | |
301 | int qlines = max (0, (llen - 1) / ncol) + 1; |
306 | int qlines = max (0, (llen - 1) / ncol) + 1; |
302 | |
307 | |
… | |
… | |
322 | while (lofs < llen && qcol < ncol) |
327 | while (lofs < llen && qcol < ncol) |
323 | { |
328 | { |
324 | int prow = lofs / prev_ncol; |
329 | int prow = lofs / prev_ncol; |
325 | int pcol = lofs % prev_ncol; |
330 | int pcol = lofs % prev_ncol; |
326 | |
331 | |
327 | line_t &pline = old_buf [MOD (p + prow, prev_total_rows)]; |
332 | prow = MOD (p + prow, prev_total_rows); |
|
|
333 | |
|
|
334 | // we only adjust the cursor _row_ and put it into |
|
|
335 | // the topmost line of "long line" it was in, as |
|
|
336 | // this seems to upset applications/shells/readline |
|
|
337 | // least. |
|
|
338 | if (prow == ocur.row) |
|
|
339 | screen.cur.row = q - (total_rows - nrow); |
|
|
340 | |
|
|
341 | line_t &pline = old_buf [prow]; |
328 | |
342 | |
329 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
343 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
330 | |
344 | |
331 | assert (len); |
345 | assert (len); |
332 | assert (pline.t); |
346 | assert (pline.t); |
… | |
… | |
340 | } |
354 | } |
341 | |
355 | |
342 | qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1; |
356 | qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1; |
343 | scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); |
357 | scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); |
344 | } |
358 | } |
|
|
359 | while (p != pend && q > 0); |
345 | |
360 | |
346 | term_start = total_rows - nrow; |
361 | term_start = total_rows - nrow; |
347 | view_start = 0; |
|
|
348 | nsaved = term_start - q; |
362 | nsaved = term_start - q; |
349 | |
363 | |
350 | // make sure all terminal lines exist |
364 | // make sure all terminal lines exist |
351 | while (nsaved < 0) |
365 | while (nsaved < 0) |
352 | scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE); |
366 | scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE); |
… | |
… | |
369 | { |
383 | { |
370 | row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); |
384 | row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); |
371 | } |
385 | } |
372 | |
386 | |
373 | term_start = 0; |
387 | term_start = 0; |
374 | view_start = 0; |
|
|
375 | } |
388 | } |
376 | |
389 | |
377 | #ifdef DEBUG_STRICT |
390 | #ifdef DEBUG_STRICT //TODO: remove |
378 | for (int i = -nsaved; i < nrow; i++) |
391 | for (int i = -nsaved; i < nrow; i++) |
379 | assert (ROW (i).t); |
392 | assert (ROW (i).t); |
380 | #endif |
393 | #endif |
381 | |
394 | |
382 | free (old_buf); |
395 | free (old_buf); |
… | |
… | |
607 | { |
620 | { |
608 | selection.beg.row -= count; |
621 | selection.beg.row -= count; |
609 | selection.end.row -= count; |
622 | selection.end.row -= count; |
610 | selection.mark.row -= count; |
623 | selection.mark.row -= count; |
611 | |
624 | |
612 | selection_check (0); |
625 | if (selection.beg.row < -nsaved |
|
|
626 | || selection.end.row < -nsaved |
|
|
627 | || selection.mark.row < -nsaved) |
|
|
628 | { |
|
|
629 | CLEAR_ALL_SELECTION (); |
|
|
630 | selection.op = SELECTION_CLEAR; |
|
|
631 | } |
613 | } |
632 | } |
614 | |
633 | |
615 | for (int i = count; i--; ) |
634 | for (int i = count; i--; ) |
616 | scr_blank_screen_mem (ROW(row2 - i), rstyle); |
635 | scr_blank_screen_mem (ROW(row2 - i), rstyle); |
617 | |
636 | |
… | |
… | |
622 | } |
641 | } |
623 | else |
642 | else |
624 | { |
643 | { |
625 | if (selection.op && current_screen == selection.screen) |
644 | if (selection.op && current_screen == selection.screen) |
626 | { |
645 | { |
627 | int i = selection.beg.row; |
646 | if ((selection.beg.row < row1 && selection.end.row > row1) |
628 | int j = selection.end.row; |
647 | || (selection.beg.row < row2 && selection.end.row > row2) |
629 | |
|
|
630 | if ((i < row1 && j > row1) |
|
|
631 | || (i < row2 && j > row2) |
|
|
632 | || (i - count < row1 && i >= row1) |
648 | || (selection.beg.row - count < row1 && selection.beg.row >= row1) |
633 | || (i - count > row2 && i <= row2) |
649 | || (selection.beg.row - count > row2 && selection.beg.row <= row2) |
634 | || (j - count < row1 && j >= row1) |
650 | || (selection.end.row - count < row1 && selection.end.row >= row1) |
635 | || (j - count > row2 && j <= row2)) |
651 | || (selection.end.row - count > row2 && selection.end.row <= row2)) |
636 | { |
652 | { |
637 | CLEAR_ALL_SELECTION (); |
653 | CLEAR_ALL_SELECTION (); |
638 | selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */ |
654 | selection.op = SELECTION_CLEAR; |
639 | } |
655 | } |
640 | else if (j >= row1 && j <= row2) |
656 | else if (selection.end.row >= row1 && selection.end.row <= row2) |
641 | { |
657 | { |
642 | /* move selected region too */ |
658 | /* move selected region too */ |
643 | selection.beg.row -= count; |
659 | selection.beg.row -= count; |
644 | selection.end.row -= count; |
660 | selection.end.row -= count; |
645 | selection.mark.row -= count; |
661 | selection.mark.row -= count; |
… | |
… | |
680 | if (len <= 0) /* sanity */ |
696 | if (len <= 0) /* sanity */ |
681 | return; |
697 | return; |
682 | |
698 | |
683 | unsigned char checksel; |
699 | unsigned char checksel; |
684 | unicode_t c; |
700 | unicode_t c; |
685 | int row, last_col; |
701 | int last_col; |
686 | const unicode_t *strend = str + len; |
702 | const unicode_t *strend = str + len; |
687 | |
703 | |
688 | want_refresh = 1; |
704 | want_refresh = 1; |
689 | ZERO_SCROLLBACK (); |
705 | ZERO_SCROLLBACK (); |
690 | last_col = ncol; |
706 | last_col = ncol; |
… | |
… | |
705 | #ifdef DEBUG_STRICT |
721 | #ifdef DEBUG_STRICT |
706 | assert (screen.cur.col < last_col); |
722 | assert (screen.cur.col < last_col); |
707 | assert (screen.cur.row < nrow |
723 | assert (screen.cur.row < nrow |
708 | && screen.cur.row >= -nsaved); |
724 | && screen.cur.row >= -nsaved); |
709 | #endif |
725 | #endif |
710 | row = screen.cur.row; |
726 | int row = screen.cur.row; |
711 | |
727 | |
712 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
728 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
713 | |
729 | |
714 | line_t *line = &ROW(row); |
730 | line_t *line = &ROW(row); |
715 | |
731 | |
… | |
… | |
972 | |
988 | |
973 | if (count == 0) |
989 | if (count == 0) |
974 | return; |
990 | return; |
975 | else if (count > 0) |
991 | else if (count > 0) |
976 | { |
992 | { |
977 | int row = screen.cur.row; |
|
|
978 | |
|
|
979 | line_t &l = ROW(row); |
993 | line_t &l = ROW(screen.cur.row); |
980 | rend_t base_rend = l.r[i]; |
994 | rend_t base_rend = l.r[i]; |
981 | ht &= l.t[i] == ' '; |
995 | ht &= l.t[i] == ' '; |
982 | |
996 | |
983 | for (; ++i < ncol; ) |
997 | for (; ++i < ncol; ) |
984 | if (tabs[i]) |
998 | if (tabs[i]) |
… | |
… | |
1059 | */ |
1073 | */ |
1060 | #if ENABLE_FRILLS |
1074 | #if ENABLE_FRILLS |
1061 | void |
1075 | void |
1062 | rxvt_term::scr_forwardindex () |
1076 | rxvt_term::scr_forwardindex () |
1063 | { |
1077 | { |
1064 | int row; |
|
|
1065 | |
|
|
1066 | if (screen.cur.col < ncol - 1) |
1078 | if (screen.cur.col < ncol - 1) |
1067 | scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); |
1079 | scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); |
1068 | else |
1080 | else |
1069 | { |
1081 | { |
1070 | row = screen.cur.row; |
|
|
1071 | |
|
|
1072 | if (ROW(row).is_longer ()) //TODO//FIXME//LEN |
1082 | if (ROW(screen.cur.row).is_longer ()) //TODO//FIXME//LEN |
1073 | ROW(row).l = ncol; |
1083 | ROW(screen.cur.row).l = ncol; |
1074 | |
1084 | |
1075 | scr_gotorc (0, 0, R_RELATIVE); |
1085 | scr_gotorc (0, 0, R_RELATIVE); |
1076 | scr_insdel_chars (1, DELETE); |
1086 | scr_insdel_chars (1, DELETE); |
1077 | scr_gotorc (0, ncol - 1, R_RELATIVE); |
1087 | scr_gotorc (0, ncol - 1, R_RELATIVE); |
1078 | } |
1088 | } |
… | |
… | |
1161 | * XTERM_SEQ: Clear whole line : ESC [ 2 K |
1171 | * XTERM_SEQ: Clear whole line : ESC [ 2 K |
1162 | */ |
1172 | */ |
1163 | void |
1173 | void |
1164 | rxvt_term::scr_erase_line (int mode) |
1174 | rxvt_term::scr_erase_line (int mode) |
1165 | { |
1175 | { |
1166 | unsigned int row, col, num; |
1176 | unsigned int col, num; |
1167 | |
1177 | |
1168 | want_refresh = 1; |
1178 | want_refresh = 1; |
1169 | ZERO_SCROLLBACK (); |
1179 | ZERO_SCROLLBACK (); |
1170 | |
1180 | |
1171 | selection_check (1); |
1181 | selection_check (1); |
1172 | |
1182 | |
1173 | row = screen.cur.row; |
1183 | line_t &line = ROW(screen.cur.row); |
1174 | |
1184 | |
1175 | switch (mode) |
1185 | switch (mode) |
1176 | { |
1186 | { |
1177 | case 0: /* erase to end of line */ |
1187 | case 0: /* erase to end of line */ |
1178 | col = screen.cur.col; |
1188 | col = screen.cur.col; |
1179 | num = ncol - col; |
1189 | num = ncol - col; |
1180 | min_it (ROW(row).l, col); |
1190 | min_it (line.l, col); |
1181 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1191 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1182 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1192 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1183 | CLEAR_SELECTION (); |
1193 | CLEAR_SELECTION (); |
1184 | break; |
1194 | break; |
1185 | case 1: /* erase to beginning of line */ |
1195 | case 1: /* erase to beginning of line */ |
… | |
… | |
1190 | CLEAR_SELECTION (); |
1200 | CLEAR_SELECTION (); |
1191 | break; |
1201 | break; |
1192 | case 2: /* erase whole line */ |
1202 | case 2: /* erase whole line */ |
1193 | col = 0; |
1203 | col = 0; |
1194 | num = ncol; |
1204 | num = ncol; |
1195 | ROW(row).l = 0; |
1205 | line.l = 0; |
1196 | if (selection.beg.row <= screen.cur.row |
1206 | if (selection.beg.row <= screen.cur.row |
1197 | && selection.end.row >= screen.cur.row) |
1207 | && selection.end.row >= screen.cur.row) |
1198 | CLEAR_SELECTION (); |
1208 | CLEAR_SELECTION (); |
1199 | break; |
1209 | break; |
1200 | default: |
1210 | default: |
1201 | return; |
1211 | return; |
1202 | } |
1212 | } |
1203 | |
1213 | |
1204 | scr_blank_line (ROW(row), col, num, rstyle); |
1214 | scr_blank_line (line, col, num, rstyle); |
1205 | } |
1215 | } |
1206 | |
1216 | |
1207 | /* ------------------------------------------------------------------------- */ |
1217 | /* ------------------------------------------------------------------------- */ |
1208 | /* |
1218 | /* |
1209 | * Erase part of whole of the screen |
1219 | * Erase part of whole of the screen |