2 * an application for displaying Win32 console
3 * registry and init functions
5 * Copyright 2001 Eric Pouech
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "winecon_private.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(wineconsole);
30 static const WCHAR wszConsole[] = {'C','o','n','s','o','l','e',0};
31 static const WCHAR wszCursorSize[] = {'C','u','r','s','o','r','S','i','z','e',0};
32 static const WCHAR wszCursorVisible[] = {'C','u','r','s','o','r','V','i','s','i','b','l','e',0};
33 static const WCHAR wszExitOnDie[] = {'E','x','i','t','O','n','D','i','e',0};
34 static const WCHAR wszFaceName[] = {'F','a','c','e','N','a','m','e',0};
35 static const WCHAR wszFontSize[] = {'F','o','n','t','S','i','z','e',0};
36 static const WCHAR wszFontWeight[] = {'F','o','n','t','W','e','i','g','h','t',0};
37 static const WCHAR wszHistoryBufferSize[] = {'H','i','s','t','o','r','y','B','u','f','f','e','r','S','i','z','e',0};
38 static const WCHAR wszMenuMask[] = {'M','e','n','u','M','a','s','k',0};
39 static const WCHAR wszQuickEdit[] = {'Q','u','i','c','k','E','d','i','t',0};
40 static const WCHAR wszScreenBufferSize[] = {'S','c','r','e','e','n','B','u','f','f','e','r','S','i','z','e',0};
41 static const WCHAR wszScreenColors[] = {'S','c','r','e','e','n','C','o','l','o','r','s',0};
42 static const WCHAR wszWindowSize[] = {'W','i','n','d','o','w','S','i','z','e',0};
44 /******************************************************************
49 BOOL WINECON_RegLoad(struct config_data* cfg)
56 WINE_TRACE("loading registry settings.\n");
57 if (RegOpenKey(HKEY_CURRENT_USER, wszConsole, &hConKey)) hConKey = 0;
60 if (!hConKey || RegQueryValueEx(hConKey, wszCursorSize, 0, &type, (char*)&val, &count))
62 cfg->cursor_size = val;
65 if (!hConKey || RegQueryValueEx(hConKey, wszCursorVisible, 0, &type, (char*)&val, &count))
67 cfg->cursor_visible = val;
70 if (!hConKey || RegQueryValueEx(hConKey, wszExitOnDie, 0, &type, (char*)&val, &count))
72 cfg->exit_on_die = val;
74 count = sizeof(cfg->face_name);
75 if (!hConKey || RegQueryValueEx(hConKey, wszFaceName, 0, &type, (char*)&cfg->face_name, &count))
76 cfg->face_name[0] = 0;
79 if (!hConKey || RegQueryValueEx(hConKey, wszFontSize, 0, &type, (char*)&val, &count))
81 cfg->cell_height = HIWORD(val);
82 cfg->cell_width = LOWORD(val);
85 if (!hConKey || RegQueryValueEx(hConKey, wszFontWeight, 0, &type, (char*)&val, &count))
87 cfg->font_weight = val;
90 if (!hConKey || RegQueryValueEx(hConKey, wszHistoryBufferSize, 0, &type, (char*)&val, &count))
92 cfg->history_size = val;
95 if (!hConKey || RegQueryValueEx(hConKey, wszMenuMask, 0, &type, (char*)&val, &count))
100 if (!hConKey || RegQueryValueEx(hConKey, wszQuickEdit, 0, &type, (char*)&val, &count))
102 cfg->quick_edit = val;
105 if (!hConKey || RegQueryValueEx(hConKey, wszScreenBufferSize, 0, &type, (char*)&val, &count))
107 cfg->sb_height = HIWORD(val);
108 cfg->sb_width = LOWORD(val);
111 if (!hConKey || RegQueryValueEx(hConKey, wszScreenColors, 0, &type, (char*)&val, &count))
116 if (!hConKey || RegQueryValueEx(hConKey, wszWindowSize, 0, &type, (char*)&val, &count))
118 cfg->win_height = HIWORD(val);
119 cfg->win_width = LOWORD(val);
121 /* win_pos isn't read from registry */
123 if (hConKey) RegCloseKey(hConKey);
127 /******************************************************************
132 BOOL WINECON_RegSave(const struct config_data* cfg)
137 WINE_TRACE("saving registry settings.\n");
138 if (RegCreateKey(HKEY_CURRENT_USER, wszConsole, &hConKey))
140 WINE_ERR("Can't open registry for saving\n");
144 val = cfg->cursor_size;
145 RegSetValueEx(hConKey, wszCursorSize, 0, REG_DWORD, (char*)&val, sizeof(val));
147 val = cfg->cursor_visible;
148 RegSetValueEx(hConKey, wszCursorVisible, 0, REG_DWORD, (char*)&val, sizeof(val));
150 val = cfg->exit_on_die;
151 RegSetValueEx(hConKey, wszExitOnDie, 0, REG_DWORD, (char*)&val, sizeof(val));
153 RegSetValueEx(hConKey, wszFaceName, 0, REG_SZ, (char*)&cfg->face_name, sizeof(cfg->face_name));
155 val = MAKELONG(cfg->cell_width, cfg->cell_height);
156 RegSetValueEx(hConKey, wszFontSize, 0, REG_DWORD, (char*)&val, sizeof(val));
158 val = cfg->font_weight;
159 RegSetValueEx(hConKey, wszFontWeight, 0, REG_DWORD, (char*)&val, sizeof(val));
161 val = cfg->history_size;
162 RegSetValueEx(hConKey, wszHistoryBufferSize, 0, REG_DWORD, (char*)&val, sizeof(val));
164 val = cfg->menu_mask;
165 RegSetValueEx(hConKey, wszMenuMask, 0, REG_DWORD, (char*)&val, sizeof(val));
167 val = cfg->quick_edit;
168 RegSetValueEx(hConKey, wszQuickEdit, 0, REG_DWORD, (char*)&val, sizeof(val));
170 val = MAKELONG(cfg->sb_width, cfg->sb_height);
171 RegSetValueEx(hConKey, wszScreenBufferSize, 0, REG_DWORD, (char*)&val, sizeof(val));
174 RegSetValueEx(hConKey, wszScreenColors, 0, REG_DWORD, (char*)&val, sizeof(val));
176 val = MAKELONG(cfg->win_width, cfg->win_height);
177 RegSetValueEx(hConKey, wszWindowSize, 0, REG_DWORD, (char*)&val, sizeof(val));
179 RegCloseKey(hConKey);