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

Comparing rxvt-unicode/src/main.C (file contents):
Revision 1.334 by sf-exg, Fri Oct 22 16:49:26 2010 UTC vs.
Revision 1.351 by sf-exg, Tue Feb 1 00:41:01 2011 UTC

11 * Copyright (c) 1997 mj olesen <olesen@me.QueensU.CA> 11 * Copyright (c) 1997 mj olesen <olesen@me.QueensU.CA>
12 * - extensive modifications 12 * - extensive modifications
13 * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> 13 * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de>
14 * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> 14 * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com>
15 * - extensive modifications 15 * - extensive modifications
16 * Copyright (c) 2003-2008 Marc Lehmann <pcg@goof.com> 16 * Copyright (c) 2003-2010 Marc Lehmann <pcg@goof.com>
17 * 17 *
18 * This program is free software; you can redistribute it and/or modify 18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by 19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or 20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version. 21 * (at your option) any later version.
96text_t rxvt_composite_vec::compose (unicode_t c1, unicode_t c2) 96text_t rxvt_composite_vec::compose (unicode_t c1, unicode_t c2)
97{ 97{
98 compose_char *cc; 98 compose_char *cc;
99 99
100 // break compose chains, as stupid readline really likes to duplicate 100 // break compose chains, as stupid readline really likes to duplicate
101 // composing characters for some reason near the end of a line. 101 // composing characters for some reason, near the end of a line.
102 cc = (*this)[c1]; 102 cc = (*this)[c1];
103 while (cc) 103 while (cc)
104 { 104 {
105 if (cc->c2 == c2) return c1; 105 if (cc->c2 == c2) return c1;
106 cc = (*this)[cc->c1]; 106 cc = (*this)[cc->c1];
107 } 107 }
108 108
109 // check to see whether this combination already exists otherwise 109 // check to see whether this combination already exists otherwise
110 for (cc = v.end (); cc-- > v.begin (); ) 110 for (cc = v.end (); cc-- > v.begin (); )
111 {
112 if (cc->c1 == c1 && cc->c2 == c2) 111 if (cc->c1 == c1 && cc->c2 == c2)
113 return COMPOSE_LO + (cc - v.begin ()); 112 return COMPOSE_LO + (cc - v.begin ());
114 }
115 113
116 // allocate a new combination 114 // allocate a new combination
117 if (v.size () == COMPOSE_HI - COMPOSE_LO + 1) 115 if (v.size () == COMPOSE_HI - COMPOSE_LO + 1)
118 { 116 {
119 static int seen; 117 static int seen;
120 118
121 if (!seen++) 119 if (!seen++)
122 fprintf (stderr, "too many unrepresentable composite characters, try --enable-unicode3\n"); 120 rxvt_warn ("too many unrepresentable composite characters, try --enable-unicode3\n");
123 121
124 return REPLACEMENT_CHAR; 122 return REPLACEMENT_CHAR;
125 } 123 }
126 124
127 v.push_back (compose_char (c1, c2)); 125 v.push_back (compose_char (c1, c2));
228 delete fontset[i]; 226 delete fontset[i];
229#endif 227#endif
230 delete fontset[0]; 228 delete fontset[0];
231 229
232#ifdef HAVE_BG_PIXMAP 230#ifdef HAVE_BG_PIXMAP
233 bgPixmap.destroy (); 231 bg_destroy ();
234#endif
235#ifdef HAVE_AFTERIMAGE
236 if (asv)
237 destroy_asvisual (asv, 0);
238 if (asimman)
239 destroy_image_manager (asimman, 0);
240#endif 232#endif
241 233
242 if (display) 234 if (display)
243 { 235 {
244 selection_clear (); 236 selection_clear ();
361 make_current (); 353 make_current ();
362 354
363 delete this; 355 delete this;
364} 356}
365 357
358void
359rxvt_term::set_option (uint8_t opt, bool set)
360{
361 if (!opt)
362 return;
363
364 uint8_t mask = 1 << (opt & 7);
365 uint8_t &val = options [opt >> 3];
366
367 val = val & ~mask | (set ? mask : 0);
368}
369
366/*----------------------------------------------------------------------*/ 370/*----------------------------------------------------------------------*/
367/* 371/*
368 * Exit gracefully, clearing the utmp entry and restoring tty attributes 372 * Exit gracefully, clearing the utmp entry and restoring tty attributes
369 * TODO: if debugging, this should free up any known resources if we can 373 * TODO: if debugging, this should free up any known resources if we can
370 */ 374 */
382print_x_error (Display *dpy, XErrorEvent *event) 386print_x_error (Display *dpy, XErrorEvent *event)
383{ 387{
384 char buffer[BUFSIZ]; 388 char buffer[BUFSIZ];
385 char mesg[BUFSIZ]; 389 char mesg[BUFSIZ];
386 char number[32]; 390 char number[32];
387 char *mtype = "XlibMessage"; 391 const char mtype[] = "XlibMessage";
388 XGetErrorText(dpy, event->error_code, buffer, BUFSIZ); 392 XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
389 XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ); 393 XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
390 rxvt_warn ("An X Error occurred, trying to continue after report.\n"); 394 rxvt_warn ("An X Error occurred, trying to continue after report.\n");
391 rxvt_warn ("%s: %s\n", mesg, buffer); 395 rxvt_warn ("%s: %s\n", mesg, buffer);
392 XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ); 396 XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ);
511 tio->c_cc[VWERSE] = CWERASE; 515 tio->c_cc[VWERSE] = CWERASE;
512# endif 516# endif
513# ifdef VLNEXT 517# ifdef VLNEXT
514 tio->c_cc[VLNEXT] = CLNEXT; 518 tio->c_cc[VLNEXT] = CLNEXT;
515# endif 519# endif
520# ifdef VSTATUS
521 tio->c_cc[VSTATUS] = CSTATUS;
522# endif
516 523
517# if VMIN != VEOF 524# if VMIN != VEOF
518 tio->c_cc[VMIN] = 1; 525 tio->c_cc[VMIN] = 1;
519# endif 526# endif
520# if VTIME != VEOL 527# if VTIME != VEOL
553 rxvt_get_ttymode (&rxvt_term::def_tio); 560 rxvt_get_ttymode (&rxvt_term::def_tio);
554 561
555 // get rid of stdin/stdout as we don't need them, to free resources 562 // get rid of stdin/stdout as we don't need them, to free resources
556 dup2 (STDERR_FILENO, STDIN_FILENO); 563 dup2 (STDERR_FILENO, STDIN_FILENO);
557 dup2 (STDERR_FILENO, STDOUT_FILENO); 564 dup2 (STDERR_FILENO, STDOUT_FILENO);
558
559 ptytty::init ();
560 565
561 if (!ev_default_loop ()) 566 if (!ev_default_loop ())
562 rxvt_fatal ("cannot initialise libev (bad value for LIBEV_METHODS?)\n"); 567 rxvt_fatal ("cannot initialise libev (bad value for LIBEV_METHODS?)\n");
563 568
564 rxvt_environ = environ; 569 rxvt_environ = environ;
945void 950void
946rxvt_term::set_colorfgbg () 951rxvt_term::set_colorfgbg ()
947{ 952{
948 unsigned int i; 953 unsigned int i;
949 const char *xpmb = ""; 954 const char *xpmb = "";
950 char fstr[sizeof ("default") + 1], bstr[sizeof ("default") + 1]; 955 char fstr[] = "default";
956 char bstr[] = "default";
951 957
952 strcpy (fstr, "default");
953 strcpy (bstr, "default");
954 for (i = Color_Black; i <= Color_White; i++) 958 for (i = Color_Black; i <= Color_White; i++)
955 if (pix_colors[Color_fg] == pix_colors[i]) 959 if (pix_colors[Color_fg] == pix_colors[i])
956 { 960 {
957 sprintf (fstr, "%d", (i - Color_Black)); 961 sprintf (fstr, "%d", i - Color_Black);
958 break; 962 break;
959 } 963 }
960 964
961 for (i = Color_Black; i <= Color_White; i++) 965 for (i = Color_Black; i <= Color_White; i++)
962 if (pix_colors[Color_bg] == pix_colors[i]) 966 if (pix_colors[Color_bg] == pix_colors[i])
963 { 967 {
964 sprintf (bstr, "%d", (i - Color_Black)); 968 sprintf (bstr, "%d", i - Color_Black);
965#ifdef BG_IMAGE_FROM_FILE 969#ifdef BG_IMAGE_FROM_FILE
966 xpmb = "default;"; 970 xpmb = "default;";
967#endif 971#endif
968 break; 972 break;
969 } 973 }
1072 XMoveResizeWindow (dpy, vt, 1076 XMoveResizeWindow (dpy, vt,
1073 window_vt_x, window_vt_y, 1077 window_vt_x, window_vt_y,
1074 width, height); 1078 width, height);
1075 1079
1076#ifdef HAVE_BG_PIXMAP 1080#ifdef HAVE_BG_PIXMAP
1077 if (bgPixmap.window_size_sensitive ()) 1081 if (bg_window_size_sensitive ())
1078 update_background (); 1082 update_background ();
1079#endif 1083#endif
1080 } 1084 }
1081 1085
1082 if (fix_screen || old_height == 0) 1086 if (fix_screen || old_height == 0)
1083 scr_reset (); 1087 scr_reset ();
1084
1085#ifdef HAVE_BG_PIXMAP
1086// TODO: this don't seem to have any effect - do we still need it ? If so - in which case exactly ?
1087// if (bgPixmap.pixmap)
1088// scr_touch (false);
1089#endif
1090 1088
1091#ifdef USE_XIM 1089#ifdef USE_XIM
1092 IMSetPosition (); 1090 IMSetPosition ();
1093#endif 1091#endif
1094} 1092}
1177 1175
1178 atom = XInternAtom (dpy, server, False); 1176 atom = XInternAtom (dpy, server, False);
1179 win = XGetSelectionOwner (dpy, atom); 1177 win = XGetSelectionOwner (dpy, atom);
1180 1178
1181 if (win != None) 1179 if (win != None)
1182 return True; 1180 return true;
1183 } 1181 }
1184 1182
1185 return False; 1183 return false;
1186} 1184}
1187 1185
1188void 1186void
1189rxvt_term::IMSendSpot () 1187rxvt_term::IMSendSpot ()
1190{ 1188{
1343 p = pet[pi]; 1341 p = pet[pi];
1344 1342
1345 if (!p) 1343 if (!p)
1346 continue; 1344 continue;
1347 1345
1348 s = rxvt_splitcommastring (p); 1346 s = rxvt_strsplit (',', p);
1349 1347
1350 for (i = found = 0; !found && s[i]; i++) 1348 for (i = found = 0; !found && s[i]; i++)
1351 { 1349 {
1352 if (!strcmp (s[i], "OverTheSpot")) 1350 if (!strcmp (s[i], "OverTheSpot"))
1353 input_style = XIMPreeditPosition | XIMStatusNothing; 1351 input_style = XIMPreeditPosition | XIMStatusNothing;
1365 input_style = XIMPreeditNothing | XIMStatusNothing; 1363 input_style = XIMPreeditNothing | XIMStatusNothing;
1366 1364
1367 for (j = 0; j < xim_styles->count_styles; j++) 1365 for (j = 0; j < xim_styles->count_styles; j++)
1368 if (input_style == xim_styles->supported_styles[j]) 1366 if (input_style == xim_styles->supported_styles[j])
1369 { 1367 {
1370 rxvt_freecommastring (s); 1368 rxvt_free_strsplit (s);
1371 1369
1372 found = 1; 1370 found = 1;
1373 goto foundpet; 1371 goto foundpet;
1374 } 1372 }
1375 1373
1376 } 1374 }
1377 1375
1378 rxvt_freecommastring (s); 1376 rxvt_free_strsplit (s);
1379 } 1377 }
1380 1378
1381foundpet: 1379foundpet:
1382 1380
1383 XFree (xim_styles); 1381 XFree (xim_styles);
1539 p = rs[Rs_inputMethod]; 1537 p = rs[Rs_inputMethod];
1540 if (p && *p) 1538 if (p && *p)
1541 { 1539 {
1542 bool found = false; 1540 bool found = false;
1543 1541
1544 s = rxvt_splitcommastring (p); 1542 s = rxvt_strsplit (',', p);
1545 1543
1546 for (i = 0; s[i]; i++) 1544 for (i = 0; s[i]; i++)
1547 { 1545 {
1548 if (*s[i]) 1546 if (*s[i])
1549 { 1547 {
1555 break; 1553 break;
1556 } 1554 }
1557 } 1555 }
1558 } 1556 }
1559 1557
1560 rxvt_freecommastring (s); 1558 rxvt_free_strsplit (s);
1561 1559
1562 if (found) 1560 if (found)
1563 goto done; 1561 goto done;
1564 } 1562 }
1565 1563
1629 Window cr; 1627 Window cr;
1630 XTranslateCoordinates (dpy, parent[0], display->root, 0, 0, &x, &y, &cr); 1628 XTranslateCoordinates (dpy, parent[0], display->root, 0, 0, &x, &y, &cr);
1631} 1629}
1632 1630
1633Pixmap 1631Pixmap
1634rxvt_term::get_pixmap_property (int prop_id) 1632rxvt_term::get_pixmap_property (Atom property)
1635{ 1633{
1636 if (prop_id > 0 && prop_id < NUM_XA) 1634 Pixmap pixmap = None;
1637 if (xa[prop_id]) 1635
1638 {
1639 int aformat; 1636 int aformat;
1640 unsigned long nitems, bytes_after; 1637 unsigned long nitems, bytes_after;
1641 Atom atype; 1638 Atom atype;
1642 unsigned char *prop = NULL; 1639 unsigned char *prop;
1643 int result = XGetWindowProperty (dpy, display->root, xa[prop_id], 1640 int result = XGetWindowProperty (dpy, display->root, property,
1644 0L, 1L, False, XA_PIXMAP, &atype, &aformat, 1641 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
1645 &nitems, &bytes_after, &prop); 1642 &nitems, &bytes_after, &prop);
1646 if (result == Success && prop && atype == XA_PIXMAP) 1643 if (result == Success)
1644 {
1645 if (atype == XA_PIXMAP)
1647 return *(Pixmap *)prop; 1646 pixmap = *(Pixmap *)prop;
1647 XFree (prop);
1648 } 1648 }
1649 1649
1650 return None; 1650 return pixmap;
1651} 1651}
1652 1652
1653#ifdef HAVE_BG_PIXMAP 1653#ifdef HAVE_BG_PIXMAP
1654 1654
1655void 1655void
1656rxvt_term::update_background () 1656rxvt_term::update_background ()
1657{ 1657{
1658 if (update_background_ev.is_active ()) 1658 if (update_background_ev.is_active ())
1659 return; 1659 return;
1660 1660
1661 bgPixmap.invalidate (); 1661 bg_invalidate ();
1662 1662
1663 ev_tstamp to_wait = 0.5 - (ev::now () - bgPixmap.valid_since); 1663 ev_tstamp to_wait = 0.5 - (ev::now () - bg_valid_since);
1664 1664
1665 if (to_wait <= 0.) 1665 if (to_wait <= 0.)
1666 bgPixmap.render (); 1666 bg_render ();
1667 else 1667 else
1668 update_background_ev.start (to_wait); 1668 update_background_ev.start (to_wait);
1669} 1669}
1670 1670
1671void 1671void
1672rxvt_term::update_background_cb (ev::timer &w, int revents) 1672rxvt_term::update_background_cb (ev::timer &w, int revents)
1673{ 1673{
1674 make_current (); 1674 make_current ();
1675 1675
1676 update_background_ev.stop (); 1676 update_background_ev.stop ();
1677 bgPixmap.render (); 1677 bg_render ();
1678 refresh_check (); 1678 refresh_check ();
1679} 1679}
1680 1680
1681#endif /* HAVE_BG_PIXMAP */ 1681#endif /* HAVE_BG_PIXMAP */
1682 1682

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines