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.13 by pcg, Wed Dec 17 09:00:35 2003 UTC vs.
Revision 1.15 by pcg, Thu Dec 18 05:45:11 2003 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*--------------------------------*-C-*---------------------------------*
2 * File: main.c 2 * File: main.c
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * $Id: main.C,v 1.13 2003/12/17 09:00:35 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
49static char curlocale[128];
50
51void
52rxvt_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
47void * 61void *
48rxvt_term::operator new (size_t s) 62rxvt_term::operator new (size_t s)
49{ 63{
50 void *p = malloc (s); 64 void *p = malloc (s);
51 65
76} 90}
77 91
78rxvt_term::~rxvt_term () 92rxvt_term::~rxvt_term ()
79{ 93{
80 scr_release (); 94 scr_release ();
95
96 free (locale);
97 free (codeset);
81 98
82#ifndef NO_SETOWNER_TTYDEV 99#ifndef NO_SETOWNER_TTYDEV
83 rxvt_privileged_ttydev (this, RESTORE); 100 rxvt_privileged_ttydev (this, RESTORE);
84#endif 101#endif
85#ifdef UTMP_SUPPORT 102#ifdef UTMP_SUPPORT
175} 192}
176 193
177bool 194bool
178rxvt_term::init (int argc, const char *const *argv) 195rxvt_term::init (int argc, const char *const *argv)
179{ 196{
180 dR;//TODO (scrollbar, setidle)
181
182 /* 197 /*
183 * Save and then give up any super-user privileges 198 * Save and then give up any super-user privileges
184 * 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.
185 * We should only need to be root in these cases: 200 * We should only need to be root in these cases:
186 * 1. write utmp entries on some systems 201 * 1. write utmp entries on some systems
187 * 2. chown tty on some systems 202 * 2. chown tty on some systems
188 */ 203 */
189 rxvt_privileges (this, SAVE); 204 rxvt_privileges (this, SAVE);
190 rxvt_privileges (this, IGNORE); 205 rxvt_privileges (this, IGNORE);
191 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
192 rxvt_init_secondary (this); 214 init_secondary ();
193 215
194 const char **cmd_argv = rxvt_init_resources (this, argc, argv); 216 const char **cmd_argv = init_resources (argc, argv);
195 217
196#if (MENUBAR_MAX) 218#if (MENUBAR_MAX)
197 rxvt_menubar_read (this, rs[Rs_menu]); 219 rxvt_menubar_read (this, rs[Rs_menu]);
198#endif 220#endif
199#ifdef HAVE_SCROLLBARS 221#ifdef HAVE_SCROLLBARS
200 if (Options & Opt_scrollBar) 222 if (Options & Opt_scrollBar)
201 scrollbar_setIdle (); /* set existence for size calculations */ 223 scrollBar.setIdle (); /* set existence for size calculations */
202#endif 224#endif
203 225
204 rxvt_Create_Windows (this, argc, argv); 226 rxvt_Create_Windows (this, argc, argv);
205 227
206 rxvt_init_xlocale (this); 228 init_xlocale ();
207 229
208 scr_reset (); /* initialize screen */ 230 scr_reset (); /* initialize screen */
209#ifdef RXVT_GRAPHICS 231#ifdef RXVT_GRAPHICS
210 rxvt_Gr_reset (this); /* reset graphics */ 232 rxvt_Gr_reset (this); /* reset graphics */
211#endif 233#endif
232 } 254 }
233#endif 255#endif
234 XMapWindow (Xdisplay, TermWin.vt); 256 XMapWindow (Xdisplay, TermWin.vt);
235 XMapWindow (Xdisplay, TermWin.parent[0]); 257 XMapWindow (Xdisplay, TermWin.parent[0]);
236 258
237 rxvt_init_env (this); 259 init_env ();
238 rxvt_init_command (this, cmd_argv); 260 init_command (cmd_argv);
239 261
240 x_ev.start (Xfd, EVENT_READ); 262 x_ev.start (Xfd, EVENT_READ);
241 pty_ev.start (cmd_fd, EVENT_READ); 263 pty_ev.start (cmd_fd, EVENT_READ);
242 264
243 check_ev.start (); 265 check_ev.start ();
758 XSetWindowBackground(R->Xdisplay, R->TermWin.vt, 780 XSetWindowBackground(R->Xdisplay, R->TermWin.vt,
759 R->PixColors[Color_bg]); 781 R->PixColors[Color_bg]);
760 782
761/* handle Color_BD, scrollbar background, etc. */ 783/* handle Color_BD, scrollbar background, etc. */
762 784
763 rxvt_set_colorfgbg(aR); 785 rxvt_set_colorfgbg (aR);
764 rxvt_recolour_cursor(aR); 786 R->recolour_cursor ();
765/* the only reasonable way to enforce a clean update */ 787/* the only reasonable way to enforce a clean update */
766 rxvt_scr_poweron(aR); 788 rxvt_scr_poweron (aR);
767} 789}
768 790
769#else 791#else
770# define rxvt_set_window_color(aR_ idx,color) ((void)0) 792# define rxvt_set_window_color(aR_ idx,color) ((void)0)
771#endif /* XTERM_COLOR_CHANGE */ 793#endif /* XTERM_COLOR_CHANGE */
772 794
773/* EXTPROTO */
774void 795void
775rxvt_recolour_cursor(pR) 796rxvt_term::recolour_cursor ()
776{ 797{
777 rxvt_color xcol[2];
778
779#if TODO 798#if TODO
799 rxvt_color xcol[2];
800
780 xcol[0] = R->PixColors[Color_pointer]; 801 xcol[0] = PixColors[Color_pointer];
781 xcol[1] = R->PixColors[Color_bg]; 802 xcol[1] = PixColors[Color_bg];
782 XQueryColors(R->Xdisplay, XCMAP, xcol, 2); 803 XQueryColors (Xdisplay, XCMAP, xcol, 2);
783 XRecolorCursor(R->Xdisplay, R->TermWin_cursor, &(xcol[0]), &(xcol[1])); 804 XRecolorCursor (Xdisplay, TermWin_cursor, &(xcol[0]), &(xcol[1]));
784#endif 805#endif
785} 806}
786 807
787/*----------------------------------------------------------------------*/ 808/*----------------------------------------------------------------------*/
788/* 809/*
1131 1152
1132 D_MAIN((stderr, "rxvt_IMInstantiateCallback()")); 1153 D_MAIN((stderr, "rxvt_IMInstantiateCallback()"));
1133 if (R->Input_Context) 1154 if (R->Input_Context)
1134 return; 1155 return;
1135 1156
1157#if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
1158 if (R->rs[Rs_imLocale])
1159 setlocale (LC_CTYPE, R->rs[Rs_imLocale]);
1160#endif
1161
1136 p = R->rs[Rs_inputMethod]; 1162 p = R->rs[Rs_inputMethod];
1137 if (p && *p) 1163 if (p && *p)
1138 { 1164 {
1139 bool found = false; 1165 bool found = false;
1140 1166
1156 for (i = 0; s[i]; i++) 1182 for (i = 0; s[i]; i++)
1157 free(s[i]); 1183 free(s[i]);
1158 free(s); 1184 free(s);
1159 1185
1160 if (found) 1186 if (found)
1161 return; 1187 goto done;
1162 } 1188 }
1163 1189
1164/* try with XMODIFIERS env. var. */ 1190/* try with XMODIFIERS env. var. */
1165 if ((p = XSetLocaleModifiers ("")) && *p 1191 if ((p = XSetLocaleModifiers ("")) && *p
1166 && rxvt_IM_get_IC (aR)) 1192 && rxvt_IM_get_IC (aR))
1167 return; 1193 goto done;
1168 1194
1169/* try with no modifiers base IF the user didn't specify an IM */ 1195/* try with no modifiers base IF the user didn't specify an IM */
1170 if ((p = XSetLocaleModifiers ("@im=none")) && *p 1196 if ((p = XSetLocaleModifiers ("@im=none")) && *p
1171 && rxvt_IM_get_IC (aR) == True) 1197 && rxvt_IM_get_IC (aR) == True)
1172 return; 1198 goto done;
1199
1200done:
1201#if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
1202 if (R->rs[Rs_imLocale])
1203 setlocale (LC_CTYPE, R->locale);
1204#endif
1173} 1205}
1174 1206
1175/* 1207/*
1176 * Try to open a XIM with the current modifiers, then see if we can 1208 * Try to open a XIM with the current modifiers, then see if we can
1177 * open a suitable preedit type 1209 * open a suitable preedit type

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines