… | |
… | |
48 | # include <termios.h> |
48 | # include <termios.h> |
49 | #endif |
49 | #endif |
50 | |
50 | |
51 | vector<rxvt_term *> rxvt_term::termlist; |
51 | vector<rxvt_term *> rxvt_term::termlist; |
52 | |
52 | |
|
|
53 | // used to tell global functions which terminal instance is "active" |
|
|
54 | rxvt_t rxvt_current_term; |
|
|
55 | |
53 | static char curlocale[128], savelocale[128]; |
56 | static char curlocale[128], savelocale[128]; |
54 | |
57 | |
55 | bool |
58 | bool |
56 | rxvt_set_locale (const char *locale) |
59 | rxvt_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 | |
66 | void |
69 | void |
67 | rxvt_push_locale (const char *locale) |
70 | rxvt_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 | |
73 | void |
76 | void |
74 | rxvt_pop_locale () |
77 | rxvt_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 | |
203 | rxvt_term::~rxvt_term () |
206 | rxvt_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 | |
303 | void |
304 | void |
304 | rxvt_term::destroy () |
305 | rxvt_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 | /*----------------------------------------------------------------------*/ |
450 | bool |
454 | bool |
451 | rxvt_term::init (int argc, const char *const *argv) |
455 | rxvt_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 ()) |
… | |
… | |
463 | |
469 | |
464 | #ifdef KEYSYM_RESOURCE |
470 | #ifdef KEYSYM_RESOURCE |
465 | keyboard->register_done (); |
471 | keyboard->register_done (); |
466 | #endif |
472 | #endif |
467 | |
473 | |
468 | #if ENABLE_PERL |
|
|
469 | if (!rs[Rs_perl_ext_1]) |
|
|
470 | rs[Rs_perl_ext_1] = "default"; |
|
|
471 | |
|
|
472 | if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) |
|
|
473 | || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2]) |
|
|
474 | || (rs[Rs_perl_eval] && *rs[Rs_perl_eval])) |
|
|
475 | { |
|
|
476 | rxvt_perl.init (this); |
|
|
477 | HOOK_INVOKE ((this, HOOK_INIT, DT_END)); |
|
|
478 | } |
|
|
479 | #endif |
|
|
480 | |
|
|
481 | #ifdef HAVE_SCROLLBARS |
474 | #ifdef HAVE_SCROLLBARS |
482 | if (OPTION (Opt_scrollBar)) |
475 | if (OPTION (Opt_scrollBar)) |
483 | scrollBar.setIdle (); /* set existence for size calculations */ |
476 | scrollBar.setIdle (); /* set existence for size calculations */ |
484 | #endif |
477 | #endif |
485 | |
478 | |
… | |
… | |
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 | |
532 | static struct sig_handlers |
525 | static 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 | |
636 | void * |
629 | void * |
637 | rxvt_realloc (void *ptr, size_t size) |
630 | rxvt_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 | /*----------------------------------------------------------------------*/ |
|
|
1595 | rxvt_t rxvt_current_term; |
|
|
1596 | |
|
|
1597 | /*----------------------- end-of-file (C source) -----------------------*/ |
1587 | /*----------------------- end-of-file (C source) -----------------------*/ |