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.152 by root, Thu Dec 22 16:44:10 2005 UTC vs.
Revision 1.158 by root, Tue Jan 3 23:40:58 2006 UTC

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 PERL_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
293void 306void
294rxvt_term::child_exit () 307rxvt_term::child_exit ()
295{ 308{
296 cmd_pid = 0; 309 cmd_pid = 0;
297 310
298 if (!(options & Opt_hold)) 311 if (!OPTION (Opt_hold))
299 destroy (); 312 destroy ();
300} 313}
301 314
302void 315void
303rxvt_term::destroy () 316rxvt_term::destroy ()
469 482
470#if MENUBAR_MAX 483#if MENUBAR_MAX
471 menubar_read (rs[Rs_menu]); 484 menubar_read (rs[Rs_menu]);
472#endif 485#endif
473#ifdef HAVE_SCROLLBARS 486#ifdef HAVE_SCROLLBARS
474 if (options & Opt_scrollBar) 487 if (OPTION (Opt_scrollBar))
475 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] && *rs[Rs_perl_ext])
493 {
494 rxvt_perl.init ();
495 PERL_INVOKE ((this, HOOK_INIT, DT_END));
496 }
476#endif 497#endif
477 498
478 create_windows (argc, argv); 499 create_windows (argc, argv);
479 500
480 dDisp; 501 dDisp;
486#if 0 507#if 0
487 XSynchronize (disp, True); 508 XSynchronize (disp, True);
488#endif 509#endif
489 510
490#ifdef HAVE_SCROLLBARS 511#ifdef HAVE_SCROLLBARS
491 if (options & Opt_scrollBar) 512 if (OPTION (Opt_scrollBar))
492 resize_scrollbar (); /* create and map scrollbar */ 513 resize_scrollbar (); /* create and map scrollbar */
493#endif 514#endif
494#if (MENUBAR_MAX) 515#if (MENUBAR_MAX)
495 if (menubar_visible ()) 516 if (menubar_visible ())
496 XMapWindow (disp, menuBar.win); 517 XMapWindow (disp, menuBar.win);
497#endif 518#endif
498#ifdef TRANSPARENT 519#ifdef TRANSPARENT
499 if (options & Opt_transparent) 520 if (OPTION (Opt_transparent))
500 { 521 {
501 XSelectInput (disp, display->root, PropertyChangeMask); 522 XSelectInput (disp, display->root, PropertyChangeMask);
502 check_our_parents (); 523 check_our_parents ();
503 rootwin_ev.start (display, display->root); 524 rootwin_ev.start (display, display->root);
504 } 525 }
514 free (cmd_argv); 535 free (cmd_argv);
515 536
516 pty_ev.start (pty.pty, EVENT_READ); 537 pty_ev.start (pty.pty, EVENT_READ);
517 538
518 check_ev.start (); 539 check_ev.start ();
540
541 PERL_INVOKE ((this, HOOK_START, DT_END));
519 542
520 return true; 543 return true;
521} 544}
522 545
523static struct sig_handlers 546static struct sig_handlers
681 704
682#ifdef UTMP_SUPPORT 705#ifdef UTMP_SUPPORT
683void 706void
684rxvt_term::privileged_utmp (rxvt_privaction action) 707rxvt_term::privileged_utmp (rxvt_privaction action)
685{ 708{
686 if ((options & Opt_utmpInhibit) 709 if (OPTION (Opt_utmpInhibit)
687 || !pty.name || !*pty.name) 710 || !pty.name || !*pty.name)
688 return; 711 return;
689 712
690 rxvt_privileges (RESTORE); 713 rxvt_privileges (RESTORE);
691 714
783 806
784 if (scrollbar_visible ()) 807 if (scrollbar_visible ())
785 { 808 {
786 sb_w = scrollbar_TotalWidth (); 809 sb_w = scrollbar_TotalWidth ();
787 szHint.base_width += sb_w; 810 szHint.base_width += sb_w;
788 if (!(options & Opt_scrollBar_right)) 811 if (!OPTION (Opt_scrollBar_right))
789 window_vt_x += sb_w; 812 window_vt_x += sb_w;
790 } 813 }
791 814
792 if (menubar_visible ()) 815 if (menubar_visible ())
793 { 816 {
821 { 844 {
822 min_it (height, max_height); 845 min_it (height, max_height);
823 szHint.height = szHint.base_height + height; 846 szHint.height = szHint.base_height + height;
824 } 847 }
825 848
826 if (scrollbar_visible () && (options & Opt_scrollBar_right)) 849 if (scrollbar_visible () && OPTION (Opt_scrollBar_right))
827 window_sb_x = szHint.width - sb_w; 850 window_sb_x = szHint.width - sb_w;
828 851
829 if (recalc_x) 852 if (recalc_x)
830 szHint.x += DisplayWidth (disp, display->screen) - szHint.width - 2 * ext_bwidth; 853 szHint.x += DisplayWidth (disp, display->screen) - szHint.width - 2 * ext_bwidth;
831 if (recalc_y) 854 if (recalc_y)
900 prop.height += lineSpace; 923 prop.height += lineSpace;
901 fs->set_prop (prop); 924 fs->set_prop (prop);
902 925
903 fwidth = prop.width; 926 fwidth = prop.width;
904 fheight = prop.height; 927 fheight = prop.height;
905 fbase = (*fs)[1]->ascent; 928 fbase = prop.ascent;
906 929
907 for (int style = 1; style < 4; style++) 930 for (int style = 1; style < 4; style++)
908 { 931 {
909#if ENABLE_STYLES 932#if ENABLE_STYLES
910 const char *res = rs[Rs_font + style]; 933 const char *res = rs[Rs_font + style];
944 return true; 967 return true;
945} 968}
946 969
947void rxvt_term::set_string_property (Atom prop, const char *str, int len) 970void rxvt_term::set_string_property (Atom prop, const char *str, int len)
948{ 971{
949 // TODO: SMART_WINDOW_TITLE
950 XChangeProperty (display->display, parent[0], 972 XChangeProperty (display->display, parent[0],
951 prop, XA_STRING, 8, PropModeReplace, 973 prop, XA_STRING, 8, PropModeReplace,
952 (const unsigned char *)str, len >= 0 ? len : strlen (str)); 974 (const unsigned char *)str, len >= 0 ? len : strlen (str));
953} 975}
954 976
955void rxvt_term::set_utf8_property (Atom prop, const char *str, int len) 977void rxvt_term::set_utf8_property (Atom prop, const char *str, int len)
956{ 978{
957 // TODO: SMART_WINDOW_TITLE
958 wchar_t *ws = rxvt_mbstowcs (str, len); 979 wchar_t *ws = rxvt_mbstowcs (str, len);
959 char *s = rxvt_wcstoutf8 (ws); 980 char *s = rxvt_wcstoutf8 (ws);
960 981
961 XChangeProperty (display->display, parent[0], 982 XChangeProperty (display->display, parent[0],
962 prop, xa[XA_UTF8_STRING], 8, PropModeReplace, 983 prop, xa[XA_UTF8_STRING], 8, PropModeReplace,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines