… | |
… | |
762 | /* ------------------------------------------------------------------------- */ |
762 | /* ------------------------------------------------------------------------- */ |
763 | /* |
763 | /* |
764 | * Add text given in <str> of length <len> to screen struct |
764 | * Add text given in <str> of length <len> to screen struct |
765 | */ |
765 | */ |
766 | void |
766 | void |
767 | rxvt_term::scr_add_lines (const uint32_t *str, int nlines, int len) |
767 | rxvt_term::scr_add_lines (const unicode_t *str, int nlines, int len) |
768 | { |
768 | { |
769 | unsigned char checksel, clearsel; |
769 | unsigned char checksel, clearsel; |
770 | uint32_t c; |
770 | unicode_t c; |
771 | int i, row, last_col; |
771 | int i, row, last_col; |
772 | text_t *stp; |
772 | text_t *stp; |
773 | rend_t *srp; |
773 | rend_t *srp; |
774 | |
774 | |
775 | if (len <= 0) /* sanity */ |
775 | if (len <= 0) /* sanity */ |
… | |
… | |
864 | } |
864 | } |
865 | |
865 | |
866 | if (screen.flags & Screen_Insert) |
866 | if (screen.flags & Screen_Insert) |
867 | scr_insdel_chars (1, INSERT); |
867 | scr_insdel_chars (1, INSERT); |
868 | |
868 | |
869 | if (IS_COMPOSE (c)) |
|
|
870 | c = REPLACEMENT_CHAR; |
|
|
871 | |
|
|
872 | // rely on wcwidth to tell us the character width, at least for non-latin1 |
869 | // rely on wcwidth to tell us the character width, at least for non-latin1 |
873 | // do wcwidth before further replacements, as wcwidth says that line-drawing |
870 | // do wcwidth before further replacements, as wcwidth says that line-drawing |
874 | // characters have width -1 (DOH!) on gnu/linux sometimes. |
871 | // characters have width -1 (DOH!) on gnu/linux sometimes. |
875 | int width = c < 256 ? 1 : wcwidth (c); |
872 | int width = c < 256 ? 1 : wcwidth (c); |
876 | |
873 | |
… | |
… | |
888 | case 's': c = 0x23bd; break; case 't': c = 0x251c; break; case 'u': c = 0x2524; break; |
885 | case 's': c = 0x23bd; break; case 't': c = 0x251c; break; case 'u': c = 0x2524; break; |
889 | case 'v': c = 0x2534; break; case 'w': c = 0x252c; break; case 'x': c = 0x2502; break; |
886 | case 'v': c = 0x2534; break; case 'w': c = 0x252c; break; case 'x': c = 0x2502; break; |
890 | case 'y': c = 0x2264; break; case 'z': c = 0x2265; break; case '{': c = 0x03c0; break; |
887 | case 'y': c = 0x2264; break; case 'z': c = 0x2265; break; case '{': c = 0x03c0; break; |
891 | case '|': c = 0x2260; break; case '}': c = 0x00a3; break; case '~': c = 0x00b7; break; |
888 | case '|': c = 0x2260; break; case '}': c = 0x00a3; break; case '~': c = 0x00b7; break; |
892 | } |
889 | } |
893 | |
|
|
894 | |
890 | |
895 | if (width > 0) |
891 | if (width > 0) |
896 | { |
892 | { |
897 | #if !UNICODE_3 |
893 | #if !UNICODE_3 && ENABLE_COMBINING |
898 | // trim characters we can't store directly :( |
894 | // trim characters we can't store directly :( |
899 | if (c >= 0x10000) |
895 | if (c >= 0x10000) |
900 | c = rxvt_composite.compose (c); // map to lower 16 bits |
896 | c = rxvt_composite.compose (c); // map to lower 16 bits |
901 | #endif |
897 | #endif |
902 | rend_t rend = SET_FONT (rstyle, TermWin.fontset->find_font (c)); |
898 | rend_t rend = SET_FONT (rstyle, TermWin.fontset->find_font (c)); |
… | |
… | |
927 | srp[c] = rend; |
923 | srp[c] = rend; |
928 | } |
924 | } |
929 | } |
925 | } |
930 | else if (width == 0) |
926 | else if (width == 0) |
931 | { |
927 | { |
932 | #if ENCODING_COMPOSE |
928 | #if ENABLE_COMBINING |
933 | // handle combining characters |
929 | // handle combining characters |
934 | // we just tag the accent on the previous on-screen character. |
930 | // we just tag the accent on the previous on-screen character. |
935 | // this is arguably not correct, but also arguably not wrong. |
931 | // this is arguably not correct, but also arguably not wrong. |
936 | // we don't handle double-width characters nicely yet. |
932 | // we don't handle double-width characters nicely yet. |
937 | |
933 | |
… | |
… | |
955 | // handle double-width-chars by making them look extremely ugly |
951 | // handle double-width-chars by making them look extremely ugly |
956 | if (*tp == NOCHAR) |
952 | if (*tp == NOCHAR) |
957 | *tp = ' '; // hack //D //TODO //--tp, --rp; |
953 | *tp = ' '; // hack //D //TODO //--tp, --rp; |
958 | |
954 | |
959 | // first try to find a precomposed character |
955 | // first try to find a precomposed character |
960 | uint32_t n = rxvt_compose (*tp, c); |
956 | unicode_t n = rxvt_compose (*tp, c); |
961 | if (n == NOCHAR) |
957 | if (n == NOCHAR) |
962 | n = rxvt_composite.compose (*tp, c); |
958 | n = rxvt_composite.compose (*tp, c); |
963 | |
959 | |
964 | *tp = n; |
960 | *tp = n; |
965 | *rp = SET_FONT (*rp, TermWin.fontset->find_font (*tp)); |
961 | *rp = SET_FONT (*rp, TermWin.fontset->find_font (*tp)); |
… | |
… | |
2192 | else |
2188 | else |
2193 | rvid = !rvid; |
2189 | rvid = !rvid; |
2194 | } |
2190 | } |
2195 | |
2191 | |
2196 | if (rend & RS_Uline) |
2192 | if (rend & RS_Uline) |
2197 | { |
|
|
2198 | if (ISSET_PIXCOLOR (Color_UL)) |
2193 | if (ISSET_PIXCOLOR (Color_UL)) |
2199 | fore = Color_UL; |
2194 | fore = Color_UL; |
2200 | } |
|
|
2201 | #endif |
2195 | #endif |
2202 | |
2196 | |
2203 | if (rvid) |
2197 | if (rvid) |
2204 | { |
2198 | { |
2205 | SWAP_IT (fore, back, int); |
2199 | SWAP_IT (fore, back, int); |
… | |
… | |
2838 | |
2832 | |
2839 | for (; col < end_col; col++) |
2833 | for (; col < end_col; col++) |
2840 | { |
2834 | { |
2841 | if (*t == NOCHAR) |
2835 | if (*t == NOCHAR) |
2842 | t++; |
2836 | t++; |
|
|
2837 | #if ENABLE_COMBINING |
2843 | else if (IS_COMPOSE (*t)) |
2838 | else if (IS_COMPOSE (*t)) |
2844 | { |
2839 | { |
2845 | int len = rxvt_composite.expand (*t, 0); |
2840 | int len = rxvt_composite.expand (*t, 0); |
2846 | |
2841 | |
2847 | extra -= (len - 1); |
2842 | extra -= (len - 1); |
… | |
… | |
2853 | new_selection_text = (wchar_t *)rxvt_realloc (new_selection_text, (i + 4) * sizeof (wchar_t)); |
2848 | new_selection_text = (wchar_t *)rxvt_realloc (new_selection_text, (i + 4) * sizeof (wchar_t)); |
2854 | } |
2849 | } |
2855 | |
2850 | |
2856 | ofs += rxvt_composite.expand (*t++, new_selection_text + ofs); |
2851 | ofs += rxvt_composite.expand (*t++, new_selection_text + ofs); |
2857 | } |
2852 | } |
|
|
2853 | #endif |
2858 | else |
2854 | else |
2859 | new_selection_text[ofs++] = *t++; |
2855 | new_selection_text[ofs++] = *t++; |
2860 | } |
2856 | } |
2861 | |
2857 | |
2862 | if (screen.tlen[row] != -1 && row != end_row) |
2858 | if (screen.tlen[row] != -1 && row != end_row) |
2863 | new_selection_text[ofs++] = L'\n'; |
2859 | new_selection_text[ofs++] = L'\n'; |
2864 | } |
2860 | } |
2865 | |
2861 | |
2866 | #ifndef NO_OLD_SELECTION |
2862 | if (end_col != selection.end.col) |
2867 | if (selection_style == OLD_SELECT) |
|
|
2868 | if (end_col == TermWin.ncol) |
|
|
2869 | new_selection_text[ofs++] = L'\n'; |
2863 | new_selection_text[ofs++] = L'\n'; |
2870 | #endif |
2864 | |
2871 | #ifndef NO_NEW_SELECTION |
|
|
2872 | if (selection_style != OLD_SELECT) |
|
|
2873 | if (end_col != selection.end.col) |
|
|
2874 | new_selection_text[ofs++] = L'\n'; |
|
|
2875 | #endif |
|
|
2876 | new_selection_text[ofs] = 0; |
2865 | new_selection_text[ofs] = 0; |
2877 | |
2866 | |
2878 | if (ofs == 0) |
2867 | if (ofs == 0) |
2879 | { |
2868 | { |
2880 | free (new_selection_text); |
2869 | free (new_selection_text); |
… | |
… | |
2939 | rxvt_term::selection_start_colrow (int col, int row) |
2928 | rxvt_term::selection_start_colrow (int col, int row) |
2940 | { |
2929 | { |
2941 | want_refresh = 1; |
2930 | want_refresh = 1; |
2942 | selection.mark.col = col; |
2931 | selection.mark.col = col; |
2943 | selection.mark.row = row - TermWin.view_start; |
2932 | selection.mark.row = row - TermWin.view_start; |
|
|
2933 | |
2944 | MAX_IT (selection.mark.row, - (int32_t)TermWin.nscrolled); |
2934 | MAX_IT (selection.mark.row, - (int32_t)TermWin.nscrolled); |
2945 | MIN_IT (selection.mark.row, (int32_t)TermWin.nrow - 1); |
2935 | MIN_IT (selection.mark.row, (int32_t)TermWin.nrow - 1); |
2946 | MAX_IT (selection.mark.col, 0); |
2936 | MAX_IT (selection.mark.col, 0); |
2947 | MIN_IT (selection.mark.col, (int32_t)TermWin.ncol - 1); |
2937 | MIN_IT (selection.mark.col, (int32_t)TermWin.ncol - 1); |
2948 | |
2938 | |
|
|
2939 | while (selection.mark.col > 0 |
|
|
2940 | && screen.text[selection.mark.row + TermWin.saveLines][selection.mark.col] == NOCHAR) |
|
|
2941 | --selection.mark.col; |
|
|
2942 | |
2949 | if (selection.op) |
2943 | if (selection.op) |
2950 | { /* clear the old selection */ |
2944 | { /* clear the old selection */ |
2951 | selection.beg.row = selection.end.row = selection.mark.row; |
2945 | selection.beg.row = selection.end.row = selection.mark.row; |
2952 | selection.beg.col = selection.end.col = selection.mark.col; |
2946 | selection.beg.col = selection.end.col = selection.mark.col; |
2953 | } |
2947 | } |
|
|
2948 | |
2954 | selection.op = SELECTION_INIT; |
2949 | selection.op = SELECTION_INIT; |
2955 | selection.screen = current_screen; |
2950 | selection.screen = current_screen; |
2956 | } |
2951 | } |
2957 | |
2952 | |
2958 | /* ------------------------------------------------------------------------- */ |
2953 | /* ------------------------------------------------------------------------- */ |
… | |
… | |
2960 | * Word select: select text for 2 clicks |
2955 | * Word select: select text for 2 clicks |
2961 | * We now only find out the boundary in one direction |
2956 | * We now only find out the boundary in one direction |
2962 | */ |
2957 | */ |
2963 | |
2958 | |
2964 | /* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */ |
2959 | /* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */ |
2965 | #define DELIMIT_TEXT(x) \ |
2960 | #define DELIMIT_TEXT(x) \ |
2966 | (((x) == ' ' || (x) == '\t') ? 2 : (STRCHR (rs[Rs_cutchars], (x)) != NULL)) |
2961 | (unicode::is_space (x) ? 2 : (x) <= 0xff && !!STRCHR (rs[Rs_cutchars], (x))) |
2967 | #define DELIMIT_REND(x) 1 |
2962 | #define DELIMIT_REND(x) 1 |
2968 | |
2963 | |
2969 | void |
2964 | void |
2970 | rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) |
2965 | rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) |
2971 | { |
2966 | { |
2972 | int col, row, dirnadd, tcol, trow, w1, w2; |
2967 | int col, row, dirnadd, tcol, trow, w1, w2; |
2973 | row_col_t bound; |
2968 | row_col_t bound; |
2974 | text_t *stp; |
2969 | text_t *stp; |
2975 | rend_t *srp; |
2970 | rend_t *srp; |
2976 | |
2971 | |
2977 | if (dirn == UP) |
2972 | if (dirn == UP) |
2978 | { |
2973 | { |
2979 | bound.row = TermWin.saveLines - TermWin.nscrolled - 1; |
2974 | bound.row = TermWin.saveLines - TermWin.nscrolled - 1; |
2980 | bound.col = 0; |
2975 | bound.col = 0; |
… | |
… | |
2984 | { |
2979 | { |
2985 | bound.row = TermWin.saveLines + TermWin.nrow; |
2980 | bound.row = TermWin.saveLines + TermWin.nrow; |
2986 | bound.col = TermWin.ncol - 1; |
2981 | bound.col = TermWin.ncol - 1; |
2987 | dirnadd = 1; |
2982 | dirnadd = 1; |
2988 | } |
2983 | } |
|
|
2984 | |
2989 | row = mark->row + TermWin.saveLines; |
2985 | row = mark->row + TermWin.saveLines; |
2990 | col = mark->col; |
2986 | col = mark->col; |
2991 | MAX_IT (col, 0); |
2987 | MAX_IT (col, 0); |
2992 | /* find the edge of a word */ |
2988 | /* find the edge of a word */ |
2993 | stp = & (screen.text[row][col]); |
2989 | stp = & (screen.text[row][col]); |
2994 | w1 = DELIMIT_TEXT (*stp); |
2990 | w1 = DELIMIT_TEXT (*stp); |
2995 | |
2991 | |
2996 | if (selection_style != NEW_SELECT) |
|
|
2997 | { |
|
|
2998 | if (w1 == 1) |
|
|
2999 | { |
|
|
3000 | stp += dirnadd; |
|
|
3001 | if (DELIMIT_TEXT (*stp) == 1) |
|
|
3002 | goto Old_Word_Selection_You_Die; |
|
|
3003 | col += dirnadd; |
|
|
3004 | } |
|
|
3005 | w1 = 0; |
|
|
3006 | } |
|
|
3007 | srp = (&screen.rend[row][col]); |
2992 | srp = (&screen.rend[row][col]); |
3008 | w2 = DELIMIT_REND (*srp); |
2993 | w2 = DELIMIT_REND (*srp); |
3009 | |
2994 | |
3010 | for (;;) |
2995 | for (;;) |
3011 | { |
2996 | { |
3012 | for (; col != bound.col; col += dirnadd) |
2997 | for (; col != bound.col; col += dirnadd) |
3013 | { |
2998 | { |
3014 | stp += dirnadd; |
2999 | stp += dirnadd; |
|
|
3000 | srp += dirnadd; |
|
|
3001 | |
|
|
3002 | if (*stp == NOCHAR) |
|
|
3003 | continue; |
|
|
3004 | |
3015 | if (DELIMIT_TEXT (*stp) != w1) |
3005 | if (DELIMIT_TEXT (*stp) != w1) |
3016 | break; |
3006 | break; |
3017 | srp += dirnadd; |
|
|
3018 | if (DELIMIT_REND (*srp) != w2) |
3007 | if (DELIMIT_REND (*srp) != w2) |
3019 | break; |
3008 | break; |
3020 | } |
3009 | } |
|
|
3010 | |
3021 | if ((col == bound.col) && (row != bound.row)) |
3011 | if ((col == bound.col) && (row != bound.row)) |
3022 | { |
3012 | { |
3023 | if (screen.tlen[ (row - (dirn == UP ? 1 : 0))] == -1) |
3013 | if (screen.tlen[ (row - (dirn == UP ? 1 : 0))] == -1) |
3024 | { |
3014 | { |
3025 | trow = row + dirnadd; |
3015 | trow = row + dirnadd; |
3026 | tcol = dirn == UP ? TermWin.ncol - 1 : 0; |
3016 | tcol = dirn == UP ? TermWin.ncol - 1 : 0; |
|
|
3017 | |
3027 | if (screen.text[trow] == NULL) |
3018 | if (screen.text[trow] == NULL) |
3028 | break; |
3019 | break; |
|
|
3020 | |
3029 | stp = & (screen.text[trow][tcol]); |
3021 | stp = & (screen.text[trow][tcol]); |
3030 | srp = & (screen.rend[trow][tcol]); |
3022 | srp = & (screen.rend[trow][tcol]); |
|
|
3023 | |
3031 | if (DELIMIT_TEXT (*stp) != w1 || DELIMIT_REND (*srp) != w2) |
3024 | if (DELIMIT_TEXT (*stp) != w1 || DELIMIT_REND (*srp) != w2) |
3032 | break; |
3025 | break; |
|
|
3026 | |
3033 | row = trow; |
3027 | row = trow; |
3034 | col = tcol; |
3028 | col = tcol; |
3035 | continue; |
3029 | continue; |
3036 | } |
3030 | } |
3037 | } |
3031 | } |
3038 | break; |
3032 | break; |
3039 | } |
3033 | } |
|
|
3034 | |
3040 | Old_Word_Selection_You_Die: |
3035 | Old_Word_Selection_You_Die: |
3041 | D_SELECT ((stderr, "rxvt_selection_delimit_word (%s,...) @ (r:%3d, c:%3d) has boundary (r:%3d, c:%3d)", (dirn == UP ? "up " : "down"), mark->row, mark->col, row - TermWin.saveLines, col)); |
3036 | D_SELECT ((stderr, "rxvt_selection_delimit_word (%s,...) @ (r:%3d, c:%3d) has boundary (r:%3d, c:%3d)", (dirn == UP ? "up " : "down"), mark->row, mark->col, row - TermWin.saveLines, col)); |
3042 | |
3037 | |
3043 | if (dirn == DN) |
3038 | if (dirn == DN) |
3044 | col++; /* put us on one past the end */ |
3039 | col++; /* put us on one past the end */ |
… | |
… | |
3066 | MAX_IT (row, 0); |
3061 | MAX_IT (row, 0); |
3067 | MIN_IT (row, (int)TermWin.nrow - 1); |
3062 | MIN_IT (row, (int)TermWin.nrow - 1); |
3068 | MAX_IT (col, 0); |
3063 | MAX_IT (col, 0); |
3069 | MIN_IT (col, (int)TermWin.ncol); |
3064 | MIN_IT (col, (int)TermWin.ncol); |
3070 | |
3065 | |
3071 | #ifndef NO_NEW_SELECTION |
|
|
3072 | /* |
3066 | /* |
3073 | * If we're selecting characters (single click) then we must check first |
3067 | * If we're selecting characters (single click) then we must check first |
3074 | * if we are at the same place as the original mark. If we are then |
3068 | * if we are at the same place as the original mark. If we are then |
3075 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
3069 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
3076 | * be _past_ a character for it to be selected. |
3070 | * be _past_ a character for it to be selected. |
3077 | */ |
3071 | */ |
3078 | if (selection_style != OLD_SELECT) |
|
|
3079 | { |
|
|
3080 | if (((selection.clicks % 3) == 1) && !flag |
3072 | if (((selection.clicks % 3) == 1) && !flag |
3081 | && (col == selection.mark.col |
3073 | && (col == selection.mark.col |
3082 | && (row == selection.mark.row + TermWin.view_start))) |
3074 | && (row == selection.mark.row + TermWin.view_start))) |
3083 | { |
3075 | { |
3084 | /* select nothing */ |
3076 | /* select nothing */ |
3085 | selection.beg.row = selection.end.row = 0; |
3077 | selection.beg.row = selection.end.row = 0; |
3086 | selection.beg.col = selection.end.col = 0; |
3078 | selection.beg.col = selection.end.col = 0; |
3087 | selection.clicks = 4; |
3079 | selection.clicks = 4; |
3088 | want_refresh = 1; |
3080 | want_refresh = 1; |
3089 | D_SELECT ((stderr, "rxvt_selection_extend () selection.clicks = 4")); |
3081 | D_SELECT ((stderr, "rxvt_selection_extend () selection.clicks = 4")); |
3090 | return; |
3082 | return; |
3091 | } |
|
|
3092 | } |
3083 | } |
3093 | #endif |
3084 | |
3094 | if (selection.clicks == 4) |
3085 | if (selection.clicks == 4) |
3095 | selection.clicks = 1; |
3086 | selection.clicks = 1; |
3096 | |
3087 | |
3097 | selection_extend_colrow (col, row, !!flag, /* ? button 3 */ |
3088 | selection_extend_colrow (col, row, !!flag, /* ? button 3 */ |
3098 | flag == 1 ? 1 : 0, /* ? button press */ |
3089 | flag == 1 ? 1 : 0, /* ? button press */ |
… | |
… | |
3152 | pos.col = col; |
3143 | pos.col = col; |
3153 | pos.row = row; |
3144 | pos.row = row; |
3154 | |
3145 | |
3155 | pos.row -= TermWin.view_start; /* adjust for scroll */ |
3146 | pos.row -= TermWin.view_start; /* adjust for scroll */ |
3156 | |
3147 | |
3157 | #ifndef NO_OLD_SELECTION |
|
|
3158 | /* |
|
|
3159 | * This mimics some of the selection behaviour of version 2.20 and before. |
|
|
3160 | * There are no ``selection modes'', button3 is always character extension. |
|
|
3161 | * Note: button3 drag is always available, c.f. v2.20 |
|
|
3162 | * Selection always terminates (left or right as appropriate) at the mark. |
|
|
3163 | */ |
|
|
3164 | if (selection_style == OLD_SELECT) |
|
|
3165 | { |
|
|
3166 | if (selection.clicks == 1 || button3) |
|
|
3167 | { |
|
|
3168 | if (hate_those_clicks) |
|
|
3169 | { |
|
|
3170 | hate_those_clicks = 0; |
|
|
3171 | if (selection.clicks == 1) |
|
|
3172 | { |
|
|
3173 | selection.beg.row = selection.mark.row; |
|
|
3174 | selection.beg.col = selection.mark.col; |
|
|
3175 | } |
|
|
3176 | else |
|
|
3177 | { |
|
|
3178 | selection.mark.row = selection.beg.row; |
|
|
3179 | selection.mark.col = selection.beg.col; |
|
|
3180 | } |
|
|
3181 | } |
|
|
3182 | if (ROWCOL_IS_BEFORE (pos, selection.mark)) |
|
|
3183 | { |
|
|
3184 | selection.end.row = selection.mark.row; |
|
|
3185 | selection.end.col = selection.mark.col + 1; |
|
|
3186 | selection.beg.row = pos.row; |
|
|
3187 | selection.beg.col = pos.col; |
|
|
3188 | } |
|
|
3189 | else |
|
|
3190 | { |
|
|
3191 | selection.beg.row = selection.mark.row; |
|
|
3192 | selection.beg.col = selection.mark.col; |
|
|
3193 | selection.end.row = pos.row; |
|
|
3194 | selection.end.col = pos.col + 1; |
|
|
3195 | } |
|
|
3196 | } |
|
|
3197 | else if (selection.clicks == 2) |
|
|
3198 | { |
|
|
3199 | selection_delimit_word (UP, & (selection.mark), |
|
|
3200 | & (selection.beg)); |
|
|
3201 | selection_delimit_word (DN, & (selection.mark), |
|
|
3202 | & (selection.end)); |
|
|
3203 | hate_those_clicks = 1; |
|
|
3204 | } |
|
|
3205 | else if (selection.clicks == 3) |
|
|
3206 | { |
|
|
3207 | selection.beg.row = selection.end.row = selection.mark.row; |
|
|
3208 | selection.beg.col = 0; |
|
|
3209 | selection.end.col = ncol; |
|
|
3210 | hate_those_clicks = 1; |
|
|
3211 | } |
|
|
3212 | D_SELECT ((stderr, "rxvt_selection_extend_colrow () EXIT b: (r:%d,c:%d) m: (r:%d,c:%d), e: (r:%d,c:%d)", selection.beg.row, selection.beg.col, selection.mark.row, selection.mark.col, selection.end.row, selection.end.col)); |
|
|
3213 | return; |
|
|
3214 | } |
|
|
3215 | #endif /* ! NO_OLD_SELECTION */ |
|
|
3216 | #ifndef NO_NEW_SELECTION |
|
|
3217 | /* selection_style must not be OLD_SELECT to get here */ |
|
|
3218 | /* |
3148 | /* |
3219 | * This is mainly xterm style selection with a couple of differences, mainly |
3149 | * This is mainly xterm style selection with a couple of differences, mainly |
3220 | * in the way button3 drag extension works. |
3150 | * in the way button3 drag extension works. |
3221 | * We're either doing: button1 drag; button3 press; or button3 drag |
3151 | * We're either doing: button1 drag; button3 press; or button3 drag |
3222 | * a) button1 drag : select around a midpoint/word/line - that point/word/line |
3152 | * a) button1 drag : select around a midpoint/word/line - that point/word/line |
… | |
… | |
3227 | * a point/word/line which is either the start or end of the selection |
3157 | * a point/word/line which is either the start or end of the selection |
3228 | * and it was decided by whichever point/word/line was `fixed' at the |
3158 | * and it was decided by whichever point/word/line was `fixed' at the |
3229 | * time of the most recent button3 press |
3159 | * time of the most recent button3 press |
3230 | */ |
3160 | */ |
3231 | if (button3 && buttonpress) |
3161 | if (button3 && buttonpress) |
3232 | { /* button3 press */ |
3162 | { /* button3 press */ |
3233 | /* |
3163 | /* |
3234 | * first determine which edge of the selection we are closest to |
3164 | * first determine which edge of the selection we are closest to |
3235 | */ |
3165 | */ |
3236 | if (ROWCOL_IS_BEFORE (pos, selection.beg) |
3166 | if (ROWCOL_IS_BEFORE (pos, selection.beg) |
3237 | || (!ROWCOL_IS_AFTER (pos, selection.end) |
3167 | || (!ROWCOL_IS_AFTER (pos, selection.end) |
3238 | && (((pos.col - selection.beg.col) |
3168 | && (((pos.col - selection.beg.col) |
3239 | + ((pos.row - selection.beg.row) * ncol)) |
3169 | + ((pos.row - selection.beg.row) * ncol)) |
3240 | < ((selection.end.col - pos.col) |
3170 | < ((selection.end.col - pos.col) |
3241 | + ((selection.end.row - pos.row) * ncol))))) |
3171 | + ((selection.end.row - pos.row) * ncol))))) |
3242 | closeto = LEFT; |
3172 | closeto = LEFT; |
|
|
3173 | |
3243 | if (closeto == LEFT) |
3174 | if (closeto == LEFT) |
3244 | { |
3175 | { |
3245 | selection.beg.row = pos.row; |
3176 | selection.beg.row = pos.row; |
3246 | selection.beg.col = pos.col; |
3177 | selection.beg.col = pos.col; |
3247 | selection.mark.row = selection.end.row; |
3178 | selection.mark.row = selection.end.row; |
3248 | selection.mark.col = selection.end.col |
3179 | selection.mark.col = selection.end.col - (selection.clicks == 2); |
3249 | - (selection.clicks == 2); |
|
|
3250 | } |
3180 | } |
3251 | else |
3181 | else |
3252 | { |
3182 | { |
3253 | selection.end.row = pos.row; |
3183 | selection.end.row = pos.row; |
3254 | selection.end.col = pos.col; |
3184 | selection.end.col = pos.col; |
3255 | selection.mark.row = selection.beg.row; |
3185 | selection.mark.row = selection.beg.row; |
3256 | selection.mark.col = selection.beg.col; |
3186 | selection.mark.col = selection.beg.col; |
3257 | } |
3187 | } |
3258 | } |
3188 | } |
3259 | else |
3189 | else |
3260 | { /* button1 drag or button3 drag */ |
3190 | { /* button1 drag or button3 drag */ |
3261 | if (ROWCOL_IS_AFTER (selection.mark, pos)) |
3191 | if (ROWCOL_IS_AFTER (selection.mark, pos)) |
3262 | { |
3192 | { |
3263 | if ((selection.mark.row == selection.end.row) |
3193 | if ((selection.mark.row == selection.end.row) |
3264 | && (selection.mark.col == selection.end.col) |
3194 | && (selection.mark.col == selection.end.col) |
3265 | && clickchange && selection.clicks == 2) |
3195 | && clickchange && selection.clicks == 2) |
3266 | selection.mark.col--; |
3196 | selection.mark.col--; |
|
|
3197 | |
3267 | selection.beg.row = pos.row; |
3198 | selection.beg.row = pos.row; |
3268 | selection.beg.col = pos.col; |
3199 | selection.beg.col = pos.col; |
3269 | selection.end.row = selection.mark.row; |
3200 | selection.end.row = selection.mark.row; |
3270 | selection.end.col = selection.mark.col |
3201 | selection.end.col = selection.mark.col + (selection.clicks == 2); |
3271 | + (selection.clicks == 2); |
|
|
3272 | } |
3202 | } |
3273 | else |
3203 | else |
3274 | { |
3204 | { |
3275 | selection.beg.row = selection.mark.row; |
3205 | selection.beg.row = selection.mark.row; |
3276 | selection.beg.col = selection.mark.col; |
3206 | selection.beg.col = selection.mark.col; |
… | |
… | |
3280 | } |
3210 | } |
3281 | |
3211 | |
3282 | if (selection.clicks == 1) |
3212 | if (selection.clicks == 1) |
3283 | { |
3213 | { |
3284 | end_col = screen.tlen[selection.beg.row + TermWin.saveLines]; |
3214 | end_col = screen.tlen[selection.beg.row + TermWin.saveLines]; |
|
|
3215 | |
3285 | if (end_col != -1 && selection.beg.col > end_col) |
3216 | if (end_col != -1 && selection.beg.col > end_col) |
3286 | { |
3217 | { |
3287 | #if 1 |
3218 | #if 1 |
3288 | selection.beg.col = ncol; |
3219 | selection.beg.col = ncol; |
3289 | #else |
3220 | #else |
3290 | if (selection.beg.row != selection.end.row) |
3221 | if (selection.beg.row != selection.end.row) |
3291 | selection.beg.col = ncol; |
3222 | selection.beg.col = ncol; |
3292 | else |
3223 | else |
3293 | selection.beg.col = selection.mark.col; |
3224 | selection.beg.col = selection.mark.col; |
3294 | #endif |
3225 | #endif |
3295 | |
|
|
3296 | } |
3226 | } |
|
|
3227 | |
3297 | end_col = screen.tlen[selection.end.row + TermWin.saveLines]; |
3228 | end_col = screen.tlen[selection.end.row + TermWin.saveLines]; |
|
|
3229 | |
3298 | if (end_col != -1 && selection.end.col > end_col) |
3230 | if (end_col != -1 && selection.end.col > end_col) |
3299 | selection.end.col = ncol; |
3231 | selection.end.col = ncol; |
3300 | |
|
|
3301 | } |
3232 | } |
3302 | else if (selection.clicks == 2) |
3233 | else if (selection.clicks == 2) |
3303 | { |
3234 | { |
3304 | if (ROWCOL_IS_AFTER (selection.end, selection.beg)) |
3235 | if (ROWCOL_IS_AFTER (selection.end, selection.beg)) |
3305 | selection.end.col--; |
3236 | selection.end.col--; |
|
|
3237 | |
3306 | selection_delimit_word (UP, & (selection.beg), |
3238 | selection_delimit_word (UP, & (selection.beg), & (selection.beg)); |
3307 | & (selection.beg)); |
|
|
3308 | selection_delimit_word (DN, & (selection.end), |
3239 | selection_delimit_word (DN, & (selection.end), & (selection.end)); |
3309 | & (selection.end)); |
|
|
3310 | } |
3240 | } |
3311 | else if (selection.clicks == 3) |
3241 | else if (selection.clicks == 3) |
3312 | { |
3242 | { |
3313 | #ifndef NO_FRILLS |
3243 | #ifndef NO_FRILLS |
3314 | if ((Options & Opt_tripleclickwords)) |
3244 | if ((Options & Opt_tripleclickwords)) |
3315 | { |
3245 | { |
3316 | int end_row; |
3246 | int end_row; |
3317 | |
3247 | |
3318 | selection_delimit_word (UP, & (selection.beg), |
3248 | selection_delimit_word (UP, & (selection.beg), & (selection.beg)); |
3319 | & (selection.beg)); |
|
|
3320 | end_row = screen.tlen[selection.mark.row |
3249 | end_row = screen.tlen[selection.mark.row + TermWin.saveLines]; |
3321 | + TermWin.saveLines]; |
3250 | |
3322 | for (end_row = selection.mark.row; end_row < TermWin.nrow; |
3251 | for (end_row = selection.mark.row; end_row < TermWin.nrow; end_row++) |
3323 | end_row++) |
|
|
3324 | { |
3252 | { |
3325 | end_col = screen.tlen[end_row + TermWin.saveLines]; |
3253 | end_col = screen.tlen[end_row + TermWin.saveLines]; |
|
|
3254 | |
3326 | if (end_col != -1) |
3255 | if (end_col != -1) |
3327 | { |
3256 | { |
3328 | selection.end.row = end_row; |
3257 | selection.end.row = end_row; |
3329 | selection.end.col = end_col; |
3258 | selection.end.col = end_col; |
3330 | selection_remove_trailing_spaces (); |
3259 | selection_remove_trailing_spaces (); |
… | |
… | |
3332 | } |
3261 | } |
3333 | } |
3262 | } |
3334 | } |
3263 | } |
3335 | else |
3264 | else |
3336 | #endif |
3265 | #endif |
3337 | |
|
|
3338 | { |
3266 | { |
3339 | if (ROWCOL_IS_AFTER (selection.mark, selection.beg)) |
3267 | if (ROWCOL_IS_AFTER (selection.mark, selection.beg)) |
3340 | selection.mark.col++; |
3268 | selection.mark.col++; |
3341 | selection.beg.col = 0; |
3269 | selection.beg.col = 0; |
3342 | selection.end.col = ncol; |
3270 | selection.end.col = ncol; |
3343 | } |
3271 | } |
3344 | } |
3272 | } |
|
|
3273 | |
3345 | if (button3 && buttonpress) |
3274 | if (button3 && buttonpress) |
3346 | { /* mark may need to be changed */ |
3275 | { /* mark may need to be changed */ |
3347 | if (closeto == LEFT) |
3276 | if (closeto == LEFT) |
3348 | { |
3277 | { |
3349 | selection.mark.row = selection.end.row; |
3278 | selection.mark.row = selection.end.row; |
3350 | selection.mark.col = selection.end.col |
3279 | selection.mark.col = selection.end.col |
3351 | - (selection.clicks == 2); |
3280 | - (selection.clicks == 2); |
… | |
… | |
3355 | selection.mark.row = selection.beg.row; |
3284 | selection.mark.row = selection.beg.row; |
3356 | selection.mark.col = selection.beg.col; |
3285 | selection.mark.col = selection.beg.col; |
3357 | } |
3286 | } |
3358 | } |
3287 | } |
3359 | D_SELECT ((stderr, "rxvt_selection_extend_colrow () EXIT b: (r:%d,c:%d) m: (r:%d,c:%d), e: (r:%d,c:%d)", selection.beg.row, selection.beg.col, selection.mark.row, selection.mark.col, selection.end.row, selection.end.col)); |
3288 | D_SELECT ((stderr, "rxvt_selection_extend_colrow () EXIT b: (r:%d,c:%d) m: (r:%d,c:%d), e: (r:%d,c:%d)", selection.beg.row, selection.beg.col, selection.mark.row, selection.mark.col, selection.end.row, selection.end.col)); |
3360 | #endif /* ! NO_NEW_SELECTION */ |
|
|
3361 | } |
3289 | } |
3362 | |
3290 | |
3363 | #ifndef NO_FRILLS |
3291 | #ifndef NO_FRILLS |
3364 | void |
3292 | void |
3365 | rxvt_term::selection_remove_trailing_spaces () |
3293 | rxvt_term::selection_remove_trailing_spaces () |