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.151 by root, Wed Dec 21 19:50:16 2005 UTC vs.
Revision 1.164 by root, Fri Jan 6 05:37:59 2006 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-2004 Marc Lehmann <pcg@goof.com> 16 * Copyright (c) 2003-2006 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.
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 *---------------------------------------------------------------------*/ 31 *---------------------------------------------------------------------*/
32 32
33#include "../config.h" /* NECESSARY */ 33#include "../config.h" /* NECESSARY */
34#include "rxvt.h" /* NECESSARY */ 34#include "rxvt.h" /* NECESSARY */
35#include "keyboard.h"
36#include "rxvtperl.h"
35 37
36#include <limits> 38#include <limits>
37 39
38#include <csignal> 40#include <csignal>
39#include <cstring> 41#include <cstring>
44 46
45#ifdef HAVE_TERMIOS_H 47#ifdef HAVE_TERMIOS_H
46# include <termios.h> 48# include <termios.h>
47#endif 49#endif
48 50
49#ifdef KEYSYM_RESOURCE
50# include "keyboard.h"
51#endif
52
53vector<rxvt_term *> rxvt_term::termlist; 51vector<rxvt_term *> rxvt_term::termlist;
54 52
55static char curlocale[128]; 53static char curlocale[128], savelocale[128];
56 54
57bool 55bool
58rxvt_set_locale (const char *locale) 56rxvt_set_locale (const char *locale)
59{ 57{
60 if (!locale || !strncmp (locale, curlocale, 128)) 58 if (!locale || !strncmp (locale, curlocale, 128))
61 return false; 59 return false;
62 60
63 strncpy (curlocale, locale, 128); 61 strncpy (curlocale, locale, 128);
64 setlocale (LC_CTYPE, curlocale); 62 setlocale (LC_CTYPE, curlocale);
65 return true; 63 return true;
64}
65
66bool
67rxvt_push_locale (const char *locale)
68{
69 strcpy (savelocale, curlocale);
70 rxvt_set_locale (locale);
71}
72
73void
74rxvt_pop_locale ()
75{
76 rxvt_set_locale (savelocale);
66} 77}
67 78
68#if ENABLE_COMBINING 79#if ENABLE_COMBINING
69class rxvt_composite_vec rxvt_composite; 80class rxvt_composite_vec rxvt_composite;
70 81
195 pty.put (); 206 pty.put ();
196} 207}
197 208
198rxvt_term::~rxvt_term () 209rxvt_term::~rxvt_term ()
199{ 210{
211 HOOK_INVOKE ((this, HOOK_DESTROY, DT_END));
212
200 termlist.erase (find (termlist.begin (), termlist.end(), this)); 213 termlist.erase (find (termlist.begin (), termlist.end(), this));
201 214
202 emergency_cleanup (); 215 emergency_cleanup ();
203 216
204#if ENABLE_STYLES 217#if ENABLE_STYLES
286 delete argv; 299 delete argv;
287 300
288#ifdef KEYSYM_RESOURCE 301#ifdef KEYSYM_RESOURCE
289 delete keyboard; 302 delete keyboard;
290#endif 303#endif
304}
305
306void
307rxvt_term::child_exit ()
308{
309 cmd_pid = 0;
310
311 if (!OPTION (Opt_hold))
312 destroy ();
291} 313}
292 314
293void 315void
294rxvt_term::destroy () 316rxvt_term::destroy ()
295{ 317{
460 482
461#if MENUBAR_MAX 483#if MENUBAR_MAX
462 menubar_read (rs[Rs_menu]); 484 menubar_read (rs[Rs_menu]);
463#endif 485#endif
464#ifdef HAVE_SCROLLBARS 486#ifdef HAVE_SCROLLBARS
465 if (options & Opt_scrollBar) 487 if (OPTION (Opt_scrollBar))
466 scrollBar.setIdle (); /* set existence for size calculations */ 488 scrollBar.setIdle (); /* set existence for size calculations */
489#endif
490
491#if ENABLE_PERL
492 if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1])
493 || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2])
494 || (rs[Rs_perl_eval] && *rs[Rs_perl_eval]))
495 {
496 rxvt_perl.init ();
497 HOOK_INVOKE ((this, HOOK_INIT, DT_END));
498 }
467#endif 499#endif
468 500
469 create_windows (argc, argv); 501 create_windows (argc, argv);
470 502
471 dDisp; 503 dDisp;
477#if 0 509#if 0
478 XSynchronize (disp, True); 510 XSynchronize (disp, True);
479#endif 511#endif
480 512
481#ifdef HAVE_SCROLLBARS 513#ifdef HAVE_SCROLLBARS
482 if (options & Opt_scrollBar) 514 if (OPTION (Opt_scrollBar))
483 resize_scrollbar (); /* create and map scrollbar */ 515 resize_scrollbar (); /* create and map scrollbar */
484#endif 516#endif
485#if (MENUBAR_MAX) 517#if (MENUBAR_MAX)
486 if (menubar_visible ()) 518 if (menubar_visible ())
487 XMapWindow (disp, menuBar.win); 519 XMapWindow (disp, menuBar.win);
488#endif 520#endif
489#ifdef TRANSPARENT 521#ifdef TRANSPARENT
490 if (options & Opt_transparent) 522 if (OPTION (Opt_transparent))
491 { 523 {
492 XSelectInput (disp, display->root, PropertyChangeMask); 524 XSelectInput (disp, display->root, PropertyChangeMask);
493 check_our_parents (); 525 check_our_parents ();
494 rootwin_ev.start (display, display->root); 526 rootwin_ev.start (display, display->root);
495 } 527 }
502 534
503 init_command (cmd_argv); 535 init_command (cmd_argv);
504 536
505 free (cmd_argv); 537 free (cmd_argv);
506 538
539 if (pty.pty >= 0)
507 pty_ev.start (pty.pty, EVENT_READ); 540 pty_ev.start (pty.pty, EVENT_READ);
508 541
509 check_ev.start (); 542 check_ev.start ();
543
544 HOOK_INVOKE ((this, HOOK_START, DT_END));
510 545
511 return true; 546 return true;
512} 547}
513 548
514static struct sig_handlers 549static struct sig_handlers
522 557
523 while ((pid = waitpid (-1, NULL, WNOHANG)) > 0) 558 while ((pid = waitpid (-1, NULL, WNOHANG)) > 0)
524 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) 559 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
525 if (pid == (*t)->cmd_pid) 560 if (pid == (*t)->cmd_pid)
526 { 561 {
527 (*t)->destroy (); 562 (*t)->child_exit ();
528 break; 563 break;
529 } 564 }
530 } 565 }
531 566
532 /* 567 /*
672 707
673#ifdef UTMP_SUPPORT 708#ifdef UTMP_SUPPORT
674void 709void
675rxvt_term::privileged_utmp (rxvt_privaction action) 710rxvt_term::privileged_utmp (rxvt_privaction action)
676{ 711{
677 if ((options & Opt_utmpInhibit) 712 if (OPTION (Opt_utmpInhibit)
678 || !pty.name || !*pty.name) 713 || !pty.name || !*pty.name)
679 return; 714 return;
680 715
681 rxvt_privileges (RESTORE); 716 rxvt_privileges (RESTORE);
682 717
774 809
775 if (scrollbar_visible ()) 810 if (scrollbar_visible ())
776 { 811 {
777 sb_w = scrollbar_TotalWidth (); 812 sb_w = scrollbar_TotalWidth ();
778 szHint.base_width += sb_w; 813 szHint.base_width += sb_w;
779 if (!(options & Opt_scrollBar_right)) 814 if (!OPTION (Opt_scrollBar_right))
780 window_vt_x += sb_w; 815 window_vt_x += sb_w;
781 } 816 }
782 817
783 if (menubar_visible ()) 818 if (menubar_visible ())
784 { 819 {
812 { 847 {
813 min_it (height, max_height); 848 min_it (height, max_height);
814 szHint.height = szHint.base_height + height; 849 szHint.height = szHint.base_height + height;
815 } 850 }
816 851
817 if (scrollbar_visible () && (options & Opt_scrollBar_right)) 852 if (scrollbar_visible () && OPTION (Opt_scrollBar_right))
818 window_sb_x = szHint.width - sb_w; 853 window_sb_x = szHint.width - sb_w;
819 854
820 if (recalc_x) 855 if (recalc_x)
821 szHint.x += DisplayWidth (disp, display->screen) - szHint.width - 2 * ext_bwidth; 856 szHint.x += DisplayWidth (disp, display->screen) - szHint.width - 2 * ext_bwidth;
822 if (recalc_y) 857 if (recalc_y)
891 prop.height += lineSpace; 926 prop.height += lineSpace;
892 fs->set_prop (prop); 927 fs->set_prop (prop);
893 928
894 fwidth = prop.width; 929 fwidth = prop.width;
895 fheight = prop.height; 930 fheight = prop.height;
896 fbase = (*fs)[1]->ascent; 931 fbase = prop.ascent;
897 932
898 for (int style = 1; style < 4; style++) 933 for (int style = 1; style < 4; style++)
899 { 934 {
900#if ENABLE_STYLES 935#if ENABLE_STYLES
901 const char *res = rs[Rs_font + style]; 936 const char *res = rs[Rs_font + style];
935 return true; 970 return true;
936} 971}
937 972
938void rxvt_term::set_string_property (Atom prop, const char *str, int len) 973void rxvt_term::set_string_property (Atom prop, const char *str, int len)
939{ 974{
940 // TODO: SMART_WINDOW_TITLE
941 XChangeProperty (display->display, parent[0], 975 XChangeProperty (display->display, parent[0],
942 prop, XA_STRING, 8, PropModeReplace, 976 prop, XA_STRING, 8, PropModeReplace,
943 (const unsigned char *)str, len >= 0 ? len : strlen (str)); 977 (const unsigned char *)str, len >= 0 ? len : strlen (str));
944} 978}
945 979
946void rxvt_term::set_utf8_property (Atom prop, const char *str, int len) 980void rxvt_term::set_utf8_property (Atom prop, const char *str, int len)
947{ 981{
948 // TODO: SMART_WINDOW_TITLE
949 wchar_t *ws = rxvt_mbstowcs (str, len); 982 wchar_t *ws = rxvt_mbstowcs (str, len);
950 char *s = rxvt_wcstoutf8 (ws); 983 char *s = rxvt_wcstoutf8 (ws);
951 984
952 XChangeProperty (display->display, parent[0], 985 XChangeProperty (display->display, parent[0],
953 prop, xa[XA_UTF8_STRING], 8, PropModeReplace, 986 prop, xa[XA_UTF8_STRING], 8, PropModeReplace,
994 i = atoi (color); 1027 i = atoi (color);
995 1028
996 if (i >= 8 && i <= 15) 1029 if (i >= 8 && i <= 15)
997 { /* bright colors */ 1030 { /* bright colors */
998 i -= 8; 1031 i -= 8;
999# ifndef NO_BRIGHTCOLOR
1000 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; 1032 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i];
1001 SET_PIXCOLOR (idx); 1033 SET_PIXCOLOR (idx);
1002 goto done; 1034 goto done;
1003# endif
1004 } 1035 }
1005 1036
1006 if (i >= 0 && i <= 7) 1037 if (i >= 0 && i <= 7)
1007 { /* normal colors */ 1038 { /* normal colors */
1008 pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; 1039 pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i];
1192 } 1223 }
1193 1224
1194 if (menubar_visible ()) 1225 if (menubar_visible ())
1195 XMoveResizeWindow (disp, menuBar.win, 1226 XMoveResizeWindow (disp, menuBar.win,
1196 window_vt_x, 0, 1227 window_vt_x, 0,
1197 TermWin_TotalWidth (), menuBar_TotalHeight ()); 1228 width, menuBar_TotalHeight ());
1198 1229
1199 XMoveResizeWindow (disp, vt, 1230 XMoveResizeWindow (disp, vt,
1200 window_vt_x, window_vt_y, 1231 window_vt_x, window_vt_y,
1201 TermWin_TotalWidth (), TermWin_TotalHeight ()); 1232 width, height);
1202 1233
1203 scr_clear (); 1234 scr_clear ();
1204#ifdef XPM_BACKGROUND 1235#ifdef XPM_BACKGROUND
1205 resize_pixmap (); 1236 resize_pixmap ();
1206#endif 1237#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines