Mercurial > emacs
comparison src/w32reg.c @ 88155:d7ddb3e565de
sync with trunk
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Mon, 16 Jan 2006 00:03:54 +0000 |
parents | 23a1cea22d13 |
children |
comparison
equal
deleted
inserted
replaced
88154:8ce476d3ba36 | 88155:d7ddb3e565de |
---|---|
1 /* Emulate the X Resource Manager through the registry. | 1 /* Emulate the X Resource Manager through the registry. |
2 Copyright (C) 1990, 1993, 1994 Free Software Foundation. | 2 Copyright (C) 1990, 1993, 1994, 2002, 2003, 2004, |
3 2005 Free Software Foundation, Inc. | |
3 | 4 |
4 This file is part of GNU Emacs. | 5 This file is part of GNU Emacs. |
5 | 6 |
6 GNU Emacs is free software; you can redistribute it and/or modify | 7 GNU Emacs is free software; you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 GNU General Public License for more details. | 15 GNU General Public License for more details. |
15 | 16 |
16 You should have received a copy of the GNU General Public License | 17 You should have received a copy of the GNU General Public License |
17 along with GNU Emacs; see the file COPYING. If not, write to | 18 along with GNU Emacs; see the file COPYING. If not, write to |
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 Boston, MA 02111-1307, USA. */ | 20 Boston, MA 02110-1301, USA. */ |
20 | 21 |
21 /* Written by Kevin Gallo */ | 22 /* Written by Kevin Gallo */ |
22 | 23 |
23 #include <config.h> | 24 #include <config.h> |
24 #include "lisp.h" | 25 #include "lisp.h" |
27 | 28 |
28 #include <stdio.h> | 29 #include <stdio.h> |
29 #include <string.h> | 30 #include <string.h> |
30 | 31 |
31 #define REG_ROOT "SOFTWARE\\GNU\\Emacs" | 32 #define REG_ROOT "SOFTWARE\\GNU\\Emacs" |
33 | |
34 /* Default system colors from the Display Control Panel settings. */ | |
35 #define SYSTEM_DEFAULT_RESOURCES \ | |
36 "emacs.foreground:SystemWindowText\0" \ | |
37 "emacs.background:SystemWindow\0" \ | |
38 "emacs.tooltip.attributeForeground:SystemInfoText\0" \ | |
39 "emacs.tooltip.attributeBackground:SystemInfoWindow\0" \ | |
40 "emacs.tool-bar.attributeForeground:SystemButtonText\0" \ | |
41 "emacs.tool-bar.attributeBackground:SystemButtonFace\0" \ | |
42 "emacs.menu.attributeForeground:SystemMenuText\0" \ | |
43 "emacs.menu.attributeBackground:SystemMenu\0" \ | |
44 "emacs.scroll-bar.attributeForeground:SystemScrollbar" | |
45 | |
46 /* Other possibilities for default faces: | |
47 | |
48 region: Could use SystemHilight, but interferes with our ability to | |
49 see most syntax highlighting through the region face. | |
50 | |
51 modeline: Could use System(In)ActiveTitle, gradient versions (not | |
52 supported on 95 and NT), but modeline is more like a status bar | |
53 really (which don't appear to be configurable in Windows). | |
54 | |
55 highlight: Could use SystemHotTrackingColor, but it is not supported | |
56 on Windows 95 or NT, and other apps only seem to use it for menus | |
57 anyway. | |
58 | |
59 */ | |
60 | |
61 static char * | |
62 w32_get_rdb_resource (rdb, resource) | |
63 char *rdb; | |
64 char *resource; | |
65 { | |
66 char *value = rdb; | |
67 int len = strlen (resource); | |
68 | |
69 while (*value) | |
70 { | |
71 /* Comparison is case-insensitive because registry searches are too. */ | |
72 if ((strnicmp (value, resource, len) == 0) && (value[len] == ':')) | |
73 return xstrdup (&value[len + 1]); | |
74 | |
75 value = strchr (value, '\0') + 1; | |
76 } | |
77 | |
78 return NULL; | |
79 } | |
32 | 80 |
33 LPBYTE | 81 LPBYTE |
34 w32_get_string_resource (name, class, dwexptype) | 82 w32_get_string_resource (name, class, dwexptype) |
35 char *name, *class; | 83 char *name, *class; |
36 DWORD dwexptype; | 84 DWORD dwexptype; |
87 if (hive == HKEY_CURRENT_USER) | 135 if (hive == HKEY_CURRENT_USER) |
88 { | 136 { |
89 hive = HKEY_LOCAL_MACHINE; | 137 hive = HKEY_LOCAL_MACHINE; |
90 goto trykey; | 138 goto trykey; |
91 } | 139 } |
92 return (NULL); | 140 |
141 /* Check if there are Windows specific defaults defined. */ | |
142 return w32_get_rdb_resource (SYSTEM_DEFAULT_RESOURCES, name); | |
93 } | 143 } |
94 return (lpvalue); | 144 return (lpvalue); |
95 } | 145 } |
96 | 146 |
97 /* Retrieve the string resource specified by NAME with CLASS from | 147 /* Retrieve the string resource specified by NAME with CLASS from |
98 database RDB. */ | 148 database RDB. */ |
99 | 149 |
100 char * | 150 char * |
101 x_get_string_resource (rdb, name, class) | 151 x_get_string_resource (rdb, name, class) |
102 int rdb; | 152 XrmDatabase rdb; |
103 char *name, *class; | 153 char *name, *class; |
104 { | 154 { |
155 if (rdb) | |
156 { | |
157 char *resource; | |
158 | |
159 if (resource = w32_get_rdb_resource (rdb, name)) | |
160 return resource; | |
161 if (resource = w32_get_rdb_resource (rdb, class)) | |
162 return resource; | |
163 } | |
164 | |
105 return (w32_get_string_resource (name, class, REG_SZ)); | 165 return (w32_get_string_resource (name, class, REG_SZ)); |
106 } | 166 } |
167 | |
168 /* arch-tag: 755fce25-42d7-4acb-874f-2fb42336823d | |
169 (do not change this comment) */ |