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.335 by root, Sun Oct 24 17:52:50 2010 UTC vs.
Revision 1.350 by sf-exg, Fri Jan 28 00:21:10 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
943void 950void
944rxvt_term::set_colorfgbg () 951rxvt_term::set_colorfgbg ()
945{ 952{
946 unsigned int i; 953 unsigned int i;
947 const char *xpmb = ""; 954 const char *xpmb = "";
948 char fstr[sizeof ("default") + 1], bstr[sizeof ("default") + 1]; 955 char fstr[] = "default";
956 char bstr[] = "default";
949 957
950 strcpy (fstr, "default");
951 strcpy (bstr, "default");
952 for (i = Color_Black; i <= Color_White; i++) 958 for (i = Color_Black; i <= Color_White; i++)
953 if (pix_colors[Color_fg] == pix_colors[i]) 959 if (pix_colors[Color_fg] == pix_colors[i])
954 { 960 {
955 sprintf (fstr, "%d", (i - Color_Black)); 961 sprintf (fstr, "%d", i - Color_Black);
956 break; 962 break;
957 } 963 }
958 964
959 for (i = Color_Black; i <= Color_White; i++) 965 for (i = Color_Black; i <= Color_White; i++)
960 if (pix_colors[Color_bg] == pix_colors[i]) 966 if (pix_colors[Color_bg] == pix_colors[i])
961 { 967 {
962 sprintf (bstr, "%d", (i - Color_Black)); 968 sprintf (bstr, "%d", i - Color_Black);
963#ifdef BG_IMAGE_FROM_FILE 969#ifdef BG_IMAGE_FROM_FILE
964 xpmb = "default;"; 970 xpmb = "default;";
965#endif 971#endif
966 break; 972 break;
967 } 973 }
1070 XMoveResizeWindow (dpy, vt, 1076 XMoveResizeWindow (dpy, vt,
1071 window_vt_x, window_vt_y, 1077 window_vt_x, window_vt_y,
1072 width, height); 1078 width, height);
1073 1079
1074#ifdef HAVE_BG_PIXMAP 1080#ifdef HAVE_BG_PIXMAP
1075 if (bgPixmap.window_size_sensitive ()) 1081 if (bg_window_size_sensitive ())
1076 update_background (); 1082 update_background ();
1077#endif 1083#endif
1078 } 1084 }
1079 1085
1080 if (fix_screen || old_height == 0) 1086 if (fix_screen || old_height == 0)
1081 scr_reset (); 1087 scr_reset ();
1082
1083#ifdef HAVE_BG_PIXMAP
1084// TODO: this don't seem to have any effect - do we still need it ? If so - in which case exactly ?
1085// if (bgPixmap.pixmap)
1086// scr_touch (false);
1087#endif
1088 1088
1089#ifdef USE_XIM 1089#ifdef USE_XIM
1090 IMSetPosition (); 1090 IMSetPosition ();
1091#endif 1091#endif
1092} 1092}
1341 p = pet[pi]; 1341 p = pet[pi];
1342 1342
1343 if (!p) 1343 if (!p)
1344 continue; 1344 continue;
1345 1345
1346 s = rxvt_splitcommastring (p); 1346 s = rxvt_strsplit (',', p);
1347 1347
1348 for (i = found = 0; !found && s[i]; i++) 1348 for (i = found = 0; !found && s[i]; i++)
1349 { 1349 {
1350 if (!strcmp (s[i], "OverTheSpot")) 1350 if (!strcmp (s[i], "OverTheSpot"))
1351 input_style = XIMPreeditPosition | XIMStatusNothing; 1351 input_style = XIMPreeditPosition | XIMStatusNothing;
1363 input_style = XIMPreeditNothing | XIMStatusNothing; 1363 input_style = XIMPreeditNothing | XIMStatusNothing;
1364 1364
1365 for (j = 0; j < xim_styles->count_styles; j++) 1365 for (j = 0; j < xim_styles->count_styles; j++)
1366 if (input_style == xim_styles->supported_styles[j]) 1366 if (input_style == xim_styles->supported_styles[j])
1367 { 1367 {
1368 rxvt_freecommastring (s); 1368 rxvt_free_strsplit (s);
1369 1369
1370 found = 1; 1370 found = 1;
1371 goto foundpet; 1371 goto foundpet;
1372 } 1372 }
1373 1373
1374 } 1374 }
1375 1375
1376 rxvt_freecommastring (s); 1376 rxvt_free_strsplit (s);
1377 } 1377 }
1378 1378
1379foundpet: 1379foundpet:
1380 1380
1381 XFree (xim_styles); 1381 XFree (xim_styles);
1537 p = rs[Rs_inputMethod]; 1537 p = rs[Rs_inputMethod];
1538 if (p && *p) 1538 if (p && *p)
1539 { 1539 {
1540 bool found = false; 1540 bool found = false;
1541 1541
1542 s = rxvt_splitcommastring (p); 1542 s = rxvt_strsplit (',', p);
1543 1543
1544 for (i = 0; s[i]; i++) 1544 for (i = 0; s[i]; i++)
1545 { 1545 {
1546 if (*s[i]) 1546 if (*s[i])
1547 { 1547 {
1553 break; 1553 break;
1554 } 1554 }
1555 } 1555 }
1556 } 1556 }
1557 1557
1558 rxvt_freecommastring (s); 1558 rxvt_free_strsplit (s);
1559 1559
1560 if (found) 1560 if (found)
1561 goto done; 1561 goto done;
1562 } 1562 }
1563 1563
1627 Window cr; 1627 Window cr;
1628 XTranslateCoordinates (dpy, parent[0], display->root, 0, 0, &x, &y, &cr); 1628 XTranslateCoordinates (dpy, parent[0], display->root, 0, 0, &x, &y, &cr);
1629} 1629}
1630 1630
1631Pixmap 1631Pixmap
1632rxvt_term::get_pixmap_property (int prop_id) 1632rxvt_term::get_pixmap_property (Atom property)
1633{ 1633{
1634 if (prop_id > 0 && prop_id < NUM_XA) 1634 Pixmap pixmap = None;
1635 if (xa[prop_id]) 1635
1636 {
1637 int aformat; 1636 int aformat;
1638 unsigned long nitems, bytes_after; 1637 unsigned long nitems, bytes_after;
1639 Atom atype; 1638 Atom atype;
1640 unsigned char *prop = NULL; 1639 unsigned char *prop;
1641 int result = XGetWindowProperty (dpy, display->root, xa[prop_id], 1640 int result = XGetWindowProperty (dpy, display->root, property,
1642 0L, 1L, False, XA_PIXMAP, &atype, &aformat, 1641 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
1643 &nitems, &bytes_after, &prop); 1642 &nitems, &bytes_after, &prop);
1644 if (result == Success && prop && atype == XA_PIXMAP) 1643 if (result == Success)
1644 {
1645 if (atype == XA_PIXMAP)
1645 return *(Pixmap *)prop; 1646 pixmap = *(Pixmap *)prop;
1647 XFree (prop);
1646 } 1648 }
1647 1649
1648 return None; 1650 return pixmap;
1649} 1651}
1650 1652
1651#ifdef HAVE_BG_PIXMAP 1653#ifdef HAVE_BG_PIXMAP
1652 1654
1653void 1655void
1654rxvt_term::update_background () 1656rxvt_term::update_background ()
1655{ 1657{
1656 if (update_background_ev.is_active ()) 1658 if (update_background_ev.is_active ())
1657 return; 1659 return;
1658 1660
1659 bgPixmap.invalidate (); 1661 bg_invalidate ();
1660 1662
1661 ev_tstamp to_wait = 0.5 - (ev::now () - bgPixmap.valid_since); 1663 ev_tstamp to_wait = 0.5 - (ev::now () - bg_valid_since);
1662 1664
1663 if (to_wait <= 0.) 1665 if (to_wait <= 0.)
1664 bgPixmap.render (); 1666 bg_render ();
1665 else 1667 else
1666 update_background_ev.start (to_wait); 1668 update_background_ev.start (to_wait);
1667} 1669}
1668 1670
1669void 1671void
1670rxvt_term::update_background_cb (ev::timer &w, int revents) 1672rxvt_term::update_background_cb (ev::timer &w, int revents)
1671{ 1673{
1672 make_current (); 1674 make_current ();
1673 1675
1674 update_background_ev.stop (); 1676 update_background_ev.stop ();
1675 bgPixmap.render (); 1677 bg_render ();
1676 refresh_check (); 1678 refresh_check ();
1677} 1679}
1678 1680
1679#endif /* HAVE_BG_PIXMAP */ 1681#endif /* HAVE_BG_PIXMAP */
1680 1682

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines