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.114 by root, Tue Sep 7 06:19:45 2004 UTC vs.
Revision 1.128 by root, Mon Jan 17 00:59:23 2005 UTC

32 32
33#include "../config.h" /* NECESSARY */ 33#include "../config.h" /* NECESSARY */
34#include "rxvt.h" /* NECESSARY */ 34#include "rxvt.h" /* NECESSARY */
35#include "main.intpro" /* PROTOS for internal routines */ 35#include "main.intpro" /* PROTOS for internal routines */
36 36
37#include <signal.h> 37#include <csignal>
38#include <cstring>
38 39
39#ifdef TTY_GID_SUPPORT 40#ifdef TTY_GID_SUPPORT
40# include <grp.h> 41# include <grp.h>
41#endif 42#endif
42 43
43#ifdef HAVE_TERMIOS_H 44#ifdef HAVE_TERMIOS_H
44# include <termios.h> 45# include <termios.h>
45#endif 46#endif
46 47
47#include <cstring> 48#ifdef KEYSYM_RESOURCE
49# include "keyboard.h"
50#endif
48 51
49vector<rxvt_term *> rxvt_term::termlist; 52vector<rxvt_term *> rxvt_term::termlist;
50 53
51static char curlocale[128]; 54static char curlocale[128];
52 55
168 incr_ev (this, &rxvt_term::incr_cb) 171 incr_ev (this, &rxvt_term::incr_cb)
169{ 172{
170 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; 173 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base;
171 174
172 termlist.push_back (this); 175 termlist.push_back (this);
176
177#ifdef KEYSYM_RESOURCE
178 keyboard = new keyboard_manager;
179
180 if (!keyboard)
181 rxvt_fatal ("out of memory, aborting.\n");
182#endif
173} 183}
174 184
175rxvt_term::~rxvt_term () 185rxvt_term::~rxvt_term ()
176{ 186{
177 termlist.erase (find (termlist.begin (), termlist.end(), this)); 187 termlist.erase (find (termlist.begin (), termlist.end(), this));
259 free (env_windowid); 269 free (env_windowid);
260 free (env_display); 270 free (env_display);
261 free (env_term); 271 free (env_term);
262 free (env_colorfgbg); 272 free (env_colorfgbg);
263 free (locale); 273 free (locale);
264#if 0 274 free (v_buffer);
265 free (codeset); 275 free (incr_buf);
266#endif
267 276
268 delete envv; 277 delete envv;
269 delete argv; 278 delete argv;
279
280#ifdef KEYSYM_RESOURCE
281 delete keyboard;
282#endif
270} 283}
271 284
272void 285void
273rxvt_term::destroy () 286rxvt_term::destroy ()
274{ 287{
332bool 345bool
333rxvt_term::init (int argc, const char *const *argv) 346rxvt_term::init (int argc, const char *const *argv)
334{ 347{
335 SET_R (this); 348 SET_R (this);
336 349
350 set_locale ("");
351
337 if (!init_vars ()) 352 if (!init_vars ())
338 return false; 353 return false;
339 354
340 init_secondary (); 355 init_secondary ();
341 356
342 const char **cmd_argv = init_resources (argc, argv); 357 const char **cmd_argv = init_resources (argc, argv);
343 358
344 set_locale (""); 359#ifdef KEYSYM_RESOURCE
360 keyboard->register_done ();
361#endif
345 362
346#if MENUBAR_MAX 363#if MENUBAR_MAX
347 menubar_read (rs[Rs_menu]); 364 menubar_read (rs[Rs_menu]);
348#endif 365#endif
349#ifdef HAVE_SCROLLBARS 366#ifdef HAVE_SCROLLBARS
382 XMapWindow (display->display, TermWin.parent[0]); 399 XMapWindow (display->display, TermWin.parent[0]);
383 400
384 set_colorfgbg (); 401 set_colorfgbg ();
385 402
386 init_command (cmd_argv); 403 init_command (cmd_argv);
404
405 free (cmd_argv);
387 406
388 pty_ev.start (pty.pty, EVENT_READ); 407 pty_ev.start (pty.pty, EVENT_READ);
389 408
390 check_ev.start (); 409 check_ev.start ();
391 410
783 802
784 delete TermWin.fontset[0]; 803 delete TermWin.fontset[0];
785 TermWin.fontset[0] = fs; 804 TermWin.fontset[0] = fs;
786 805
787 prop = (*fs)[1]->properties (); 806 prop = (*fs)[1]->properties ();
807 prop.height += TermWin.lineSpace;
788 fs->set_prop (prop); 808 fs->set_prop (prop);
789 809
790 TermWin.fwidth = prop.width; 810 TermWin.fwidth = prop.width;
791 TermWin.fheight = prop.height; 811 TermWin.fheight = prop.height;
792 TermWin.fweight = prop.weight; 812 TermWin.fweight = prop.weight;
831 } 851 }
832 852
833 return true; 853 return true;
834} 854}
835 855
856void rxvt_term::set_string_property (Atom prop, const char *str, int len)
857{
858 // TODO: SMART_WINDOW_TITLE
859 XChangeProperty (display->display, TermWin.parent[0],
860 prop, XA_STRING, 8, PropModeReplace,
861 (const unsigned char *)str, len >= 0 ? len : strlen (str));
862}
863
864void rxvt_term::set_utf8_property (Atom prop, const char *str, int len)
865{
866 // TODO: SMART_WINDOW_TITLE
867 wchar_t *ws = rxvt_mbstowcs (str, len);
868 char *s = rxvt_wcstoutf8 (ws);
869
870 XChangeProperty (display->display, TermWin.parent[0],
871 prop, xa[XA_UTF8_STRING], 8, PropModeReplace,
872 (const unsigned char *)s, strlen (s));
873
874 free (s);
875 free (ws);
876}
877
836/*----------------------------------------------------------------------*/ 878/*----------------------------------------------------------------------*/
837/*----------------------------------------------------------------------*/ 879/*----------------------------------------------------------------------*/
838/* xterm sequences - title, iconName, color (exptl) */ 880/* xterm sequences - title, iconName, color (exptl) */
839void 881void
840rxvt_term::set_title (const char *str) 882rxvt_term::set_title (const char *str)
841{ 883{
842#ifdef SMART_WINDOW_TITLE 884 set_string_property (XA_WM_NAME, str);
843 char *name; 885#if ENABLE_FRILLS
844 886 set_utf8_property (xa[XA_NET_WM_NAME], str);
845 if (!XFetchName (display->display, TermWin.parent[0], &name))
846 name = NULL;
847
848 if (name == NULL || strcmp (name, str))
849#endif
850 XStoreName (display->display, TermWin.parent[0], str);
851
852#ifdef SMART_WINDOW_TITLE
853 if (name)
854 XFree (name);
855#endif 887#endif
856} 888}
857 889
858void 890void
859rxvt_term::set_icon_name (const char *str) 891rxvt_term::set_icon_name (const char *str)
860{ 892{
861#ifdef SMART_WINDOW_TITLE 893 set_string_property (XA_WM_ICON_NAME, str);
862 char *name; 894#if ENABLE_FRILLS
863 895 set_utf8_property (xa[XA_NET_WM_ICON_NAME], str);
864 if (!XGetIconName (display->display, TermWin.parent[0], &name))
865 name = NULL;
866
867 if (name == NULL || strcmp (name, str))
868#endif
869 XSetIconName (display->display, TermWin.parent[0], str);
870
871#ifdef SMART_WINDOW_TITLE
872 if (name)
873 XFree (name);
874#endif 896#endif
875} 897}
876 898
877#ifdef XTERM_COLOR_CHANGE 899#ifdef XTERM_COLOR_CHANGE
878void 900void
997 1019
998 sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr); 1020 sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr);
999} 1021}
1000 1022
1001/*----------------------------------------------------------------------*/ 1023/*----------------------------------------------------------------------*/
1002/*
1003 * Colour determination for low colour displays, routine from
1004 * Hans de Goede <hans@highrise.nl>
1005 */
1006 1024
1007int 1025int
1008rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) 1026rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour)
1009{ 1027{
1010 if (!screen_in_out->set (display, colour)) 1028 if (!screen_in_out->set (display, colour))
1299 { 1317 {
1300 im_destroy (); 1318 im_destroy ();
1301 return false; 1319 return false;
1302 } 1320 }
1303 1321
1304 p = rs[Rs_preeditType] ? rs[Rs_preeditType] : "OverTheSpot,OffTheSpot,Root,None"; 1322 const char *pet[] = { rs[Rs_preeditType], "OverTheSpot,OffTheSpot,Root,None" };
1323
1324 for (int pi = 0; pi < 2; pi++)
1325 {
1326 p = pet[pi];
1327
1328 if (!p)
1329 continue;
1330
1305 s = rxvt_splitcommastring (p); 1331 s = rxvt_splitcommastring (p);
1306 1332
1307 for (i = found = 0; !found && s[i]; i++) 1333 for (i = found = 0; !found && s[i]; i++)
1308 { 1334 {
1309 if (!strcmp (s[i], "OverTheSpot")) 1335 if (!strcmp (s[i], "OverTheSpot"))
1310 input_style = (XIMPreeditPosition | XIMStatusNothing); 1336 input_style = (XIMPreeditPosition | XIMStatusNothing);
1311 else if (!strcmp (s[i], "OffTheSpot")) 1337 else if (!strcmp (s[i], "OffTheSpot"))
1312 input_style = (XIMPreeditArea | XIMStatusArea); 1338 input_style = (XIMPreeditArea | XIMStatusArea);
1313 else if (!strcmp (s[i], "Root")) 1339 else if (!strcmp (s[i], "Root"))
1314 input_style = (XIMPreeditNothing | XIMStatusNothing); 1340 input_style = (XIMPreeditNothing | XIMStatusNothing);
1315 else if (!strcmp (s[i], "None")) 1341 else if (!strcmp (s[i], "None"))
1316 input_style = (XIMPreeditNone | XIMStatusNone); 1342 input_style = (XIMPreeditNone | XIMStatusNone);
1317 1343
1318 for (j = 0; j < xim_styles->count_styles; j++) 1344 for (j = 0; j < xim_styles->count_styles; j++)
1319 if (input_style == xim_styles->supported_styles[j]) 1345 if (input_style == xim_styles->supported_styles[j])
1320 { 1346 {
1347 rxvt_freecommastring (s);
1348
1321 found = 1; 1349 found = 1;
1322 break; 1350 goto foundpet;
1351 }
1352
1323 } 1353 }
1324 }
1325 1354
1326 for (i = 0; s[i]; i++) 1355 rxvt_freecommastring (s);
1327 free (s[i]); 1356 }
1328 1357
1329 free (s); 1358foundpet:
1359
1330 XFree (xim_styles); 1360 XFree (xim_styles);
1331 1361
1332 if (!found) 1362 if (!found)
1333 { 1363 {
1334 im_destroy (); 1364 im_destroy ();
1459 if (p && *p) 1489 if (p && *p)
1460 { 1490 {
1461 bool found = false; 1491 bool found = false;
1462 1492
1463 s = rxvt_splitcommastring (p); 1493 s = rxvt_splitcommastring (p);
1494
1464 for (i = 0; s[i]; i++) 1495 for (i = 0; s[i]; i++)
1465 { 1496 {
1466 if (*s[i]) 1497 if (*s[i])
1467 { 1498 {
1468 strcpy (buf, "@im="); 1499 strcpy (buf, "@im=");
1472 found = true; 1503 found = true;
1473 break; 1504 break;
1474 } 1505 }
1475 } 1506 }
1476 } 1507 }
1477 for (i = 0; s[i]; i++) 1508
1478 free (s[i]); 1509 rxvt_freecommastring (s);
1479 free (s);
1480 1510
1481 if (found) 1511 if (found)
1482 goto done; 1512 goto done;
1483 } 1513 }
1484 1514

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines