annotate src/input-method-xfs.c @ 428:3ecd8885ac67 r21-2-22

Import from CVS: tag r21-2-22
author cvs
date Mon, 13 Aug 2007 11:28:15 +0200
parents
children 8de8e3f6228a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* input-method-xfs.c provides just only locale initialize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 for non Motif people. (stoled from input-method-xlib.c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Why I made this code is to initialize X locale environment for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 the purpose of use XFontSet correctly in lwlib/xlwmenu.c.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 And this code donot provides input methods under Xlib while they
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 prefer to use Canna, Wnn, skk or something like that.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 This code has been tested on FreeBSD 2.2.1 and Solaris2.5.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 Copyright (C) 1997 Kazuyuki IENAGA.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 This file is a part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 #include <X11/Xlocale.h> /* More portable than <locale.h> ? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 #include "frame.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #include "device.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #include "window.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #include "buffer.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include "console-x.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include "EmacsFrame.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #include "events.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #ifdef USE_XFONTSET
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 Initialize_Locale (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 char *locale;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 /* dverna - Nov. 98: ### DON'T DO THIS !!! The default XtLanguageProc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 routine calls setlocale(LC_ALL, lang) which fucks up our lower-level
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 locale management, and especially the value of LC_NUMERIC. Anyway, since
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 at this point, we don't know yet whether we're gonna need an X11 frame,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 we should really do it manually and not use Xlib's dumb default routine */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 /*XtSetLanguageProc (NULL, (XtLanguageProc) NULL, NULL);*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 if ((locale = setlocale (LC_ALL, "")) == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 stderr_out ("Can't set locale.\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 stderr_out ("Using C locale instead.\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 putenv ("LANG=C");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 putenv ("LC_ALL=C");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 if ((locale = setlocale (LC_ALL, "C")) == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 stderr_out ("Can't even set locale to `C'!\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 if (!XSupportsLocale ())
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 stderr_out ("X Windows does not support locale `%s'\n", locale);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 stderr_out ("Using C Locale instead\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 putenv ("LANG=C");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 putenv ("LC_ALL=C");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 if ((locale = setlocale (LC_ALL, "C")) == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 stderr_out ("Can't even set locale to `C'!\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 if (!XSupportsLocale ())
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 stderr_out ("X Windows does not even support locale `C'!\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 setlocale(LC_NUMERIC, "C");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 setlocale(LC_CTYPE, ""); /* take back CTYPE to previous state */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 if (XSetLocaleModifiers ("") == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 stderr_out ("XSetLocaleModifiers(\"\") failed\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 stderr_out ("Check the value of the XMODIFIERS environment variable.\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 #endif /* USE_XFONTSET */