Mercurial > emacs
annotate src/w32reg.c @ 105076:8a45209e673f
(js-end-of-defun): Remove malformed and unneeded let.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Fri, 18 Sep 2009 07:16:49 +0000 |
parents | 4cbb223d0b1c |
children | 68dd71358159 |
rev | line source |
---|---|
13434 | 1 /* Emulate the X Resource Manager through the registry. |
75227
e90d04cd455a
Update copyright for years from Emacs 21 to present (mainly adding
Glenn Morris <rgm@gnu.org>
parents:
68651
diff
changeset
|
2 Copyright (C) 1990, 1993, 1994, 2001, 2002, 2003, 2004, |
100951 | 3 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
13434 | 4 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
5 This file is part of GNU Emacs. |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
6 |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
79759
diff
changeset
|
7 GNU Emacs is free software: you can redistribute it and/or modify |
13434 | 8 it under the terms of the GNU General Public License as published by |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
79759
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
79759
diff
changeset
|
10 (at your option) any later version. |
13434 | 11 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
12 GNU Emacs is distributed in the hope that it will be useful, |
13434 | 13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
79759
diff
changeset
|
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
13434 | 19 |
20 /* Written by Kevin Gallo */ | |
21 | |
22 #include <config.h> | |
23 #include "lisp.h" | |
24 #include "w32term.h" | |
25 #include "blockinput.h" | |
26 | |
27 #include <stdio.h> | |
28 #include <string.h> | |
29 | |
15149
685510b93c83
(REG_ROOT): Remove trailing backslash.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14353
diff
changeset
|
30 #define REG_ROOT "SOFTWARE\\GNU\\Emacs" |
13434 | 31 |
51501
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
32 /* Default system colors from the Display Control Panel settings. */ |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
33 #define SYSTEM_DEFAULT_RESOURCES \ |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
34 "emacs.foreground:SystemWindowText\0" \ |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
35 "emacs.background:SystemWindow\0" \ |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
36 "emacs.tooltip.attributeForeground:SystemInfoText\0" \ |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
37 "emacs.tooltip.attributeBackground:SystemInfoWindow\0" \ |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
38 "emacs.tool-bar.attributeForeground:SystemButtonText\0" \ |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
39 "emacs.tool-bar.attributeBackground:SystemButtonFace\0" \ |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
40 "emacs.menu.attributeForeground:SystemMenuText\0" \ |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
41 "emacs.menu.attributeBackground:SystemMenu\0" \ |
78609
7cabb4564b1b
(SYSTEM_DEFAULT_RESOURCES): Add missing NULL terminator.
Jason Rumney <jasonr@gnu.org>
parents:
78260
diff
changeset
|
42 "emacs.scroll-bar.attributeForeground:SystemScrollbar\0" |
51501
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
43 |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
44 /* Other possibilities for default faces: |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
45 |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
46 region: Could use SystemHilight, but interferes with our ability to |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
47 see most syntax highlighting through the region face. |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
48 |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
49 modeline: Could use System(In)ActiveTitle, gradient versions (not |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
50 supported on 95 and NT), but modeline is more like a status bar |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
51 really (which don't appear to be configurable in Windows). |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
52 |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
53 highlight: Could use SystemHotTrackingColor, but it is not supported |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
54 on Windows 95 or NT, and other apps only seem to use it for menus |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
55 anyway. |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
56 |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
57 */ |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
58 |
50040
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
59 static char * |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
60 w32_get_rdb_resource (rdb, resource) |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
61 char *rdb; |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
62 char *resource; |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
63 { |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
64 char *value = rdb; |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
65 int len = strlen (resource); |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
66 |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
67 while (*value) |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
68 { |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
69 /* Comparison is case-insensitive because registry searches are too. */ |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
70 if ((strnicmp (value, resource, len) == 0) && (value[len] == ':')) |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
71 return xstrdup (&value[len + 1]); |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
72 |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
73 value = strchr (value, '\0') + 1; |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
74 } |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
75 |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
76 return NULL; |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
77 } |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
78 |
105069
4cbb223d0b1c
The --quick command line option now ignores X resources and Registry settings.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
79 static LPBYTE |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15149
diff
changeset
|
80 w32_get_string_resource (name, class, dwexptype) |
13434 | 81 char *name, *class; |
82 DWORD dwexptype; | |
83 { | |
84 LPBYTE lpvalue = NULL; | |
85 HKEY hrootkey = NULL; | |
86 DWORD dwType; | |
87 DWORD cbData; | |
88 BOOL ok = FALSE; | |
24672
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
89 HKEY hive = HKEY_CURRENT_USER; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
90 |
24672
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
91 trykey: |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
92 |
13434 | 93 BLOCK_INPUT; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
94 |
24672
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
95 /* Check both the current user and the local machine to see if we have |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
96 any resources */ |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
97 |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
98 if (RegOpenKeyEx (hive, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS) |
13434 | 99 { |
100 char *keyname; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
101 |
13434 | 102 if (RegQueryValueEx (hrootkey, name, NULL, &dwType, NULL, &cbData) == ERROR_SUCCESS |
103 && dwType == dwexptype) | |
104 { | |
105 keyname = name; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
106 } |
13434 | 107 else if (RegQueryValueEx (hrootkey, class, NULL, &dwType, NULL, &cbData) == ERROR_SUCCESS |
108 && dwType == dwexptype) | |
109 { | |
110 keyname = class; | |
111 } | |
112 else | |
113 { | |
114 keyname = NULL; | |
115 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
116 |
13434 | 117 ok = (keyname |
118 && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL | |
119 && RegQueryValueEx (hrootkey, keyname, NULL, NULL, lpvalue, &cbData) == ERROR_SUCCESS); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
120 |
13434 | 121 RegCloseKey (hrootkey); |
122 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
123 |
13434 | 124 UNBLOCK_INPUT; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
125 |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
126 if (!ok) |
13434 | 127 { |
24672
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
128 if (lpvalue) |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
129 { |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
130 xfree (lpvalue); |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
131 lpvalue = NULL; |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
132 } |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
133 if (hive == HKEY_CURRENT_USER) |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
134 { |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
135 hive = HKEY_LOCAL_MACHINE; |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
136 goto trykey; |
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
137 } |
51501
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
138 |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
139 /* Check if there are Windows specific defaults defined. */ |
b79b842995c2
(SYSTEM_DEFAULT_RESOURCES): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
50364
diff
changeset
|
140 return w32_get_rdb_resource (SYSTEM_DEFAULT_RESOURCES, name); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
24672
diff
changeset
|
141 } |
24672
8387918b52c6
(w32_get_string_resource): Check for name in current
Andrew Innes <andrewi@gnu.org>
parents:
16588
diff
changeset
|
142 return (lpvalue); |
13434 | 143 } |
144 | |
145 /* Retrieve the string resource specified by NAME with CLASS from | |
146 database RDB. */ | |
147 | |
148 char * | |
149 x_get_string_resource (rdb, name, class) | |
50364
fcf617f53ab1
(x_get_string_resource): Use XrmDatabase.
Kim F. Storm <storm@cua.dk>
parents:
50040
diff
changeset
|
150 XrmDatabase rdb; |
13434 | 151 char *name, *class; |
152 { | |
50040
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
153 if (rdb) |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
154 { |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
155 char *resource; |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
156 |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
157 if (resource = w32_get_rdb_resource (rdb, name)) |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
158 return resource; |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
159 if (resource = w32_get_rdb_resource (rdb, class)) |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
160 return resource; |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
161 } |
57e262ca5d0d
(w32_get_rdb_resource): New function.
Juanma Barranquero <lekktu@gmail.com>
parents:
49600
diff
changeset
|
162 |
105069
4cbb223d0b1c
The --quick command line option now ignores X resources and Registry settings.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
163 if (inhibit_x_resources) |
4cbb223d0b1c
The --quick command line option now ignores X resources and Registry settings.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
164 /* --quick was passed, so this is a no-op. */ |
4cbb223d0b1c
The --quick command line option now ignores X resources and Registry settings.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
165 return NULL; |
4cbb223d0b1c
The --quick command line option now ignores X resources and Registry settings.
Juanma Barranquero <lekktu@gmail.com>
parents:
100951
diff
changeset
|
166 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15149
diff
changeset
|
167 return (w32_get_string_resource (name, class, REG_SZ)); |
13434 | 168 } |
52401 | 169 |
170 /* arch-tag: 755fce25-42d7-4acb-874f-2fb42336823d | |
171 (do not change this comment) */ |