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.189 by root, Thu Jan 19 09:47:15 2006 UTC vs.
Revision 1.194 by root, Sun Jan 22 00:36:59 2006 UTC

48# include <termios.h> 48# include <termios.h>
49#endif 49#endif
50 50
51vector<rxvt_term *> rxvt_term::termlist; 51vector<rxvt_term *> rxvt_term::termlist;
52 52
53// used to tell global functions which terminal instance is "active"
54rxvt_t rxvt_current_term;
55
53static char curlocale[128], savelocale[128]; 56static char curlocale[128], savelocale[128];
54 57
55bool 58bool
56rxvt_set_locale (const char *locale) 59rxvt_set_locale (const char *locale) NOTHROW
57{ 60{
58 if (!locale || !strncmp (locale, curlocale, 128)) 61 if (!locale || !strncmp (locale, curlocale, 128))
59 return false; 62 return false;
60 63
61 strncpy (curlocale, locale, 128); 64 strncpy (curlocale, locale, 128);
62 setlocale (LC_CTYPE, curlocale); 65 setlocale (LC_CTYPE, curlocale);
63 return true; 66 return true;
64} 67}
65 68
66void 69void
67rxvt_push_locale (const char *locale) 70rxvt_push_locale (const char *locale) NOTHROW
68{ 71{
69 strcpy (savelocale, curlocale); 72 strcpy (savelocale, curlocale);
70 rxvt_set_locale (locale); 73 rxvt_set_locale (locale);
71} 74}
72 75
73void 76void
74rxvt_pop_locale () 77rxvt_pop_locale () NOTHROW
75{ 78{
76 rxvt_set_locale (savelocale); 79 rxvt_set_locale (savelocale);
77} 80}
78 81
79#if ENABLE_COMBINING 82#if ENABLE_COMBINING
166#ifdef POINTER_BLANK 169#ifdef POINTER_BLANK
167 pointer_ev (this, &rxvt_term::pointer_cb), 170 pointer_ev (this, &rxvt_term::pointer_cb),
168#endif 171#endif
169#ifdef USE_XIM 172#ifdef USE_XIM
170 im_ev (this, &rxvt_term::im_cb), 173 im_ev (this, &rxvt_term::im_cb),
174#endif
175#ifndef NO_BELL
176 bell_ev (this, &rxvt_term::bell_cb),
171#endif 177#endif
172 termwin_ev (this, &rxvt_term::x_cb), 178 termwin_ev (this, &rxvt_term::x_cb),
173 vt_ev (this, &rxvt_term::x_cb), 179 vt_ev (this, &rxvt_term::x_cb),
174 child_ev (this, &rxvt_term::child_cb), 180 child_ev (this, &rxvt_term::child_cb),
175 check_ev (this, &rxvt_term::check_cb), 181 check_ev (this, &rxvt_term::check_cb),
182 188
183 termlist.push_back (this); 189 termlist.push_back (this);
184 190
185#ifdef KEYSYM_RESOURCE 191#ifdef KEYSYM_RESOURCE
186 keyboard = new keyboard_manager; 192 keyboard = new keyboard_manager;
187
188 if (!keyboard)
189 rxvt_fatal ("out of memory, aborting.\n");
190#endif 193#endif
191} 194}
192 195
193// clean up the most important stuff, do *not* call x or free mem etc. 196// clean up the most important stuff, do *not* call x or free mem etc.
194// for use before an emergency exit 197// for use before an emergency exit
200 delete pty; pty = 0; 203 delete pty; pty = 0;
201} 204}
202 205
203rxvt_term::~rxvt_term () 206rxvt_term::~rxvt_term ()
204{ 207{
205 HOOK_INVOKE ((this, HOOK_DESTROY, DT_END));
206
207 termlist.erase (find (termlist.begin (), termlist.end(), this)); 208 termlist.erase (find (termlist.begin (), termlist.end(), this));
208 209
209 emergency_cleanup (); 210 emergency_cleanup ();
210 211
211#if ENABLE_STYLES 212#if ENABLE_STYLES
302 303
303void 304void
304rxvt_term::destroy () 305rxvt_term::destroy ()
305{ 306{
306 if (destroy_ev.active) 307 if (destroy_ev.active)
308 return;
309
310 if (HOOK_INVOKE ((this, HOOK_DESTROY, DT_END)))
307 return; 311 return;
308 312
309#if ENABLE_OVERLAY 313#if ENABLE_OVERLAY
310 scr_overlay_off (); 314 scr_overlay_off ();
311#endif 315#endif
446 _exit (EXIT_FAILURE); 450 _exit (EXIT_FAILURE);
447} 451}
448 452
449/*----------------------------------------------------------------------*/ 453/*----------------------------------------------------------------------*/
450bool 454bool
451rxvt_term::init (int argc, const char *const *argv) 455rxvt_term::init (int argc, const char *const *argv, stringvec *envv)
452{ 456{
457 this->envv = envv;
458
453 SET_R (this); 459 SET_R (this);
454 set_locale (""); 460 set_locale ("");
455 set_environ (envv); // few things in X do not call setlocale :( 461 set_environ (envv); // few things in X do not call setlocale :(
456 462
457 if (!init_vars ()) 463 if (!init_vars ())
468#ifdef HAVE_SCROLLBARS 474#ifdef HAVE_SCROLLBARS
469 if (OPTION (Opt_scrollBar)) 475 if (OPTION (Opt_scrollBar))
470 scrollBar.setIdle (); /* set existence for size calculations */ 476 scrollBar.setIdle (); /* set existence for size calculations */
471#endif 477#endif
472 478
473#if ENABLE_PERL
474 if (!rs[Rs_perl_ext_1])
475 rs[Rs_perl_ext_1] = "default";
476
477 if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1])
478 || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2])
479 || (rs[Rs_perl_eval] && *rs[Rs_perl_eval]))
480 {
481 rxvt_perl.init (this);
482 HOOK_INVOKE ((this, HOOK_INIT, DT_END));
483 }
484#endif
485
486 pty = rxvt_new_ptytty (); 479 pty = rxvt_new_ptytty ();
487 480
488 create_windows (argc, argv); 481 create_windows (argc, argv);
489 482
490 dDisp; 483 dDisp;
508 check_our_parents (); 501 check_our_parents ();
509 rootwin_ev.start (display, display->root); 502 rootwin_ev.start (display, display->root);
510 } 503 }
511#endif 504#endif
512 505
506 set_colorfgbg ();
507
508 init_command (cmd_argv);
509
510 free (cmd_argv);
511
512 if (pty->pty >= 0)
513 pty_ev.start (pty->pty, EVENT_READ);
514
515 check_ev.start ();
516
517 HOOK_INVOKE ((this, HOOK_START, DT_END));
518
513 XMapWindow (disp, vt); 519 XMapWindow (disp, vt);
514 XMapWindow (disp, parent[0]); 520 XMapWindow (disp, parent[0]);
515
516 set_colorfgbg ();
517
518 init_command (cmd_argv);
519
520 free (cmd_argv);
521
522 if (pty->pty >= 0)
523 pty_ev.start (pty->pty, EVENT_READ);
524
525 check_ev.start ();
526
527 HOOK_INVOKE ((this, HOOK_START, DT_END));
528 521
529 return true; 522 return true;
530} 523}
531 524
532static struct sig_handlers 525static struct sig_handlers
631 rxvt_fatal ("memory allocation failure. aborting.\n"); 624 rxvt_fatal ("memory allocation failure. aborting.\n");
632 625
633 return p; 626 return p;
634} 627}
635 628
636void * 629void *
637rxvt_realloc (void *ptr, size_t size) 630rxvt_realloc (void *ptr, size_t size)
638{ 631{
639 void *p = realloc (ptr, size); 632 void *p = realloc (ptr, size);
640 633
641 if (!p) 634 if (!p)
1589 XFree (preedit_attr); 1582 XFree (preedit_attr);
1590 XFree (status_attr); 1583 XFree (status_attr);
1591} 1584}
1592#endif /* USE_XIM */ 1585#endif /* USE_XIM */
1593 1586
1594/*----------------------------------------------------------------------*/
1595rxvt_t rxvt_current_term;
1596
1597/*----------------------- end-of-file (C source) -----------------------*/ 1587/*----------------------- end-of-file (C source) -----------------------*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines