… | |
… | |
48 | #include "../config.h" /* NECESSARY */ |
48 | #include "../config.h" /* NECESSARY */ |
49 | #include "rxvt.h" /* NECESSARY */ |
49 | #include "rxvt.h" /* NECESSARY */ |
50 | #include "version.h" |
50 | #include "version.h" |
51 | #include "command.h" |
51 | #include "command.h" |
52 | |
52 | |
53 | #include <wchar.h> |
53 | #include <cwchar> |
54 | #include <signal.h> |
54 | #include <csignal> |
55 | |
55 | |
56 | /*----------------------------------------------------------------------*/ |
56 | /*----------------------------------------------------------------------*/ |
57 | |
57 | |
58 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
58 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
59 | |
59 | |
… | |
… | |
488 | #endif |
488 | #endif |
489 | |
489 | |
490 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
490 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
491 | { |
491 | { |
492 | #ifdef KEYSYM_RESOURCE |
492 | #ifdef KEYSYM_RESOURCE |
493 | if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) |
493 | if (!(shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) |
494 | { |
494 | { |
495 | unsigned int l; |
495 | unsigned int l; |
496 | const unsigned char *kbuf0; |
496 | const unsigned char *kbuf0; |
497 | |
497 | |
498 | kbuf0 = (Keysym_map[keysym & 0xFF]); |
498 | kbuf0 = (Keysym_map[keysym & 0xFF]); |
… | |
… | |
785 | case XK_F35: /* "\033[49~" */ |
785 | case XK_F35: /* "\033[49~" */ |
786 | FKEY (31, XK_F17); |
786 | FKEY (31, XK_F17); |
787 | break; |
787 | break; |
788 | #undef FKEY |
788 | #undef FKEY |
789 | default: |
789 | default: |
790 | newlen = 0; |
790 | if (len == 0 |
791 | break; |
791 | && (keysym & 0xfff0) != 0xff70 |
|
|
792 | && (keysym & 0xfff0) != 0xffe0) |
|
|
793 | /* generate a keycode for every remaining keypress */ |
|
|
794 | sprintf ((char *)kbuf, "\033[%x;%xA", (unsigned char)ev.state, (unsigned short)keysym); |
792 | } |
795 | } |
|
|
796 | |
793 | if (newlen) |
797 | if (newlen) |
794 | len = strlen (kbuf); |
798 | len = strlen (kbuf); |
795 | } |
799 | } |
796 | |
800 | |
797 | /* |
801 | /* |
… | |
… | |
805 | } |
809 | } |
806 | else if (ctrl && keysym == XK_minus) |
810 | else if (ctrl && keysym == XK_minus) |
807 | { |
811 | { |
808 | len = 1; |
812 | len = 1; |
809 | kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */ |
813 | kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */ |
|
|
814 | } |
|
|
815 | else if (keysym == XK_ISO_Left_Tab) |
|
|
816 | { |
|
|
817 | strcpy (kbuf, "\033[Z"); |
|
|
818 | len = 3; |
|
|
819 | } |
|
|
820 | else if (len == 0 |
|
|
821 | && (keysym & 0xffe0) != 0xfe00 |
|
|
822 | && (keysym < 0xfe50 || keysym > 0xfe6f)) |
|
|
823 | { |
|
|
824 | /* generate a keycode for every remaining keypress */ |
|
|
825 | len = sprintf ((char *)kbuf, "\033[%x;%xA", (unsigned char)ev.state, (unsigned short)keysym); |
810 | } |
826 | } |
811 | else |
827 | else |
812 | { |
828 | { |
813 | #ifdef META8_OPTION |
829 | #ifdef META8_OPTION |
814 | /* set 8-bit on */ |
830 | /* set 8-bit on */ |
… | |
… | |
1058 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1074 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1059 | { |
1075 | { |
1060 | SET_R (this); |
1076 | SET_R (this); |
1061 | SET_LOCALE (locale); |
1077 | SET_LOCALE (locale); |
1062 | |
1078 | |
1063 | if (revents & EVENT_WRITE) |
|
|
1064 | tt_write (0, 0); |
|
|
1065 | else if (revents & EVENT_READ) |
1079 | if (revents & EVENT_READ) |
1066 | // loop, but don't allow a single term to monopolize us |
1080 | // loop, but don't allow a single term to monopolize us |
1067 | while (pty_fill ()) |
1081 | while (pty_fill ()) |
1068 | if (cmd_parse ()) |
1082 | if (cmd_parse ()) |
1069 | break; |
1083 | break; |
|
|
1084 | |
|
|
1085 | if (revents & EVENT_WRITE) |
|
|
1086 | pty_write (); |
1070 | } |
1087 | } |
1071 | |
1088 | |
1072 | void |
1089 | void |
1073 | rxvt_term::pointer_unblank () |
1090 | rxvt_term::pointer_unblank () |
1074 | { |
1091 | { |
… | |
… | |
1217 | if (ev.type == KeyPress && hidden_pointer == 0) |
1234 | if (ev.type == KeyPress && hidden_pointer == 0) |
1218 | pointer_blank (); |
1235 | pointer_blank (); |
1219 | } |
1236 | } |
1220 | #endif |
1237 | #endif |
1221 | |
1238 | |
1222 | Window unused_root, unused_child; |
1239 | Window unused_root, unused_child; |
1223 | int unused_root_x, unused_root_y; |
1240 | int unused_root_x, unused_root_y; |
1224 | unsigned int unused_mask; |
1241 | unsigned int unused_mask; |
1225 | |
1242 | |
1226 | switch (ev.type) |
1243 | switch (ev.type) |
1227 | { |
1244 | { |
1228 | case KeyPress: |
1245 | case KeyPress: |
1229 | #if ISO_14755 |
1246 | #if ISO_14755 |
… | |
… | |
1334 | 0L, 1000000L, |
1351 | 0L, 1000000L, |
1335 | False, AnyPropertyType, |
1352 | False, AnyPropertyType, |
1336 | &ActualType, &ActualFormat, |
1353 | &ActualType, &ActualFormat, |
1337 | &Size, &RemainingBytes, |
1354 | &Size, &RemainingBytes, |
1338 | &data); |
1355 | &data); |
1339 | XChangeProperty (display->display, display->root, |
1356 | set_string_property (XA_CUT_BUFFER0, data); |
1340 | XA_CUT_BUFFER0, XA_STRING, |
|
|
1341 | 8, PropModeReplace, |
|
|
1342 | data, strlen (data)); |
|
|
1343 | XFree (data); |
1357 | XFree (data); |
1344 | selection_paste (display->root, XA_CUT_BUFFER0, True); |
1358 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
1345 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1359 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1346 | } |
1360 | } |
1347 | #endif /* OFFIX_DND */ |
1361 | #endif /* OFFIX_DND */ |
1348 | break; |
1362 | break; |
1349 | |
1363 | |
… | |
… | |
1453 | resize_all_windows (width, height, 1); |
1467 | resize_all_windows (width, height, 1); |
1454 | } |
1468 | } |
1455 | |
1469 | |
1456 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1470 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1457 | if (options & Opt_transparent) |
1471 | if (options & Opt_transparent) |
1458 | { |
|
|
1459 | check_our_parents (); |
1472 | check_our_parents (); |
1460 | if (am_transparent) |
|
|
1461 | want_refresh = want_full_refresh = 1; |
|
|
1462 | } |
|
|
1463 | #endif |
1473 | #endif |
1464 | } |
1474 | } |
1465 | break; |
1475 | break; |
1466 | |
1476 | |
1467 | case PropertyNotify: |
1477 | case PropertyNotify: |
… | |
… | |
1475 | selection_clear (); |
1485 | selection_clear (); |
1476 | break; |
1486 | break; |
1477 | |
1487 | |
1478 | case SelectionNotify: |
1488 | case SelectionNotify: |
1479 | if (selection_wait == Sel_normal) |
1489 | if (selection_wait == Sel_normal) |
1480 | selection_paste (ev.xselection.requestor, |
1490 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1481 | ev.xselection.property, True); |
|
|
1482 | break; |
1491 | break; |
1483 | |
1492 | |
1484 | case SelectionRequest: |
1493 | case SelectionRequest: |
1485 | selection_send (ev.xselectionrequest); |
1494 | selection_send (ev.xselectionrequest); |
1486 | break; |
1495 | break; |
… | |
… | |
1675 | case PropertyNotify: |
1684 | case PropertyNotify: |
1676 | /* |
1685 | /* |
1677 | * if user used some Esetroot compatible prog to set the root bg, |
1686 | * if user used some Esetroot compatible prog to set the root bg, |
1678 | * use the property to determine the pixmap. We use it later on. |
1687 | * use the property to determine the pixmap. We use it later on. |
1679 | */ |
1688 | */ |
1680 | if (xa[XA_XROOTPMAPID] == 0) |
|
|
1681 | xa[XA_XROOTPMAPID] = XInternAtom (display->display, "_XROOTPMAP_ID", False); |
|
|
1682 | |
|
|
1683 | if (ev.xproperty.atom != xa[XA_XROOTPMAPID]) |
1689 | if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] |
|
|
1690 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1684 | return; |
1691 | return; |
1685 | |
1692 | |
1686 | /* FALLTHROUGH */ |
1693 | /* FALLTHROUGH */ |
1687 | case ReparentNotify: |
1694 | case ReparentNotify: |
1688 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
1695 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
… | |
… | |
2358 | /* |
2365 | /* |
2359 | * Make the frame window set by the window manager have |
2366 | * Make the frame window set by the window manager have |
2360 | * the root background. Some window managers put multiple nested frame |
2367 | * the root background. Some window managers put multiple nested frame |
2361 | * windows for each client, so we have to take care about that. |
2368 | * windows for each client, so we have to take care about that. |
2362 | */ |
2369 | */ |
2363 | i = (xa[XA_XROOTPMAPID] |
2370 | i = (xa[XA_XROOTPMAP_ID] |
2364 | && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAPID], |
2371 | && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAP_ID], |
2365 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2372 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2366 | &nitems, &bytes_after, &prop) == Success); |
2373 | &nitems, &bytes_after, &prop) == Success); |
2367 | |
2374 | |
2368 | if (!i || prop == NULL) |
2375 | if (!i || prop == NULL) |
2369 | i = (xa[XA_XSETROOTID] |
2376 | i = (xa[XA_ESETROOT_PMAP_ID] |
2370 | && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID], |
2377 | && XGetWindowProperty (display->display, display->root, xa[XA_ESETROOT_PMAP_ID], |
2371 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2378 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2372 | &nitems, &bytes_after, &prop) == Success); |
2379 | &nitems, &bytes_after, &prop) == Success); |
2373 | |
2380 | |
2374 | if (!i || prop == NULL |
2381 | if (!i || prop == NULL |
2375 | #if TINTING |
2382 | #if TINTING |
… | |
… | |
2416 | sy = 0; |
2423 | sy = 0; |
2417 | } |
2424 | } |
2418 | |
2425 | |
2419 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2426 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2420 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
2427 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2428 | |
|
|
2429 | XSync (display->display, False); |
2421 | allowedxerror = -1; |
2430 | allowedxerror = -1; |
2422 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2431 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2423 | |
2432 | |
2424 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2433 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2425 | /* XXX: may need a delay here? */ |
2434 | /* XXX: may need a delay here? */ |
… | |
… | |
2471 | |
2480 | |
2472 | am_transparent = am_pixmap_trans = 1; |
2481 | am_transparent = am_pixmap_trans = 1; |
2473 | } |
2482 | } |
2474 | } |
2483 | } |
2475 | |
2484 | |
2476 | if (!am_pixmap_trans) |
2485 | if (am_pixmap_trans) |
|
|
2486 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); |
|
|
2487 | else |
2477 | { |
2488 | { |
2478 | unsigned int n; |
2489 | unsigned int n; |
2479 | /* |
2490 | /* |
2480 | * InheritPixmap transparency |
2491 | * InheritPixmap transparency |
2481 | */ |
2492 | */ |
… | |
… | |
2544 | if (scrollBar.win) |
2555 | if (scrollBar.win) |
2545 | { |
2556 | { |
2546 | XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); |
2557 | XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); |
2547 | scrollBar.setIdle (); |
2558 | scrollBar.setIdle (); |
2548 | scrollbar_show (0); |
2559 | scrollbar_show (0); |
|
|
2560 | } |
|
|
2561 | |
|
|
2562 | if (am_transparent) |
|
|
2563 | { |
|
|
2564 | want_refresh = want_full_refresh = 1; |
|
|
2565 | if (am_pixmap_trans) |
|
|
2566 | flush (); |
2549 | } |
2567 | } |
2550 | |
2568 | |
2551 | return pchanged; |
2569 | return pchanged; |
2552 | } |
2570 | } |
2553 | #endif |
2571 | #endif |
… | |
… | |
2705 | if (len == (size_t)-1) |
2723 | if (len == (size_t)-1) |
2706 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2724 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2707 | |
2725 | |
2708 | // assume wchar == unicode |
2726 | // assume wchar == unicode |
2709 | cmdbuf_ptr += len; |
2727 | cmdbuf_ptr += len; |
2710 | return wc; |
2728 | return wc & UNICODE_MASK; |
2711 | } |
2729 | } |
2712 | |
2730 | |
2713 | return NOCHAR; |
2731 | return NOCHAR; |
2714 | } |
2732 | } |
2715 | |
2733 | |
… | |
… | |
3513 | * ends_how is terminator used. returned input must be free()'d |
3531 | * ends_how is terminator used. returned input must be free()'d |
3514 | */ |
3532 | */ |
3515 | unsigned char * |
3533 | unsigned char * |
3516 | rxvt_term::get_to_st (unicode_t &ends_how) |
3534 | rxvt_term::get_to_st (unicode_t &ends_how) |
3517 | { |
3535 | { |
3518 | unicode_t seen_esc = 0, ch; |
3536 | unicode_t ch; |
|
|
3537 | bool seen_esc = false; |
3519 | unsigned int n = 0; |
3538 | unsigned int n = 0; |
3520 | unsigned char *s; |
|
|
3521 | unsigned char string[STRING_MAX]; |
3539 | wchar_t string[STRING_MAX]; |
3522 | |
3540 | |
3523 | while ((ch = cmd_getc ()) != NOCHAR) |
3541 | while ((ch = cmd_getc ()) != NOCHAR) |
3524 | { |
3542 | { |
3525 | if (seen_esc) |
3543 | if (seen_esc) |
3526 | { |
3544 | { |
… | |
… | |
3529 | else |
3547 | else |
3530 | return NULL; |
3548 | return NULL; |
3531 | } |
3549 | } |
3532 | else if (ch == C0_ESC) |
3550 | else if (ch == C0_ESC) |
3533 | { |
3551 | { |
3534 | seen_esc = 1; |
3552 | seen_esc = true; |
3535 | continue; |
3553 | continue; |
3536 | } |
3554 | } |
3537 | else if (ch == C0_BEL || ch == CHAR_ST) |
3555 | else if (ch == C0_BEL || ch == CHAR_ST) |
3538 | break; |
3556 | break; |
3539 | else if (ch < 0x20) |
3557 | else if (ch < 0x20) |
3540 | return NULL; /* other control character - exit */ |
3558 | return NULL; /* other control character - exit */ |
3541 | |
3559 | |
3542 | seen_esc = 0; |
3560 | seen_esc = false; |
3543 | |
3561 | |
3544 | if (n >= sizeof (string) - 1) |
3562 | if (n >= sizeof (string) - 1) |
3545 | // stop at some sane length |
3563 | // stop at some sane length |
3546 | return NULL; |
3564 | return NULL; |
3547 | |
3565 | |
… | |
… | |
3551 | string[n++] = ch; |
3569 | string[n++] = ch; |
3552 | } |
3570 | } |
3553 | |
3571 | |
3554 | string[n++] = '\0'; |
3572 | string[n++] = '\0'; |
3555 | |
3573 | |
3556 | if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) |
|
|
3557 | return NULL; |
|
|
3558 | |
|
|
3559 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3574 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3560 | strncpy (s, string, n); |
3575 | |
3561 | return s; |
3576 | return (unsigned char *)rxvt_wcstombs (string); |
3562 | } |
3577 | } |
3563 | |
3578 | |
3564 | /*----------------------------------------------------------------------*/ |
3579 | /*----------------------------------------------------------------------*/ |
3565 | /* |
3580 | /* |
3566 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3581 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
… | |
… | |
3667 | set_title (str); |
3682 | set_title (str); |
3668 | break; |
3683 | break; |
3669 | case XTerm_property: |
3684 | case XTerm_property: |
3670 | if (str[0] == '?') |
3685 | if (str[0] == '?') |
3671 | { |
3686 | { |
3672 | Atom prop = XInternAtom (display->display, str + 1, True); |
3687 | Atom prop = display->atom (str + 1); |
3673 | Atom actual_type; |
3688 | Atom actual_type; |
3674 | int actual_format; |
3689 | int actual_format; |
3675 | unsigned long nitems; |
3690 | unsigned long nitems; |
3676 | unsigned long bytes_after; |
3691 | unsigned long bytes_after; |
3677 | unsigned char *value = 0; |
3692 | unsigned char *value = 0; |
… | |
… | |
3695 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3710 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3696 | |
3711 | |
3697 | if (eq) |
3712 | if (eq) |
3698 | { |
3713 | { |
3699 | *eq = 0; |
3714 | *eq = 0; |
3700 | XChangeProperty (display->display, TermWin.parent[0], |
3715 | set_utf8_property (display->atom (str), eq + 1); |
3701 | display->atom (str), XA_STRING, 8, |
|
|
3702 | PropModeReplace, (unsigned char *)eq + 1, |
|
|
3703 | strlen (eq + 1)); |
|
|
3704 | } |
3716 | } |
3705 | else |
3717 | else |
3706 | XDeleteProperty (display->display, TermWin.parent[0], |
3718 | XDeleteProperty (display->display, TermWin.parent[0], |
3707 | display->atom (str)); |
3719 | display->atom (str)); |
3708 | } |
3720 | } |
… | |
… | |
4285 | |
4297 | |
4286 | /* ---------------------------------------------------------------------- */ |
4298 | /* ---------------------------------------------------------------------- */ |
4287 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4299 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4288 | * or generated by us in response to a query ESC sequence. |
4300 | * or generated by us in response to a query ESC sequence. |
4289 | */ |
4301 | */ |
|
|
4302 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
|
|
4303 | |
4290 | void |
4304 | void |
4291 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4305 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4292 | { |
4306 | { |
4293 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4307 | if (v_buflen == 0) |
|
|
4308 | { |
|
|
4309 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4294 | |
4310 | |
4295 | if (len) |
4311 | if ((unsigned int)written == len) |
|
|
4312 | return; |
|
|
4313 | |
|
|
4314 | data += written; |
|
|
4315 | len -= written; |
4296 | { |
4316 | } |
|
|
4317 | |
|
|
4318 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
|
|
4319 | |
|
|
4320 | memcpy (v_buffer + v_buflen, data, len); |
|
|
4321 | v_buflen += len; |
|
|
4322 | |
|
|
4323 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
|
|
4324 | } |
|
|
4325 | |
|
|
4326 | void rxvt_term::pty_write () |
|
|
4327 | { |
|
|
4328 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
|
|
4329 | |
|
|
4330 | if (written > 0) |
|
|
4331 | { |
|
|
4332 | v_buflen -= written; |
|
|
4333 | |
4297 | if (v_buflen == 0) |
4334 | if (v_buflen == 0) |
4298 | { |
4335 | { |
4299 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
|
|
4300 | |
|
|
4301 | if ((unsigned int)written == len) |
|
|
4302 | return; |
|
|
4303 | |
|
|
4304 | data += written; |
|
|
4305 | len -= written; |
|
|
4306 | } |
|
|
4307 | |
|
|
4308 | |
|
|
4309 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
|
|
4310 | |
|
|
4311 | memcpy (v_buffer + v_buflen, data, len); |
|
|
4312 | v_buflen += len; |
|
|
4313 | } |
|
|
4314 | |
|
|
4315 | for (;;) |
|
|
4316 | { |
|
|
4317 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
|
|
4318 | |
|
|
4319 | if (written > 0) |
|
|
4320 | { |
|
|
4321 | v_buflen -= written; |
|
|
4322 | |
|
|
4323 | if (v_buflen == 0) |
|
|
4324 | { |
|
|
4325 | free (v_buffer); |
4336 | free (v_buffer); |
4326 | v_buffer = 0; |
4337 | v_buffer = 0; |
4327 | v_buflen = 0; |
4338 | v_buflen = 0; |
4328 | |
4339 | |
4329 | pty_ev.set (EVENT_READ); |
4340 | pty_ev.set (EVENT_READ); |
4330 | return; |
|
|
4331 | } |
|
|
4332 | |
|
|
4333 | memmove (v_buffer, v_buffer + written, v_buflen); |
|
|
4334 | } |
|
|
4335 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
|
|
4336 | // original code just ignores this... |
|
|
4337 | destroy (); |
|
|
4338 | else |
|
|
4339 | { |
|
|
4340 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
|
|
4341 | return; |
4341 | return; |
4342 | } |
4342 | } |
|
|
4343 | |
|
|
4344 | memmove (v_buffer, v_buffer + written, v_buflen); |
4343 | } |
4345 | } |
|
|
4346 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
|
|
4347 | // original code just ignores this... |
|
|
4348 | destroy (); |
4344 | } |
4349 | } |
4345 | |
4350 | |
4346 | /*----------------------- end-of-file (C source) -----------------------*/ |
4351 | /*----------------------- end-of-file (C source) -----------------------*/ |
4347 | |
4352 | |