1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*--------------------------------*-C-*---------------------------------* |
2 | * File: main.c |
2 | * File: main.c |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * $Id: main.C,v 1.14 2003/12/18 00:29:29 pcg Exp $ |
4 | * $Id: main.C,v 1.15 2003/12/18 05:45:11 pcg Exp $ |
5 | * |
5 | * |
6 | * All portions of code are copyright by their respective author/s. |
6 | * All portions of code are copyright by their respective author/s. |
7 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
7 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
8 | * - original version |
8 | * - original version |
9 | * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> |
9 | * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> |
… | |
… | |
42 | |
42 | |
43 | #ifdef HAVE_TERMIOS_H |
43 | #ifdef HAVE_TERMIOS_H |
44 | # include <termios.h> |
44 | # include <termios.h> |
45 | #endif |
45 | #endif |
46 | |
46 | |
|
|
47 | #include <cstring> |
|
|
48 | |
|
|
49 | static char curlocale[128]; |
|
|
50 | |
|
|
51 | void |
|
|
52 | rxvt_set_locale (const char *locale) |
|
|
53 | { |
|
|
54 | if (locale && strncmp (locale, curlocale, 128)) |
|
|
55 | { |
|
|
56 | strncpy (curlocale, locale, 128); |
|
|
57 | setlocale (LC_CTYPE, curlocale); |
|
|
58 | } |
|
|
59 | } |
|
|
60 | |
47 | void * |
61 | void * |
48 | rxvt_term::operator new (size_t s) |
62 | rxvt_term::operator new (size_t s) |
49 | { |
63 | { |
50 | void *p = malloc (s); |
64 | void *p = malloc (s); |
51 | |
65 | |
… | |
… | |
77 | |
91 | |
78 | rxvt_term::~rxvt_term () |
92 | rxvt_term::~rxvt_term () |
79 | { |
93 | { |
80 | scr_release (); |
94 | scr_release (); |
81 | |
95 | |
82 | #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) |
|
|
83 | free (locale); |
96 | free (locale); |
84 | #endif |
97 | free (codeset); |
|
|
98 | |
85 | #ifndef NO_SETOWNER_TTYDEV |
99 | #ifndef NO_SETOWNER_TTYDEV |
86 | rxvt_privileged_ttydev (this, RESTORE); |
100 | rxvt_privileged_ttydev (this, RESTORE); |
87 | #endif |
101 | #endif |
88 | #ifdef UTMP_SUPPORT |
102 | #ifdef UTMP_SUPPORT |
89 | rxvt_privileged_utmp (this, RESTORE); |
103 | rxvt_privileged_utmp (this, RESTORE); |
… | |
… | |
178 | } |
192 | } |
179 | |
193 | |
180 | bool |
194 | bool |
181 | rxvt_term::init (int argc, const char *const *argv) |
195 | rxvt_term::init (int argc, const char *const *argv) |
182 | { |
196 | { |
183 | dR;//TODO (scrollbar, setidle) |
|
|
184 | |
|
|
185 | /* |
197 | /* |
186 | * Save and then give up any super-user privileges |
198 | * Save and then give up any super-user privileges |
187 | * If we need privileges in any area then we must specifically request it. |
199 | * If we need privileges in any area then we must specifically request it. |
188 | * We should only need to be root in these cases: |
200 | * We should only need to be root in these cases: |
189 | * 1. write utmp entries on some systems |
201 | * 1. write utmp entries on some systems |
190 | * 2. chown tty on some systems |
202 | * 2. chown tty on some systems |
191 | */ |
203 | */ |
192 | rxvt_privileges (this, SAVE); |
204 | rxvt_privileges (this, SAVE); |
193 | rxvt_privileges (this, IGNORE); |
205 | rxvt_privileges (this, IGNORE); |
194 | |
206 | |
|
|
207 | #if HAVE_XSETLOCALE || HAVE_SETLOCALE |
|
|
208 | locale = strdup (setlocale (LC_CTYPE, "")); |
|
|
209 | #endif |
|
|
210 | #if HAVE_NL_LANGINFO |
|
|
211 | codeset = strdup (nl_langinfo (CODESET)); |
|
|
212 | #endif |
|
|
213 | |
195 | rxvt_init_secondary (this); |
214 | init_secondary (); |
196 | |
215 | |
197 | const char **cmd_argv = rxvt_init_resources (this, argc, argv); |
216 | const char **cmd_argv = init_resources (argc, argv); |
198 | |
217 | |
199 | #if (MENUBAR_MAX) |
218 | #if (MENUBAR_MAX) |
200 | rxvt_menubar_read (this, rs[Rs_menu]); |
219 | rxvt_menubar_read (this, rs[Rs_menu]); |
201 | #endif |
220 | #endif |
202 | #ifdef HAVE_SCROLLBARS |
221 | #ifdef HAVE_SCROLLBARS |
203 | if (Options & Opt_scrollBar) |
222 | if (Options & Opt_scrollBar) |
204 | scrollbar_setIdle (); /* set existence for size calculations */ |
223 | scrollBar.setIdle (); /* set existence for size calculations */ |
205 | #endif |
224 | #endif |
206 | |
225 | |
207 | rxvt_Create_Windows (this, argc, argv); |
226 | rxvt_Create_Windows (this, argc, argv); |
208 | |
227 | |
209 | rxvt_init_xlocale (this); |
228 | init_xlocale (); |
210 | |
229 | |
211 | scr_reset (); /* initialize screen */ |
230 | scr_reset (); /* initialize screen */ |
212 | #ifdef RXVT_GRAPHICS |
231 | #ifdef RXVT_GRAPHICS |
213 | rxvt_Gr_reset (this); /* reset graphics */ |
232 | rxvt_Gr_reset (this); /* reset graphics */ |
214 | #endif |
233 | #endif |
… | |
… | |
235 | } |
254 | } |
236 | #endif |
255 | #endif |
237 | XMapWindow (Xdisplay, TermWin.vt); |
256 | XMapWindow (Xdisplay, TermWin.vt); |
238 | XMapWindow (Xdisplay, TermWin.parent[0]); |
257 | XMapWindow (Xdisplay, TermWin.parent[0]); |
239 | |
258 | |
240 | rxvt_init_env (this); |
259 | init_env (); |
241 | rxvt_init_command (this, cmd_argv); |
260 | init_command (cmd_argv); |
242 | |
261 | |
243 | x_ev.start (Xfd, EVENT_READ); |
262 | x_ev.start (Xfd, EVENT_READ); |
244 | pty_ev.start (cmd_fd, EVENT_READ); |
263 | pty_ev.start (cmd_fd, EVENT_READ); |
245 | |
264 | |
246 | check_ev.start (); |
265 | check_ev.start (); |
… | |
… | |
761 | XSetWindowBackground(R->Xdisplay, R->TermWin.vt, |
780 | XSetWindowBackground(R->Xdisplay, R->TermWin.vt, |
762 | R->PixColors[Color_bg]); |
781 | R->PixColors[Color_bg]); |
763 | |
782 | |
764 | /* handle Color_BD, scrollbar background, etc. */ |
783 | /* handle Color_BD, scrollbar background, etc. */ |
765 | |
784 | |
766 | rxvt_set_colorfgbg(aR); |
785 | rxvt_set_colorfgbg (aR); |
767 | rxvt_recolour_cursor(aR); |
786 | R->recolour_cursor (); |
768 | /* the only reasonable way to enforce a clean update */ |
787 | /* the only reasonable way to enforce a clean update */ |
769 | rxvt_scr_poweron(aR); |
788 | rxvt_scr_poweron (aR); |
770 | } |
789 | } |
771 | |
790 | |
772 | #else |
791 | #else |
773 | # define rxvt_set_window_color(aR_ idx,color) ((void)0) |
792 | # define rxvt_set_window_color(aR_ idx,color) ((void)0) |
774 | #endif /* XTERM_COLOR_CHANGE */ |
793 | #endif /* XTERM_COLOR_CHANGE */ |
775 | |
794 | |
776 | /* EXTPROTO */ |
|
|
777 | void |
795 | void |
778 | rxvt_recolour_cursor(pR) |
796 | rxvt_term::recolour_cursor () |
779 | { |
797 | { |
780 | rxvt_color xcol[2]; |
|
|
781 | |
|
|
782 | #if TODO |
798 | #if TODO |
|
|
799 | rxvt_color xcol[2]; |
|
|
800 | |
783 | xcol[0] = R->PixColors[Color_pointer]; |
801 | xcol[0] = PixColors[Color_pointer]; |
784 | xcol[1] = R->PixColors[Color_bg]; |
802 | xcol[1] = PixColors[Color_bg]; |
785 | XQueryColors(R->Xdisplay, XCMAP, xcol, 2); |
803 | XQueryColors (Xdisplay, XCMAP, xcol, 2); |
786 | XRecolorCursor(R->Xdisplay, R->TermWin_cursor, &(xcol[0]), &(xcol[1])); |
804 | XRecolorCursor (Xdisplay, TermWin_cursor, &(xcol[0]), &(xcol[1])); |
787 | #endif |
805 | #endif |
788 | } |
806 | } |
789 | |
807 | |
790 | /*----------------------------------------------------------------------*/ |
808 | /*----------------------------------------------------------------------*/ |
791 | /* |
809 | /* |