1 | /*--------------------------------*-C-*--------------------------------------* |
1 | /*--------------------------------*-C-*--------------------------------------* |
2 | * File: screen.c |
2 | * File: screen.c |
3 | *---------------------------------------------------------------------------* |
3 | *---------------------------------------------------------------------------* |
4 | * $Id: screen.C,v 1.5 2003/11/27 16:49:45 pcg Exp $ |
4 | * $Id: screen.C,v 1.7 2003/12/16 23:04:13 pcg Exp $ |
5 | * |
5 | * |
6 | * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> |
6 | * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
37 | { |
37 | { |
38 | while (len--) |
38 | while (len--) |
39 | *start++ = value; |
39 | *start++ = value; |
40 | } |
40 | } |
41 | |
41 | |
42 | #define RESET_CHSTAT(H) \ |
|
|
43 | if ((H)->chstat == WBYTE) \ |
|
|
44 | (H)->chstat = SBYTE, (H)->lost_multi = 1 |
|
|
45 | |
|
|
46 | /* ------------------------------------------------------------------------- */ |
42 | /* ------------------------------------------------------------------------- */ |
47 | #define PROP_SIZE 16384 |
43 | #define PROP_SIZE 16384 |
48 | #define TABSIZE 8 /* default tab size */ |
44 | #define TABSIZE 8 /* default tab size */ |
49 | |
45 | |
50 | /* ------------------------------------------------------------------------- * |
46 | /* ------------------------------------------------------------------------- * |
… | |
… | |
164 | rend_t setrstyle; |
160 | rend_t setrstyle; |
165 | |
161 | |
166 | D_SCREEN((stderr, "rxvt_scr_reset()")); |
162 | D_SCREEN((stderr, "rxvt_scr_reset()")); |
167 | |
163 | |
168 | R->TermWin.view_start = 0; |
164 | R->TermWin.view_start = 0; |
169 | RESET_CHSTAT(R); |
|
|
170 | R->num_scr = 0; |
165 | R->num_scr = 0; |
171 | |
166 | |
172 | prev_ncol = R->prev_ncol; |
167 | prev_ncol = R->prev_ncol; |
173 | prev_nrow = R->prev_nrow; |
168 | prev_nrow = R->prev_nrow; |
174 | if (R->TermWin.ncol == 0) |
169 | if (R->TermWin.ncol == 0) |
… | |
… | |
363 | R->tabs[p] = (p % TABSIZE == 0) ? 1 : 0; |
358 | R->tabs[p] = (p % TABSIZE == 0) ? 1 : 0; |
364 | |
359 | |
365 | R->prev_nrow = nrow; |
360 | R->prev_nrow = nrow; |
366 | R->prev_ncol = ncol; |
361 | R->prev_ncol = ncol; |
367 | |
362 | |
368 | rxvt_tt_winsize (R->cmd_fd, R->TermWin.ncol, R->TermWin.nrow, R->cmd_pid); |
363 | R->tt_winch (); |
369 | } |
364 | } |
370 | |
365 | |
371 | /* INTPROTO */ |
366 | /* INTPROTO */ |
372 | void |
367 | void |
373 | rxvt_scr_reset_realloc(pR) |
368 | rxvt_scr_reset_realloc(pR) |
… | |
… | |
532 | R->want_refresh = 1; |
527 | R->want_refresh = 1; |
533 | |
528 | |
534 | D_SCREEN((stderr, "rxvt_scr_change_screen(%d)", scrn)); |
529 | D_SCREEN((stderr, "rxvt_scr_change_screen(%d)", scrn)); |
535 | |
530 | |
536 | R->TermWin.view_start = 0; |
531 | R->TermWin.view_start = 0; |
537 | RESET_CHSTAT(R); |
|
|
538 | |
532 | |
539 | if (R->current_screen == scrn) |
533 | if (R->current_screen == scrn) |
540 | return R->current_screen; |
534 | return R->current_screen; |
541 | |
535 | |
542 | rxvt_selection_check(aR_ 2); /* check for boundary cross */ |
536 | rxvt_selection_check(aR_ 2); /* check for boundary cross */ |
… | |
… | |
797 | rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, 1, 0); |
791 | rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, 1, 0); |
798 | else if (R->screen.cur.row < (R->TermWin.nrow - 1)) |
792 | else if (R->screen.cur.row < (R->TermWin.nrow - 1)) |
799 | row = (++R->screen.cur.row) + R->TermWin.saveLines; |
793 | row = (++R->screen.cur.row) + R->TermWin.saveLines; |
800 | stp = R->screen.text[row]; /* _must_ refresh */ |
794 | stp = R->screen.text[row]; /* _must_ refresh */ |
801 | srp = R->screen.rend[row]; /* _must_ refresh */ |
795 | srp = R->screen.rend[row]; /* _must_ refresh */ |
802 | RESET_CHSTAT(R); |
|
|
803 | continue; |
796 | continue; |
804 | case '\r': |
797 | case '\r': |
805 | if (R->screen.tlen[row] != -1) /* XXX: think about this */ |
798 | if (R->screen.tlen[row] != -1) /* XXX: think about this */ |
806 | MAX_IT(R->screen.tlen[row], R->screen.cur.col); |
799 | MAX_IT(R->screen.tlen[row], R->screen.cur.col); |
807 | R->screen.flags &= ~Screen_WrapNext; |
800 | R->screen.flags &= ~Screen_WrapNext; |
808 | R->screen.cur.col = 0; |
801 | R->screen.cur.col = 0; |
809 | RESET_CHSTAT(R); |
|
|
810 | continue; |
802 | continue; |
811 | default: |
803 | default: |
812 | if (c == 127) |
804 | if (c == 127) |
813 | continue; /* yummmm..... */ |
805 | continue; /* yummmm..... */ |
814 | break; |
806 | break; |
… | |
… | |
907 | */ |
899 | */ |
908 | /* EXTPROTO */ |
900 | /* EXTPROTO */ |
909 | void |
901 | void |
910 | rxvt_scr_backspace(pR) |
902 | rxvt_scr_backspace(pR) |
911 | { |
903 | { |
912 | RESET_CHSTAT(R); |
|
|
913 | R->want_refresh = 1; |
904 | R->want_refresh = 1; |
914 | if (R->screen.cur.col == 0) { |
905 | if (R->screen.cur.col == 0) { |
915 | if (R->screen.cur.row > 0) { |
906 | if (R->screen.cur.row > 0) { |
916 | #ifdef TERMCAP_HAS_BW |
907 | #ifdef TERMCAP_HAS_BW |
917 | R->screen.cur.col = R->TermWin.ncol - 1; |
908 | R->screen.cur.col = R->TermWin.ncol - 1; |
… | |
… | |
936 | { |
927 | { |
937 | int i, x; |
928 | int i, x; |
938 | |
929 | |
939 | D_SCREEN((stderr, "rxvt_scr_tab(%d)", count)); |
930 | D_SCREEN((stderr, "rxvt_scr_tab(%d)", count)); |
940 | R->want_refresh = 1; |
931 | R->want_refresh = 1; |
941 | RESET_CHSTAT(R); |
|
|
942 | i = x = R->screen.cur.col; |
932 | i = x = R->screen.cur.col; |
943 | if (count == 0) |
933 | if (count == 0) |
944 | return; |
934 | return; |
945 | else if (count > 0) { |
935 | else if (count > 0) { |
946 | for (; ++i < R->TermWin.ncol; ) |
936 | for (; ++i < R->TermWin.ncol; ) |
… | |
… | |
1023 | void |
1013 | void |
1024 | rxvt_scr_gotorc(pR_ int row, int col, int relative) |
1014 | rxvt_scr_gotorc(pR_ int row, int col, int relative) |
1025 | { |
1015 | { |
1026 | R->want_refresh = 1; |
1016 | R->want_refresh = 1; |
1027 | ZERO_SCROLLBACK(R); |
1017 | ZERO_SCROLLBACK(R); |
1028 | RESET_CHSTAT(R); |
|
|
1029 | #ifdef RXVT_GRAPHICS |
1018 | #ifdef RXVT_GRAPHICS |
1030 | if (rxvt_Gr_Displayed(aR)) |
1019 | if (rxvt_Gr_Displayed(aR)) |
1031 | rxvt_Gr_scroll(aR_ 0); |
1020 | rxvt_Gr_scroll(aR_ 0); |
1032 | #endif |
1021 | #endif |
1033 | |
1022 | |
… | |
… | |
1077 | R->want_refresh = 1; |
1066 | R->want_refresh = 1; |
1078 | dirn = ((direction == UP) ? 1 : -1); |
1067 | dirn = ((direction == UP) ? 1 : -1); |
1079 | D_SCREEN((stderr, "rxvt_scr_index(%d)", dirn)); |
1068 | D_SCREEN((stderr, "rxvt_scr_index(%d)", dirn)); |
1080 | |
1069 | |
1081 | ZERO_SCROLLBACK(R); |
1070 | ZERO_SCROLLBACK(R); |
1082 | RESET_CHSTAT(R); |
|
|
1083 | |
1071 | |
1084 | #ifdef RXVT_GRAPHICS |
1072 | #ifdef RXVT_GRAPHICS |
1085 | if (rxvt_Gr_Displayed(aR)) |
1073 | if (rxvt_Gr_Displayed(aR)) |
1086 | rxvt_Gr_scroll(aR_ 0); |
1074 | rxvt_Gr_scroll(aR_ 0); |
1087 | #endif |
1075 | #endif |
… | |
… | |
1111 | unsigned int row, col, num; |
1099 | unsigned int row, col, num; |
1112 | |
1100 | |
1113 | R->want_refresh = 1; |
1101 | R->want_refresh = 1; |
1114 | D_SCREEN((stderr, "rxvt_scr_erase_line(%d) at screen row: %d", mode, R->screen.cur.row)); |
1102 | D_SCREEN((stderr, "rxvt_scr_erase_line(%d) at screen row: %d", mode, R->screen.cur.row)); |
1115 | ZERO_SCROLLBACK(R); |
1103 | ZERO_SCROLLBACK(R); |
1116 | RESET_CHSTAT(R); |
|
|
1117 | |
1104 | |
1118 | #ifdef RXVT_GRAPHICS |
1105 | #ifdef RXVT_GRAPHICS |
1119 | if (rxvt_Gr_Displayed(aR)) |
1106 | if (rxvt_Gr_Displayed(aR)) |
1120 | rxvt_Gr_scroll(aR_ 0); |
1107 | rxvt_Gr_scroll(aR_ 0); |
1121 | #endif |
1108 | #endif |
… | |
… | |
1178 | XGCValues gcvalue; |
1165 | XGCValues gcvalue; |
1179 | |
1166 | |
1180 | R->want_refresh = 1; |
1167 | R->want_refresh = 1; |
1181 | D_SCREEN((stderr, "rxvt_scr_erase_screen(%d) at screen row: %d", mode, R->screen.cur.row)); |
1168 | D_SCREEN((stderr, "rxvt_scr_erase_screen(%d) at screen row: %d", mode, R->screen.cur.row)); |
1182 | ZERO_SCROLLBACK(R); |
1169 | ZERO_SCROLLBACK(R); |
1183 | RESET_CHSTAT(R); |
|
|
1184 | row_offset = (int32_t)R->TermWin.saveLines; |
1170 | row_offset = (int32_t)R->TermWin.saveLines; |
1185 | |
1171 | |
1186 | switch (mode) { |
1172 | switch (mode) { |
1187 | case 0: /* erase to end of screen */ |
1173 | case 0: /* erase to end of screen */ |
1188 | rxvt_selection_check(aR_ 1); |
1174 | rxvt_selection_check(aR_ 1); |
… | |
… | |
1252 | rend_t *r1, fs; |
1238 | rend_t *r1, fs; |
1253 | |
1239 | |
1254 | R->want_refresh = 1; |
1240 | R->want_refresh = 1; |
1255 | R->num_scr_allow = 0; |
1241 | R->num_scr_allow = 0; |
1256 | ZERO_SCROLLBACK(R); |
1242 | ZERO_SCROLLBACK(R); |
1257 | RESET_CHSTAT(R); |
|
|
1258 | rxvt_selection_check(aR_ 3); |
1243 | rxvt_selection_check(aR_ 3); |
1259 | |
1244 | |
1260 | fs = SET_FONT (R->rstyle, R->TermWin.fontset->find_font ('E')); |
1245 | fs = SET_FONT (R->rstyle, R->TermWin.fontset->find_font ('E')); |
1261 | for (k = R->TermWin.saveLines, i = R->TermWin.nrow; i--; k++) { |
1246 | for (k = R->TermWin.saveLines, i = R->TermWin.nrow; i--; k++) { |
1262 | R->screen.tlen[k] = R->TermWin.ncol; /* make the `E's selectable */ |
1247 | R->screen.tlen[k] = R->TermWin.ncol; /* make the `E's selectable */ |
… | |
… | |
1275 | rxvt_scr_insdel_lines(pR_ int count, int insdel) |
1260 | rxvt_scr_insdel_lines(pR_ int count, int insdel) |
1276 | { |
1261 | { |
1277 | int end; |
1262 | int end; |
1278 | |
1263 | |
1279 | ZERO_SCROLLBACK(R); |
1264 | ZERO_SCROLLBACK(R); |
1280 | RESET_CHSTAT(R); |
|
|
1281 | |
1265 | |
1282 | #ifdef RXVT_GRAPHICS |
1266 | #ifdef RXVT_GRAPHICS |
1283 | if (rxvt_Gr_Displayed(aR)) |
1267 | if (rxvt_Gr_Displayed(aR)) |
1284 | rxvt_Gr_scroll(aR_ 0); |
1268 | rxvt_Gr_scroll(aR_ 0); |
1285 | #endif |
1269 | #endif |
… | |
… | |
1316 | rend_t *srp; |
1300 | rend_t *srp; |
1317 | int16_t *slp; |
1301 | int16_t *slp; |
1318 | |
1302 | |
1319 | R->want_refresh = 1; |
1303 | R->want_refresh = 1; |
1320 | ZERO_SCROLLBACK(R); |
1304 | ZERO_SCROLLBACK(R); |
1321 | #if 0 |
|
|
1322 | RESET_CHSTAT(R); |
|
|
1323 | #endif |
|
|
1324 | |
1305 | |
1325 | #ifdef RXVT_GRAPHICS |
1306 | #ifdef RXVT_GRAPHICS |
1326 | if (rxvt_Gr_Displayed(aR)) |
1307 | if (rxvt_Gr_Displayed(aR)) |
1327 | rxvt_Gr_scroll(aR_ 0); |
1308 | rxvt_Gr_scroll(aR_ 0); |
1328 | #endif |
1309 | #endif |
… | |
… | |
2414 | |
2395 | |
2415 | /* ------------------------------------------------------------------------- */ |
2396 | /* ------------------------------------------------------------------------- */ |
2416 | /* |
2397 | /* |
2417 | * Paste a selection direct to the command fd |
2398 | * Paste a selection direct to the command fd |
2418 | */ |
2399 | */ |
2419 | /* INTPROTO */ |
|
|
2420 | void |
2400 | void |
2421 | rxvt_PasteIt (pR_ const unsigned char *data, unsigned int nitems) |
2401 | rxvt_term::paste (const unsigned char *data, unsigned int len) |
2422 | { |
2402 | { |
2423 | unsigned int i, j, n; |
2403 | unsigned int i, j, n; |
2424 | unsigned char *ds = (unsigned char *)rxvt_malloc (PROP_SIZE); |
2404 | unsigned char *ds = (unsigned char *)rxvt_malloc (PROP_SIZE); |
2425 | |
2405 | |
2426 | /* convert normal newline chars into common keyboard Return key sequence */ |
2406 | /* convert normal newline chars into common keyboard Return key sequence */ |
2427 | for (i = 0; i < nitems; i += PROP_SIZE) |
2407 | for (i = 0; i < len; i += PROP_SIZE) |
2428 | { |
2408 | { |
2429 | n = min (nitems - i, PROP_SIZE); |
2409 | n = min (len - i, PROP_SIZE); |
2430 | MEMCPY (ds, data + i, n); |
2410 | MEMCPY (ds, data + i, n); |
|
|
2411 | |
2431 | for (j = 0; j < n; j++) |
2412 | for (j = 0; j < n; j++) |
2432 | if (ds[j] == '\n') |
2413 | if (ds[j] == '\n') |
2433 | ds[j] = '\r'; |
2414 | ds[j] = '\r'; |
|
|
2415 | |
2434 | R->tt_write (ds, (int)n); |
2416 | tt_write (ds, (int)n); |
2435 | } |
2417 | } |
2436 | |
2418 | |
2437 | free(ds); |
2419 | free(ds); |
2438 | } |
2420 | } |
2439 | |
2421 | |
… | |
… | |
2444 | */ |
2426 | */ |
2445 | /* EXTPROTO */ |
2427 | /* EXTPROTO */ |
2446 | int |
2428 | int |
2447 | rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop) |
2429 | rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop) |
2448 | { |
2430 | { |
2449 | long nread = 0; |
2431 | long nread = 0; |
2450 | unsigned long bytes_after; |
2432 | unsigned long bytes_after; |
2451 | XTextProperty ct; |
2433 | XTextProperty ct; |
2452 | #ifdef MULTICHAR_SET |
2434 | int dummy_count; |
2453 | int dummy_count; |
2435 | char **cl; |
2454 | char **cl; |
|
|
2455 | #endif |
|
|
2456 | |
2436 | |
2457 | D_SELECT((stderr, "rxvt_selection_paste(%08lx, %lu, %d), wait=%2x", win, (unsigned long)prop, (int)delete_prop, R->selection_wait)); |
2437 | D_SELECT((stderr, "rxvt_selection_paste(%08lx, %lu, %d), wait=%2x", win, (unsigned long)prop, (int)delete_prop, R->selection_wait)); |
2458 | |
2438 | |
2459 | if (prop == None) { /* check for failed XConvertSelection */ |
2439 | if (prop == None) /* check for failed XConvertSelection */ |
2460 | #ifdef MULTICHAR_SET |
2440 | { |
2461 | if ((R->selection_type & Sel_CompoundText)) { |
2441 | if ((R->selection_type & Sel_CompoundText)) |
|
|
2442 | { |
2462 | int selnum = R->selection_type & Sel_whereMask; |
2443 | int selnum = R->selection_type & Sel_whereMask; |
2463 | |
2444 | |
2464 | R->selection_type = 0; |
2445 | R->selection_type = 0; |
2465 | if (selnum != Sel_direct) |
2446 | if (selnum != Sel_direct) |
2466 | rxvt_selection_request_other(aR_ XA_STRING, selnum); |
2447 | rxvt_selection_request_other(aR_ XA_STRING, selnum); |
|
|
2448 | } |
2467 | } |
2449 | |
2468 | #endif |
|
|
2469 | return 0; |
2450 | return 0; |
2470 | } |
2451 | } |
|
|
2452 | |
2471 | for (;;) { |
2453 | for (;;) |
|
|
2454 | { |
2472 | if (XGetWindowProperty(R->Xdisplay, win, prop, (long)(nread / 4), |
2455 | if (XGetWindowProperty(R->Xdisplay, win, prop, (long)(nread / 4), |
2473 | (long)(PROP_SIZE / 4), delete_prop, |
2456 | (long)(PROP_SIZE / 4), delete_prop, |
2474 | AnyPropertyType, &ct.encoding, &ct.format, |
2457 | AnyPropertyType, &ct.encoding, &ct.format, |
2475 | &ct.nitems, &bytes_after, |
2458 | &ct.nitems, &bytes_after, |
2476 | &ct.value) != Success) |
2459 | &ct.value) != Success) |
2477 | break; |
2460 | break; |
|
|
2461 | |
2478 | if (ct.encoding == 0) { |
2462 | if (ct.encoding == 0) |
|
|
2463 | { |
2479 | D_SELECT((stderr, "rxvt_selection_paste: property didn't exist!")); |
2464 | D_SELECT((stderr, "rxvt_selection_paste: property didn't exist!")); |
2480 | break; |
2465 | break; |
2481 | } |
2466 | } |
|
|
2467 | |
2482 | if (ct.value == NULL) { |
2468 | if (ct.value == NULL) |
|
|
2469 | { |
2483 | D_SELECT((stderr, "rxvt_selection_paste: property shooting blanks!")); |
2470 | D_SELECT((stderr, "rxvt_selection_paste: property shooting blanks!")); |
2484 | continue; |
2471 | continue; |
2485 | } |
2472 | } |
|
|
2473 | |
2486 | if (ct.nitems == 0) { |
2474 | if (ct.nitems == 0) |
|
|
2475 | { |
2487 | D_SELECT((stderr, "rxvt_selection_paste: property empty - also INCR end")); |
2476 | D_SELECT((stderr, "rxvt_selection_paste: property empty - also INCR end")); |
2488 | if (R->selection_wait == Sel_normal && nread == 0) { |
2477 | if (R->selection_wait == Sel_normal && nread == 0) |
|
|
2478 | { |
2489 | /* |
2479 | /* |
2490 | * pass through again trying CUT_BUFFER0 if we've come from |
2480 | * pass through again trying CUT_BUFFER0 if we've come from |
2491 | * XConvertSelection() but nothing was presented |
2481 | * XConvertSelection() but nothing was presented |
2492 | */ |
2482 | */ |
2493 | D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); |
2483 | D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); |
2494 | rxvt_selection_paste(aR_ Xroot, XA_CUT_BUFFER0, False); |
2484 | rxvt_selection_paste (aR_ Xroot, XA_CUT_BUFFER0, False); |
2495 | } |
2485 | } |
|
|
2486 | |
2496 | nread = -1; /* discount any previous stuff */ |
2487 | nread = -1; /* discount any previous stuff */ |
2497 | break; |
2488 | break; |
2498 | } |
2489 | } |
|
|
2490 | |
2499 | nread += ct.nitems; |
2491 | nread += ct.nitems; |
2500 | #ifdef MULTICHAR_SET |
|
|
2501 | if (XmbTextPropertyToTextList(R->Xdisplay, &ct, &cl, |
2492 | if (XmbTextPropertyToTextList (R->Xdisplay, &ct, &cl, |
2502 | &dummy_count) == Success && cl) { |
2493 | &dummy_count) == Success && cl) |
2503 | rxvt_PasteIt(aR_ cl[0], STRLEN(cl[0])); |
2494 | { |
|
|
2495 | R->paste ((unsigned char *)cl[0], STRLEN (cl[0])); |
2504 | XFreeStringList(cl); |
2496 | XFreeStringList (cl); |
|
|
2497 | } |
2505 | } else |
2498 | else |
2506 | #endif |
2499 | R->paste (ct.value, ct.nitems); |
2507 | rxvt_PasteIt(aR_ ct.value, (unsigned int)ct.nitems); |
2500 | |
2508 | if (bytes_after == 0) |
2501 | if (bytes_after == 0) |
2509 | break; |
2502 | break; |
|
|
2503 | |
2510 | XFree(ct.value); |
2504 | XFree (ct.value); |
2511 | } |
2505 | } |
|
|
2506 | |
2512 | if (ct.value) |
2507 | if (ct.value) |
2513 | XFree(ct.value); |
2508 | XFree (ct.value); |
|
|
2509 | |
2514 | if (R->selection_wait == Sel_normal) |
2510 | if (R->selection_wait == Sel_normal) |
2515 | R->selection_wait = Sel_none; |
2511 | R->selection_wait = Sel_none; |
|
|
2512 | |
2516 | D_SELECT((stderr, "rxvt_selection_paste: bytes written: %ld", nread)); |
2513 | D_SELECT((stderr, "rxvt_selection_paste: bytes written: %ld", nread)); |
2517 | return (int)nread; |
2514 | return (int)nread; |
|
|
2515 | } |
|
|
2516 | |
|
|
2517 | void |
|
|
2518 | rxvt_term::incr_cb (time_watcher &w) |
|
|
2519 | { |
|
|
2520 | w.stop (); |
|
|
2521 | selection_wait = Sel_none; |
|
|
2522 | |
|
|
2523 | rxvt_print_error("data loss: timeout on INCR selection paste"); |
2518 | } |
2524 | } |
2519 | |
2525 | |
2520 | /* |
2526 | /* |
2521 | * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za> |
2527 | * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za> |
2522 | */ |
2528 | */ |
… | |
… | |
2554 | } else if (R->selection_wait == Sel_incr) { |
2560 | } else if (R->selection_wait == Sel_incr) { |
2555 | reget_time = 1; |
2561 | reget_time = 1; |
2556 | if (rxvt_selection_paste(aR_ win, prop, True) == -1) { |
2562 | if (rxvt_selection_paste(aR_ win, prop, True) == -1) { |
2557 | D_SELECT((stderr, "rxvt_selection_property: INCR: clean end")); |
2563 | D_SELECT((stderr, "rxvt_selection_property: INCR: clean end")); |
2558 | R->selection_wait = Sel_none; |
2564 | R->selection_wait = Sel_none; |
2559 | R->timeout[TIMEOUT_INCR].tv_sec = 0; /* turn off timer */ |
2565 | R->incr_ev.stop (); |
2560 | } |
2566 | } |
2561 | } |
2567 | } |
2562 | if (reget_time) { /* received more data so reget time */ |
2568 | if (reget_time) /* received more data so reget time */ |
2563 | (void)gettimeofday(&(R->timeout[TIMEOUT_INCR]), NULL); |
2569 | R->incr_ev.start (NOW + 10); |
2564 | R->timeout[TIMEOUT_INCR].tv_sec += 10; /* ten seconds wait */ |
|
|
2565 | } |
|
|
2566 | } |
2570 | } |
2567 | /* ------------------------------------------------------------------------- */ |
2571 | /* ------------------------------------------------------------------------- */ |
2568 | /* |
2572 | /* |
2569 | * Request the current selection: |
2573 | * Request the current selection: |
2570 | * Order: > internal selection if available |
2574 | * Order: > internal selection if available |
… | |
… | |
2582 | if (x < 0 || x >= R->TermWin.width || y < 0 || y >= R->TermWin.height) |
2586 | if (x < 0 || x >= R->TermWin.width || y < 0 || y >= R->TermWin.height) |
2583 | return; /* outside window */ |
2587 | return; /* outside window */ |
2584 | |
2588 | |
2585 | if (R->selection.text != NULL) { /* internal selection */ |
2589 | if (R->selection.text != NULL) { /* internal selection */ |
2586 | D_SELECT((stderr, "rxvt_selection_request: pasting internal")); |
2590 | D_SELECT((stderr, "rxvt_selection_request: pasting internal")); |
2587 | rxvt_PasteIt(aR_ R->selection.text, R->selection.len); |
2591 | R->paste (R->selection.text, R->selection.len); |
2588 | return; |
2592 | return; |
2589 | } else { |
2593 | } else { |
2590 | int i; |
2594 | int i; |
2591 | |
2595 | |
2592 | R->selection_request_time = tm; |
2596 | R->selection_request_time = tm; |
2593 | R->selection_wait = Sel_normal; |
2597 | R->selection_wait = Sel_normal; |
2594 | for (i = Sel_Primary; i <= Sel_Clipboard; i++) { |
2598 | for (i = Sel_Primary; i <= Sel_Clipboard; i++) { |
2595 | #ifdef MULTICHAR_SET |
|
|
2596 | R->selection_type = Sel_CompoundText; |
2599 | R->selection_type = Sel_CompoundText; |
2597 | #else |
|
|
2598 | R->selection_type = 0; |
|
|
2599 | #endif |
|
|
2600 | if (rxvt_selection_request_other(aR_ |
2600 | if (rxvt_selection_request_other(aR_ R->xa[XA_COMPOUND_TEXT], i)) |
2601 | #ifdef MULTICHAR_SET |
|
|
2602 | R->xa[XA_COMPOUND_TEXT], |
|
|
2603 | #else |
|
|
2604 | XA_STRING, |
|
|
2605 | #endif |
|
|
2606 | i)) |
|
|
2607 | return; |
2601 | return; |
2608 | } |
2602 | } |
2609 | } |
2603 | } |
2610 | R->selection_wait = Sel_none; /* don't loop in rxvt_selection_paste() */ |
2604 | R->selection_wait = Sel_none; /* don't loop in rxvt_selection_paste() */ |
2611 | D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); |
2605 | D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); |
… | |
… | |
2820 | */ |
2814 | */ |
2821 | |
2815 | |
2822 | /* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */ |
2816 | /* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */ |
2823 | #define DELIMIT_TEXT(x) \ |
2817 | #define DELIMIT_TEXT(x) \ |
2824 | (((x) == ' ' || (x) == '\t') ? 2 : (STRCHR(R->rs[Rs_cutchars], (x)) != NULL)) |
2818 | (((x) == ' ' || (x) == '\t') ? 2 : (STRCHR(R->rs[Rs_cutchars], (x)) != NULL)) |
2825 | #ifdef MULTICHAR_SET |
|
|
2826 | # define DELIMIT_REND(x) (((x) & RS_multiMask) ? 1 : 0) |
|
|
2827 | #else |
|
|
2828 | # define DELIMIT_REND(x) 1 |
2819 | #define DELIMIT_REND(x) 1 |
2829 | #endif |
|
|
2830 | |
2820 | |
2831 | /* INTPROTO */ |
2821 | /* INTPROTO */ |
2832 | void |
2822 | void |
2833 | rxvt_selection_delimit_word(pR_ enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) |
2823 | rxvt_selection_delimit_word(pR_ enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) |
2834 | { |
2824 | { |