ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/command.C
(Generate patch)

Comparing rxvt-unicode/src/command.C (file contents):
Revision 1.171 by root, Wed Dec 1 02:12:18 2004 UTC vs.
Revision 1.179 by root, Wed Dec 15 05:39:08 2004 UTC

1058rxvt_term::pty_cb (io_watcher &w, short revents) 1058rxvt_term::pty_cb (io_watcher &w, short revents)
1059{ 1059{
1060 SET_R (this); 1060 SET_R (this);
1061 SET_LOCALE (locale); 1061 SET_LOCALE (locale);
1062 1062
1063 if (revents & EVENT_WRITE)
1064 tt_write (0, 0);
1065 else if (revents & EVENT_READ) 1063 if (revents & EVENT_READ)
1066 // loop, but don't allow a single term to monopolize us 1064 // loop, but don't allow a single term to monopolize us
1067 while (pty_fill ()) 1065 while (pty_fill ())
1068 if (cmd_parse ()) 1066 if (cmd_parse ())
1069 break; 1067 break;
1068
1069 if (revents & EVENT_WRITE)
1070 pty_write ();
1070} 1071}
1071 1072
1072void 1073void
1073rxvt_term::pointer_unblank () 1074rxvt_term::pointer_unblank ()
1074{ 1075{
1217 if (ev.type == KeyPress && hidden_pointer == 0) 1218 if (ev.type == KeyPress && hidden_pointer == 0)
1218 pointer_blank (); 1219 pointer_blank ();
1219 } 1220 }
1220#endif 1221#endif
1221 1222
1222 Window unused_root, unused_child; 1223 Window unused_root, unused_child;
1223 int unused_root_x, unused_root_y; 1224 int unused_root_x, unused_root_y;
1224 unsigned int unused_mask; 1225 unsigned int unused_mask;
1225 1226
1226 switch (ev.type) 1227 switch (ev.type)
1227 { 1228 {
1228 case KeyPress: 1229 case KeyPress:
1229#if ISO_14755 1230#if ISO_14755
1334 0L, 1000000L, 1335 0L, 1000000L,
1335 False, AnyPropertyType, 1336 False, AnyPropertyType,
1336 &ActualType, &ActualFormat, 1337 &ActualType, &ActualFormat,
1337 &Size, &RemainingBytes, 1338 &Size, &RemainingBytes,
1338 &data); 1339 &data);
1339 XChangeProperty (display->display, display->root, 1340 set_string_property (XA_CUT_BUFFER0, data);
1340 XA_CUT_BUFFER0, XA_STRING,
1341 8, PropModeReplace,
1342 data, strlen (data));
1343 XFree (data); 1341 XFree (data);
1344 selection_paste (display->root, XA_CUT_BUFFER0, True); 1342 selection_paste (display->root, XA_CUT_BUFFER0, true);
1345 XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); 1343 XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime);
1346 } 1344 }
1347#endif /* OFFIX_DND */ 1345#endif /* OFFIX_DND */
1348 break; 1346 break;
1349 1347
1453 resize_all_windows (width, height, 1); 1451 resize_all_windows (width, height, 1);
1454 } 1452 }
1455 1453
1456#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ 1454#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */
1457 if (options & Opt_transparent) 1455 if (options & Opt_transparent)
1458 {
1459 check_our_parents (); 1456 check_our_parents ();
1460 if (am_transparent)
1461 want_refresh = want_full_refresh = 1;
1462 }
1463#endif 1457#endif
1464 } 1458 }
1465 break; 1459 break;
1466 1460
1467 case PropertyNotify: 1461 case PropertyNotify:
1475 selection_clear (); 1469 selection_clear ();
1476 break; 1470 break;
1477 1471
1478 case SelectionNotify: 1472 case SelectionNotify:
1479 if (selection_wait == Sel_normal) 1473 if (selection_wait == Sel_normal)
1480 selection_paste (ev.xselection.requestor, 1474 selection_paste (ev.xselection.requestor, ev.xselection.property, true);
1481 ev.xselection.property, True);
1482 break; 1475 break;
1483 1476
1484 case SelectionRequest: 1477 case SelectionRequest:
1485 selection_send (ev.xselectionrequest); 1478 selection_send (ev.xselectionrequest);
1486 break; 1479 break;
1675 case PropertyNotify: 1668 case PropertyNotify:
1676 /* 1669 /*
1677 * if user used some Esetroot compatible prog to set the root bg, 1670 * 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. 1671 * use the property to determine the pixmap. We use it later on.
1679 */ 1672 */
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]) 1673 if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID]
1674 && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID])
1684 return; 1675 return;
1685 1676
1686 /* FALLTHROUGH */ 1677 /* FALLTHROUGH */
1687 case ReparentNotify: 1678 case ReparentNotify:
1688 if ((options & Opt_transparent) && check_our_parents () && am_transparent) 1679 if ((options & Opt_transparent) && check_our_parents () && am_transparent)
2358 /* 2349 /*
2359 * Make the frame window set by the window manager have 2350 * Make the frame window set by the window manager have
2360 * the root background. Some window managers put multiple nested frame 2351 * the root background. Some window managers put multiple nested frame
2361 * windows for each client, so we have to take care about that. 2352 * windows for each client, so we have to take care about that.
2362 */ 2353 */
2363 i = (xa[XA_XROOTPMAPID] 2354 i = (xa[XA_XROOTPMAP_ID]
2364 && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAPID], 2355 && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAP_ID],
2365 0L, 1L, False, XA_PIXMAP, &atype, &aformat, 2356 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
2366 &nitems, &bytes_after, &prop) == Success); 2357 &nitems, &bytes_after, &prop) == Success);
2367 2358
2368 if (!i || prop == NULL) 2359 if (!i || prop == NULL)
2369 i = (xa[XA_XSETROOTID] 2360 i = (xa[XA_ESETROOT_PMAP_ID]
2370 && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID], 2361 && XGetWindowProperty (display->display, display->root, xa[XA_ESETROOT_PMAP_ID],
2371 0L, 1L, False, XA_PIXMAP, &atype, &aformat, 2362 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
2372 &nitems, &bytes_after, &prop) == Success); 2363 &nitems, &bytes_after, &prop) == Success);
2373 2364
2374 if (!i || prop == NULL 2365 if (!i || prop == NULL
2375#if TINTING 2366#if TINTING
2416 sy = 0; 2407 sy = 0;
2417 } 2408 }
2418 2409
2419 MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); 2410 MIN_IT (nw, (unsigned int) (wrootattr.width - sx));
2420 MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); 2411 MIN_IT (nh, (unsigned int) (wrootattr.height - sy));
2412
2413 XSync (display->display, False);
2421 allowedxerror = -1; 2414 allowedxerror = -1;
2422 image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); 2415 image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap);
2423 2416
2424 /* XXX: handle BadMatch - usually because we're outside the pixmap */ 2417 /* XXX: handle BadMatch - usually because we're outside the pixmap */
2425 /* XXX: may need a delay here? */ 2418 /* XXX: may need a delay here? */
2471 2464
2472 am_transparent = am_pixmap_trans = 1; 2465 am_transparent = am_pixmap_trans = 1;
2473 } 2466 }
2474 } 2467 }
2475 2468
2476 if (!am_pixmap_trans) 2469 if (am_pixmap_trans)
2470 XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative);
2471 else
2477 { 2472 {
2478 unsigned int n; 2473 unsigned int n;
2479 /* 2474 /*
2480 * InheritPixmap transparency 2475 * InheritPixmap transparency
2481 */ 2476 */
2544 if (scrollBar.win) 2539 if (scrollBar.win)
2545 { 2540 {
2546 XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); 2541 XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative);
2547 scrollBar.setIdle (); 2542 scrollBar.setIdle ();
2548 scrollbar_show (0); 2543 scrollbar_show (0);
2544 }
2545
2546 if (am_transparent)
2547 {
2548 want_refresh = want_full_refresh = 1;
2549 if (am_pixmap_trans)
2550 flush ();
2549 } 2551 }
2550 2552
2551 return pchanged; 2553 return pchanged;
2552} 2554}
2553#endif 2555#endif
3513 * ends_how is terminator used. returned input must be free()'d 3515 * ends_how is terminator used. returned input must be free()'d
3514 */ 3516 */
3515unsigned char * 3517unsigned char *
3516rxvt_term::get_to_st (unicode_t &ends_how) 3518rxvt_term::get_to_st (unicode_t &ends_how)
3517{ 3519{
3518 unicode_t seen_esc = 0, ch; 3520 unicode_t ch;
3521 bool seen_esc = false;
3519 unsigned int n = 0; 3522 unsigned int n = 0;
3520 unsigned char *s;
3521 unsigned char string[STRING_MAX]; 3523 wchar_t string[STRING_MAX];
3522 3524
3523 while ((ch = cmd_getc ()) != NOCHAR) 3525 while ((ch = cmd_getc ()) != NOCHAR)
3524 { 3526 {
3525 if (seen_esc) 3527 if (seen_esc)
3526 { 3528 {
3529 else 3531 else
3530 return NULL; 3532 return NULL;
3531 } 3533 }
3532 else if (ch == C0_ESC) 3534 else if (ch == C0_ESC)
3533 { 3535 {
3534 seen_esc = 1; 3536 seen_esc = true;
3535 continue; 3537 continue;
3536 } 3538 }
3537 else if (ch == C0_BEL || ch == CHAR_ST) 3539 else if (ch == C0_BEL || ch == CHAR_ST)
3538 break; 3540 break;
3539 else if (ch < 0x20) 3541 else if (ch < 0x20)
3540 return NULL; /* other control character - exit */ 3542 return NULL; /* other control character - exit */
3541 3543
3542 seen_esc = 0; 3544 seen_esc = false;
3543 3545
3544 if (n >= sizeof (string) - 1) 3546 if (n >= sizeof (string) - 1)
3545 // stop at some sane length 3547 // stop at some sane length
3546 return NULL; 3548 return NULL;
3547 3549
3551 string[n++] = ch; 3553 string[n++] = ch;
3552 } 3554 }
3553 3555
3554 string[n++] = '\0'; 3556 string[n++] = '\0';
3555 3557
3556 if ((s = (unsigned char *)rxvt_malloc (n)) == NULL)
3557 return NULL;
3558
3559 ends_how = (ch == 0x5c ? C0_ESC : ch); 3558 ends_how = (ch == 0x5c ? C0_ESC : ch);
3560 strncpy (s, string, n); 3559
3561 return s; 3560 return (unsigned char *)rxvt_wcstombs (string);
3562} 3561}
3563 3562
3564/*----------------------------------------------------------------------*/ 3563/*----------------------------------------------------------------------*/
3565/* 3564/*
3566 * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' 3565 * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)'
3667 set_title (str); 3666 set_title (str);
3668 break; 3667 break;
3669 case XTerm_property: 3668 case XTerm_property:
3670 if (str[0] == '?') 3669 if (str[0] == '?')
3671 { 3670 {
3672 Atom prop = XInternAtom (display->display, str + 1, True); 3671 Atom prop = display->atom (str + 1);
3673 Atom actual_type; 3672 Atom actual_type;
3674 int actual_format; 3673 int actual_format;
3675 unsigned long nitems; 3674 unsigned long nitems;
3676 unsigned long bytes_after; 3675 unsigned long bytes_after;
3677 unsigned char *value = 0; 3676 unsigned char *value = 0;
3695 char *eq = strchr (str, '='); // constness lost, but verified to be ok 3694 char *eq = strchr (str, '='); // constness lost, but verified to be ok
3696 3695
3697 if (eq) 3696 if (eq)
3698 { 3697 {
3699 *eq = 0; 3698 *eq = 0;
3700 XChangeProperty (display->display, TermWin.parent[0], 3699 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 } 3700 }
3705 else 3701 else
3706 XDeleteProperty (display->display, TermWin.parent[0], 3702 XDeleteProperty (display->display, TermWin.parent[0],
3707 display->atom (str)); 3703 display->atom (str));
3708 } 3704 }
4285 4281
4286/* ---------------------------------------------------------------------- */ 4282/* ---------------------------------------------------------------------- */
4287/* Write data to the pty as typed by the user, pasted with the mouse, 4283/* 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. 4284 * or generated by us in response to a query ESC sequence.
4289 */ 4285 */
4286const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT
4287
4290void 4288void
4291rxvt_term::tt_write (const unsigned char *data, unsigned int len) 4289rxvt_term::tt_write (const unsigned char *data, unsigned int len)
4292{ 4290{
4293 const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT 4291 if (v_buflen == 0)
4292 {
4293 ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE));
4294 4294
4295 if (len) 4295 if ((unsigned int)written == len)
4296 return;
4297
4298 data += written;
4299 len -= written;
4296 { 4300 }
4301
4302 v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len);
4303
4304 memcpy (v_buffer + v_buflen, data, len);
4305 v_buflen += len;
4306
4307 pty_ev.set (EVENT_READ | EVENT_WRITE);
4308}
4309
4310void rxvt_term::pty_write ()
4311{
4312 int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE));
4313
4314 if (written > 0)
4315 {
4316 v_buflen -= written;
4317
4297 if (v_buflen == 0) 4318 if (v_buflen == 0)
4298 { 4319 {
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); 4320 free (v_buffer);
4326 v_buffer = 0; 4321 v_buffer = 0;
4327 v_buflen = 0; 4322 v_buflen = 0;
4328 4323
4329 pty_ev.set (EVENT_READ); 4324 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; 4325 return;
4342 } 4326 }
4327
4328 memmove (v_buffer, v_buffer + written, v_buflen);
4343 } 4329 }
4330 else if (written != -1 || (errno != EAGAIN && errno != EINTR))
4331 // original code just ignores this...
4332 destroy ();
4344} 4333}
4345 4334
4346/*----------------------- end-of-file (C source) -----------------------*/ 4335/*----------------------- end-of-file (C source) -----------------------*/
4347 4336

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines