1 | /*--------------------------------*-C-*--------------------------------------* |
1 | /*--------------------------------*-C-*--------------------------------------* |
2 | * File: screen.c |
2 | * File: screen.C |
3 | *---------------------------------------------------------------------------* |
3 | *---------------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> |
5 | * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> |
6 | * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> |
7 | * |
7 | * |
… | |
… | |
511 | s->s_cur.col = s->cur.col; |
511 | s->s_cur.col = s->cur.col; |
512 | s->s_rstyle = rstyle; |
512 | s->s_rstyle = rstyle; |
513 | s->s_charset = s->charset; |
513 | s->s_charset = s->charset; |
514 | s->s_charset_char = charsets[s->charset]; |
514 | s->s_charset_char = charsets[s->charset]; |
515 | break; |
515 | break; |
|
|
516 | |
516 | case RESTORE: |
517 | case RESTORE: |
517 | want_refresh = 1; |
518 | want_refresh = 1; |
518 | s->cur.row = s->s_cur.row; |
519 | s->cur.row = s->s_cur.row; |
519 | s->cur.col = s->s_cur.col; |
520 | s->cur.col = s->s_cur.col; |
520 | s->flags &= ~Screen_WrapNext; |
521 | s->flags &= ~Screen_WrapNext; |
… | |
… | |
810 | c = *str++; |
811 | c = *str++; |
811 | |
812 | |
812 | if (c < 0x20) |
813 | if (c < 0x20) |
813 | switch (c) |
814 | switch (c) |
814 | { |
815 | { |
815 | case '\t': |
816 | case C0_HT: |
816 | scr_tab (1); |
817 | scr_tab (1); |
817 | continue; |
818 | continue; |
818 | |
819 | |
819 | case '\n': |
820 | case C0_LF: |
820 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
821 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
821 | MAX_IT (screen.tlen[row], screen.cur.col); |
822 | MAX_IT (screen.tlen[row], screen.cur.col); |
822 | |
823 | |
823 | screen.flags &= ~Screen_WrapNext; |
824 | screen.flags &= ~Screen_WrapNext; |
824 | |
825 | |
… | |
… | |
829 | |
830 | |
830 | stp = screen.text[row]; /* _must_ refresh */ |
831 | stp = screen.text[row]; /* _must_ refresh */ |
831 | srp = screen.rend[row]; /* _must_ refresh */ |
832 | srp = screen.rend[row]; /* _must_ refresh */ |
832 | continue; |
833 | continue; |
833 | |
834 | |
834 | case '\r': |
835 | case C0_CR: |
835 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
836 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
836 | MAX_IT (screen.tlen[row], screen.cur.col); |
837 | MAX_IT (screen.tlen[row], screen.cur.col); |
837 | |
838 | |
838 | screen.flags &= ~Screen_WrapNext; |
839 | screen.flags &= ~Screen_WrapNext; |
839 | screen.cur.col = 0; |
840 | screen.cur.col = 0; |
… | |
… | |
987 | */ |
988 | */ |
988 | void |
989 | void |
989 | rxvt_term::scr_backspace () |
990 | rxvt_term::scr_backspace () |
990 | { |
991 | { |
991 | want_refresh = 1; |
992 | want_refresh = 1; |
|
|
993 | |
992 | if (screen.cur.col == 0) |
994 | if (screen.cur.col == 0) |
993 | { |
995 | { |
994 | if (screen.cur.row > 0) |
996 | if (screen.cur.row > 0) |
995 | { |
997 | { |
996 | #ifdef TERMCAP_HAS_BW |
998 | #ifdef TERMCAP_HAS_BW |
… | |
… | |
1001 | |
1003 | |
1002 | } |
1004 | } |
1003 | } |
1005 | } |
1004 | else if ((screen.flags & Screen_WrapNext) == 0) |
1006 | else if ((screen.flags & Screen_WrapNext) == 0) |
1005 | scr_gotorc (0, -1, RELATIVE); |
1007 | scr_gotorc (0, -1, RELATIVE); |
|
|
1008 | |
1006 | screen.flags &= ~Screen_WrapNext; |
1009 | screen.flags &= ~Screen_WrapNext; |
1007 | } |
1010 | } |
1008 | |
1011 | |
1009 | /* ------------------------------------------------------------------------- */ |
1012 | /* ------------------------------------------------------------------------- */ |
1010 | /* |
1013 | /* |
… | |
… | |
1114 | want_refresh = 1; |
1117 | want_refresh = 1; |
1115 | ZERO_SCROLLBACK (); |
1118 | ZERO_SCROLLBACK (); |
1116 | |
1119 | |
1117 | D_SCREEN ((stderr, "rxvt_scr_gotorc (r:%s%d,c:%s%d): from (r:%d,c:%d)", (relative & R_RELATIVE ? "+" : ""), row, (relative & C_RELATIVE ? "+" : ""), col, screen.cur.row, screen.cur.col)); |
1120 | D_SCREEN ((stderr, "rxvt_scr_gotorc (r:%s%d,c:%s%d): from (r:%d,c:%d)", (relative & R_RELATIVE ? "+" : ""), row, (relative & C_RELATIVE ? "+" : ""), col, screen.cur.row, screen.cur.col)); |
1118 | |
1121 | |
1119 | screen.cur.col = ((relative & C_RELATIVE) ? (screen.cur.col + col) |
1122 | screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; |
1120 | : col); |
|
|
1121 | MAX_IT (screen.cur.col, 0); |
1123 | MAX_IT (screen.cur.col, 0); |
1122 | MIN_IT (screen.cur.col, (int32_t)TermWin.ncol - 1); |
1124 | MIN_IT (screen.cur.col, (int32_t)TermWin.ncol - 1); |
1123 | |
1125 | |
1124 | screen.flags &= ~Screen_WrapNext; |
1126 | screen.flags &= ~Screen_WrapNext; |
1125 | if (relative & R_RELATIVE) |
1127 | if (relative & R_RELATIVE) |
… | |
… | |
1164 | * direction should be UP or DN |
1166 | * direction should be UP or DN |
1165 | */ |
1167 | */ |
1166 | void |
1168 | void |
1167 | rxvt_term::scr_index (enum page_dirn direction) |
1169 | rxvt_term::scr_index (enum page_dirn direction) |
1168 | { |
1170 | { |
1169 | int dirn; |
1171 | int dirn; |
1170 | |
1172 | |
1171 | want_refresh = 1; |
1173 | want_refresh = 1; |
1172 | dirn = ((direction == UP) ? 1 : -1); |
1174 | dirn = ((direction == UP) ? 1 : -1); |
1173 | D_SCREEN ((stderr, "rxvt_scr_index (%d)", dirn)); |
1175 | D_SCREEN ((stderr, "rxvt_scr_index (%d)", dirn)); |
1174 | |
1176 | |
… | |
… | |
1517 | */ |
1519 | */ |
1518 | void |
1520 | void |
1519 | rxvt_term::scr_cursor_visible (int mode) |
1521 | rxvt_term::scr_cursor_visible (int mode) |
1520 | { |
1522 | { |
1521 | want_refresh = 1; |
1523 | want_refresh = 1; |
|
|
1524 | |
1522 | if (mode) |
1525 | if (mode) |
1523 | screen.flags |= Screen_VisibleCursor; |
1526 | screen.flags |= Screen_VisibleCursor; |
1524 | else |
1527 | else |
1525 | screen.flags &= ~Screen_VisibleCursor; |
1528 | screen.flags &= ~Screen_VisibleCursor; |
1526 | } |
1529 | } |
… | |
… | |
1842 | if (TermWin.view_start != oldviewstart) |
1845 | if (TermWin.view_start != oldviewstart) |
1843 | { |
1846 | { |
1844 | want_refresh = 1; |
1847 | want_refresh = 1; |
1845 | num_scr -= (TermWin.view_start - oldviewstart); |
1848 | num_scr -= (TermWin.view_start - oldviewstart); |
1846 | } |
1849 | } |
|
|
1850 | |
1847 | return (int) (TermWin.view_start - oldviewstart); |
1851 | return (int) (TermWin.view_start - oldviewstart); |
1848 | } |
1852 | } |
1849 | |
1853 | |
1850 | /* ------------------------------------------------------------------------- */ |
1854 | /* ------------------------------------------------------------------------- */ |
1851 | void |
1855 | void |
… | |
… | |
2517 | { |
2521 | { |
2518 | n = min (len - i, PROP_SIZE); |
2522 | n = min (len - i, PROP_SIZE); |
2519 | MEMCPY (ds, data + i, n); |
2523 | MEMCPY (ds, data + i, n); |
2520 | |
2524 | |
2521 | for (j = 0; j < n; j++) |
2525 | for (j = 0; j < n; j++) |
2522 | if (ds[j] == '\n') |
2526 | if (ds[j] == C0_LF) |
2523 | ds[j] = '\r'; |
2527 | ds[j] = C0_CR; |
2524 | |
2528 | |
2525 | tt_write (ds, (int)n); |
2529 | tt_write (ds, (int)n); |
2526 | } |
2530 | } |
2527 | |
2531 | |
2528 | free (ds); |
2532 | free (ds); |
… | |
… | |
2879 | else |
2883 | else |
2880 | new_selection_text[ofs++] = *t++; |
2884 | new_selection_text[ofs++] = *t++; |
2881 | } |
2885 | } |
2882 | |
2886 | |
2883 | if (screen.tlen[row] != -1 && row != end_row) |
2887 | if (screen.tlen[row] != -1 && row != end_row) |
2884 | new_selection_text[ofs++] = L'\n'; |
2888 | new_selection_text[ofs++] = C0_LF; |
2885 | } |
2889 | } |
2886 | |
2890 | |
2887 | if (end_col != selection.end.col) |
2891 | if (end_col != selection.end.col) |
2888 | new_selection_text[ofs++] = L'\n'; |
2892 | new_selection_text[ofs++] = C0_LF; |
2889 | |
2893 | |
2890 | new_selection_text[ofs] = 0; |
2894 | new_selection_text[ofs] = 0; |
2891 | |
2895 | |
2892 | if (ofs == 0) |
2896 | if (ofs == 0) |
2893 | { |
2897 | { |
… | |
… | |
3120 | * Extend the selection to the specified col/row |
3124 | * Extend the selection to the specified col/row |
3121 | */ |
3125 | */ |
3122 | void |
3126 | void |
3123 | rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) |
3127 | rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) |
3124 | { |
3128 | { |
3125 | int16_t ncol = TermWin.ncol; |
3129 | int16_t ncol = TermWin.ncol; |
3126 | int end_col; |
3130 | int end_col; |
3127 | row_col_t pos; |
3131 | row_col_t pos; |
3128 | enum { |
3132 | enum { |
3129 | LEFT, RIGHT |
3133 | LEFT, RIGHT |
3130 | } closeto = RIGHT; |
3134 | } closeto = RIGHT; |
3131 | |
3135 | |
3132 | D_SELECT ((stderr, "rxvt_selection_extend_colrow (c:%d, r:%d, %d, %d) clicks:%d, op:%d", col, row, button3, buttonpress, selection.clicks, selection.op)); |
3136 | D_SELECT ((stderr, "rxvt_selection_extend_colrow (c:%d, r:%d, %d, %d) clicks:%d, op:%d", col, row, button3, buttonpress, selection.clicks, selection.op)); |