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.348 by sf-exg, Thu Jan 20 16:41:23 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));
361 make_current (); 359 make_current ();
362 360
363 delete this; 361 delete this;
364} 362}
365 363
364void
365rxvt_term::set_option (uint8_t opt, bool set)
366{
367 if (!opt)
368 return;
369
370 uint8_t mask = 1 << (opt & 7);
371 uint8_t &val = options [opt >> 3];
372
373 val = val & ~mask | (set ? mask : 0);
374}
375
366/*----------------------------------------------------------------------*/ 376/*----------------------------------------------------------------------*/
367/* 377/*
368 * Exit gracefully, clearing the utmp entry and restoring tty attributes 378 * Exit gracefully, clearing the utmp entry and restoring tty attributes
369 * TODO: if debugging, this should free up any known resources if we can 379 * TODO: if debugging, this should free up any known resources if we can
370 */ 380 */
382print_x_error (Display *dpy, XErrorEvent *event) 392print_x_error (Display *dpy, XErrorEvent *event)
383{ 393{
384 char buffer[BUFSIZ]; 394 char buffer[BUFSIZ];
385 char mesg[BUFSIZ]; 395 char mesg[BUFSIZ];
386 char number[32]; 396 char number[32];
387 char *mtype = "XlibMessage"; 397 const char mtype[] = "XlibMessage";
388 XGetErrorText(dpy, event->error_code, buffer, BUFSIZ); 398 XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
389 XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ); 399 XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
390 rxvt_warn ("An X Error occurred, trying to continue after report.\n"); 400 rxvt_warn ("An X Error occurred, trying to continue after report.\n");
391 rxvt_warn ("%s: %s\n", mesg, buffer); 401 rxvt_warn ("%s: %s\n", mesg, buffer);
392 XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ); 402 XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ);
511 tio->c_cc[VWERSE] = CWERASE; 521 tio->c_cc[VWERSE] = CWERASE;
512# endif 522# endif
513# ifdef VLNEXT 523# ifdef VLNEXT
514 tio->c_cc[VLNEXT] = CLNEXT; 524 tio->c_cc[VLNEXT] = CLNEXT;
515# endif 525# endif
526# ifdef VSTATUS
527 tio->c_cc[VSTATUS] = CSTATUS;
528# endif
516 529
517# if VMIN != VEOF 530# if VMIN != VEOF
518 tio->c_cc[VMIN] = 1; 531 tio->c_cc[VMIN] = 1;
519# endif 532# endif
520# if VTIME != VEOL 533# if VTIME != VEOL
943void 956void
944rxvt_term::set_colorfgbg () 957rxvt_term::set_colorfgbg ()
945{ 958{
946 unsigned int i; 959 unsigned int i;
947 const char *xpmb = ""; 960 const char *xpmb = "";
948 char fstr[sizeof ("default") + 1], bstr[sizeof ("default") + 1]; 961 char fstr[] = "default";
962 char bstr[] = "default";
949 963
950 strcpy (fstr, "default");
951 strcpy (bstr, "default");
952 for (i = Color_Black; i <= Color_White; i++) 964 for (i = Color_Black; i <= Color_White; i++)
953 if (pix_colors[Color_fg] == pix_colors[i]) 965 if (pix_colors[Color_fg] == pix_colors[i])
954 { 966 {
955 sprintf (fstr, "%d", (i - Color_Black)); 967 sprintf (fstr, "%d", i - Color_Black);
956 break; 968 break;
957 } 969 }
958 970
959 for (i = Color_Black; i <= Color_White; i++) 971 for (i = Color_Black; i <= Color_White; i++)
960 if (pix_colors[Color_bg] == pix_colors[i]) 972 if (pix_colors[Color_bg] == pix_colors[i])
961 { 973 {
962 sprintf (bstr, "%d", (i - Color_Black)); 974 sprintf (bstr, "%d", i - Color_Black);
963#ifdef BG_IMAGE_FROM_FILE 975#ifdef BG_IMAGE_FROM_FILE
964 xpmb = "default;"; 976 xpmb = "default;";
965#endif 977#endif
966 break; 978 break;
967 } 979 }
1078 } 1090 }
1079 1091
1080 if (fix_screen || old_height == 0) 1092 if (fix_screen || old_height == 0)
1081 scr_reset (); 1093 scr_reset ();
1082 1094
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
1089#ifdef USE_XIM 1095#ifdef USE_XIM
1090 IMSetPosition (); 1096 IMSetPosition ();
1091#endif 1097#endif
1092} 1098}
1093 1099
1341 p = pet[pi]; 1347 p = pet[pi];
1342 1348
1343 if (!p) 1349 if (!p)
1344 continue; 1350 continue;
1345 1351
1346 s = rxvt_splitcommastring (p); 1352 s = rxvt_strsplit (',', p);
1347 1353
1348 for (i = found = 0; !found && s[i]; i++) 1354 for (i = found = 0; !found && s[i]; i++)
1349 { 1355 {
1350 if (!strcmp (s[i], "OverTheSpot")) 1356 if (!strcmp (s[i], "OverTheSpot"))
1351 input_style = XIMPreeditPosition | XIMStatusNothing; 1357 input_style = XIMPreeditPosition | XIMStatusNothing;
1363 input_style = XIMPreeditNothing | XIMStatusNothing; 1369 input_style = XIMPreeditNothing | XIMStatusNothing;
1364 1370
1365 for (j = 0; j < xim_styles->count_styles; j++) 1371 for (j = 0; j < xim_styles->count_styles; j++)
1366 if (input_style == xim_styles->supported_styles[j]) 1372 if (input_style == xim_styles->supported_styles[j])
1367 { 1373 {
1368 rxvt_freecommastring (s); 1374 rxvt_free_strsplit (s);
1369 1375
1370 found = 1; 1376 found = 1;
1371 goto foundpet; 1377 goto foundpet;
1372 } 1378 }
1373 1379
1374 } 1380 }
1375 1381
1376 rxvt_freecommastring (s); 1382 rxvt_free_strsplit (s);
1377 } 1383 }
1378 1384
1379foundpet: 1385foundpet:
1380 1386
1381 XFree (xim_styles); 1387 XFree (xim_styles);
1537 p = rs[Rs_inputMethod]; 1543 p = rs[Rs_inputMethod];
1538 if (p && *p) 1544 if (p && *p)
1539 { 1545 {
1540 bool found = false; 1546 bool found = false;
1541 1547
1542 s = rxvt_splitcommastring (p); 1548 s = rxvt_strsplit (',', p);
1543 1549
1544 for (i = 0; s[i]; i++) 1550 for (i = 0; s[i]; i++)
1545 { 1551 {
1546 if (*s[i]) 1552 if (*s[i])
1547 { 1553 {
1553 break; 1559 break;
1554 } 1560 }
1555 } 1561 }
1556 } 1562 }
1557 1563
1558 rxvt_freecommastring (s); 1564 rxvt_free_strsplit (s);
1559 1565
1560 if (found) 1566 if (found)
1561 goto done; 1567 goto done;
1562 } 1568 }
1563 1569
1627 Window cr; 1633 Window cr;
1628 XTranslateCoordinates (dpy, parent[0], display->root, 0, 0, &x, &y, &cr); 1634 XTranslateCoordinates (dpy, parent[0], display->root, 0, 0, &x, &y, &cr);
1629} 1635}
1630 1636
1631Pixmap 1637Pixmap
1632rxvt_term::get_pixmap_property (int prop_id) 1638rxvt_term::get_pixmap_property (Atom property)
1633{ 1639{
1634 if (prop_id > 0 && prop_id < NUM_XA) 1640 Pixmap pixmap = None;
1635 if (xa[prop_id]) 1641
1636 {
1637 int aformat; 1642 int aformat;
1638 unsigned long nitems, bytes_after; 1643 unsigned long nitems, bytes_after;
1639 Atom atype; 1644 Atom atype;
1640 unsigned char *prop = NULL; 1645 unsigned char *prop;
1641 int result = XGetWindowProperty (dpy, display->root, xa[prop_id], 1646 int result = XGetWindowProperty (dpy, display->root, property,
1642 0L, 1L, False, XA_PIXMAP, &atype, &aformat, 1647 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
1643 &nitems, &bytes_after, &prop); 1648 &nitems, &bytes_after, &prop);
1644 if (result == Success && prop && atype == XA_PIXMAP) 1649 if (result == Success)
1650 {
1651 if (atype == XA_PIXMAP)
1645 return *(Pixmap *)prop; 1652 pixmap = *(Pixmap *)prop;
1653 XFree (prop);
1646 } 1654 }
1647 1655
1648 return None; 1656 return pixmap;
1649} 1657}
1650 1658
1651#ifdef HAVE_BG_PIXMAP 1659#ifdef HAVE_BG_PIXMAP
1652 1660
1653void 1661void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines