reactos/dll/cpl/console/console.h

91 lines
1.6 KiB
C
Raw Normal View History

#ifndef CONSOLE_H__
#define CONSOLE_H__
#include <stdio.h>
[CONSOLE.CPL]: Rewrite the way we deal with console font samples in the console properties dialog: - Remove the font helper functions that were already moved into concfg/font.c in r74462, and use the latter instead. - Use a double list for listing the available font sizes for a given face: * a ListBox for raster fonts; * a ComboBox for TrueType fonts, allowing the user to specify a custom size. The raster ListBox is wrapped using the LIST_CTL structure so that we can use the bisection functions on it. - Allow the user to specify TrueType font size either in pixels or in points. Raster font sizes however are always in pixels. - Try to remember the nearest font size across different selected face changes. - Try to support custom-sized TrueType fonts (using the ComboBox's edit field). May need more improvements! - Retrieve the correct character cell height & width size in pixels when selecting a font (especially when it's a TrueType one). - We now support bold console fonts too, see CORE-13122 (thanks Katayama!). - Remove the commented-out "temporary code for future reference". - Use a global cached font "hCurrentFont" that gets initialized when the console properties applet is created, so that we now can have a correct font in the screen samples when one directly views e.g. the "Color" tab, without going first in the "Font" tab. This current font is of course updated whenever one changes the font settings. Tested with success on Windows 2003, Windows 7 and on ReactOS. CORE-13122 CORE-13182 #resolve svn path=/trunk/; revision=74469
2017-05-03 23:56:35 +00:00
#include <stdlib.h>
#include <wchar.h>
[CONSOLE.DLL-KERNEL32-CONSRV] Fix the console properties dialog, when launching and transmitting console properties. Before, the properties dialog was directly launched by the console server (consrv), running with CSRSS (System) privileges, what constituted a security hole. Now, I create a remote thread in the running process owning the console for launching the properties dialog (thus it has only user privileges, and not System ones anymore). For that purpose, I basically took the technique described in the following paper (Cesar Cerrudo, "Story of a dumb patch", http://www.argeniss.com/research/MSBugPaper.pdf or http://www.scn.rain.com/~neighorn/PDF/MSBugPaper.pdf), where basically the console server shares the console properties via a shared memory section with the console properties dialog dll. The address of the thread which launches the dialog in the context of the console app is given to the console server the same way as we do for the control handler (called e.g. when you press Ctrl-C, etc...) Of course this is quite hackish, because you have the GUI interface split between the console server and the console properties dialog dll. Something far more elegant would be to put all the GUI thingie into a dedicated dll or exe, running with the same privileges as the console program itself (a kind of console -- or terminal -- emulator). [CONSOLE.DLL] Fix retriving / setting colors.c and other things. [CONSRV.DLL] - Fix retrieving / setting console properties from the registry (via the HKCU\Console\* keys), via the shell shortcuts (not totally done at the moment, because somebody has to implement properly that thing : http://msdn.microsoft.com/en-us/library/windows/desktop/bb773359(v=vs.85).aspx (NT_CONSOLE_PROPS structure stored as a shortcut data block) (at application launching time), and via the console properties dialog. - Few DPRINTs removed. svn path=/branches/ros-csrss/; revision=58415
2013-03-03 15:35:12 +00:00
#define WIN32_NO_STATUS
#include <windef.h>
#include <winbase.h>
[CONSOLE.CPL]: Rewrite the way we deal with console font samples in the console properties dialog: - Remove the font helper functions that were already moved into concfg/font.c in r74462, and use the latter instead. - Use a double list for listing the available font sizes for a given face: * a ListBox for raster fonts; * a ComboBox for TrueType fonts, allowing the user to specify a custom size. The raster ListBox is wrapped using the LIST_CTL structure so that we can use the bisection functions on it. - Allow the user to specify TrueType font size either in pixels or in points. Raster font sizes however are always in pixels. - Try to remember the nearest font size across different selected face changes. - Try to support custom-sized TrueType fonts (using the ComboBox's edit field). May need more improvements! - Retrieve the correct character cell height & width size in pixels when selecting a font (especially when it's a TrueType one). - We now support bold console fonts too, see CORE-13122 (thanks Katayama!). - Remove the commented-out "temporary code for future reference". - Use a global cached font "hCurrentFont" that gets initialized when the console properties applet is created, so that we now can have a correct font in the screen samples when one directly views e.g. the "Color" tab, without going first in the "Font" tab. This current font is of course updated whenever one changes the font settings. Tested with success on Windows 2003, Windows 7 and on ReactOS. CORE-13122 CORE-13182 #resolve svn path=/trunk/; revision=74469
2017-05-03 23:56:35 +00:00
#include <wincon.h>
#include <wingdi.h>
#include <winnls.h>
[CONSRV] - Introduce a "console configuration" library that is used by both CONSRV and the console properties applet so that they can share common code concerning getting/setting console registry properties. - Make use of the Windows-compatible (and undocumented) CONSOLE_STATE_INFO structure for that purpose (as well as the WM_SETCONSOLEINFO): see commits r63819 and r58415 and links within for more details. Note: this structure needs to be 4-byte packed (contrary to what it is said in almost all the links from above. The difference is only visible at the level of the last member that is the ConsoleTitle string array. This was tested on windows). - Simplify some parts of console settings initialization. - Some work is still needed concerning how to correctly retrieve the default console settings (without touching the ConsoleTitle member of CONSOLE_STATE_INFO, contrary to what we do currently). [CONSOLE.DLL] - Make the console properties applet windows-compatible, in the sense that you can now run it on win2k3 and use it instead of the windows one. This implies having the same strange hacks as windows' one, namely, that the window handle parameter of the CPlApplet entry point is either used as the caller (parent) window handle, OR, as a shared section handle to shared data with CONSRV. [KERNEL32] - Rework the console applet initialization accordingly. Also we reload each time the console.dll when opening the console applet, and then unload it: this "allows" to reset all the global variables that console.dll may (and does) have. svn path=/trunk/; revision=66867
2015-03-24 23:58:44 +00:00
#include <winreg.h>
[CONSOLE.CPL]: Rewrite the way we deal with console font samples in the console properties dialog: - Remove the font helper functions that were already moved into concfg/font.c in r74462, and use the latter instead. - Use a double list for listing the available font sizes for a given face: * a ListBox for raster fonts; * a ComboBox for TrueType fonts, allowing the user to specify a custom size. The raster ListBox is wrapped using the LIST_CTL structure so that we can use the bisection functions on it. - Allow the user to specify TrueType font size either in pixels or in points. Raster font sizes however are always in pixels. - Try to remember the nearest font size across different selected face changes. - Try to support custom-sized TrueType fonts (using the ComboBox's edit field). May need more improvements! - Retrieve the correct character cell height & width size in pixels when selecting a font (especially when it's a TrueType one). - We now support bold console fonts too, see CORE-13122 (thanks Katayama!). - Remove the commented-out "temporary code for future reference". - Use a global cached font "hCurrentFont" that gets initialized when the console properties applet is created, so that we now can have a correct font in the screen samples when one directly views e.g. the "Color" tab, without going first in the "Font" tab. This current font is of course updated whenever one changes the font settings. Tested with success on Windows 2003, Windows 7 and on ReactOS. CORE-13122 CORE-13182 #resolve svn path=/trunk/; revision=74469
2017-05-03 23:56:35 +00:00
#include <winuser.h>
#include <commctrl.h>
#include <cpl.h>
#include <strsafe.h>
#include "resource.h"
#define EnableDlgItem(hDlg, nID, bEnable) \
EnableWindow(GetDlgItem((hDlg), (nID)), (bEnable))
/* Shared header with the GUI Terminal Front-End from consrv.dll */
[CONSOLE.CPL]: Rewrite the way we deal with console font samples in the console properties dialog: - Remove the font helper functions that were already moved into concfg/font.c in r74462, and use the latter instead. - Use a double list for listing the available font sizes for a given face: * a ListBox for raster fonts; * a ComboBox for TrueType fonts, allowing the user to specify a custom size. The raster ListBox is wrapped using the LIST_CTL structure so that we can use the bisection functions on it. - Allow the user to specify TrueType font size either in pixels or in points. Raster font sizes however are always in pixels. - Try to remember the nearest font size across different selected face changes. - Try to support custom-sized TrueType fonts (using the ComboBox's edit field). May need more improvements! - Retrieve the correct character cell height & width size in pixels when selecting a font (especially when it's a TrueType one). - We now support bold console fonts too, see CORE-13122 (thanks Katayama!). - Remove the commented-out "temporary code for future reference". - Use a global cached font "hCurrentFont" that gets initialized when the console properties applet is created, so that we now can have a correct font in the screen samples when one directly views e.g. the "Color" tab, without going first in the "Font" tab. This current font is of course updated whenever one changes the font settings. Tested with success on Windows 2003, Windows 7 and on ReactOS. CORE-13122 CORE-13182 #resolve svn path=/trunk/; revision=74469
2017-05-03 23:56:35 +00:00
#include "concfg.h" // in /winsrv/concfg/
typedef enum _TEXT_TYPE
{
Screen,
Popup
} TEXT_TYPE;
[CONSRV] - Introduce a "console configuration" library that is used by both CONSRV and the console properties applet so that they can share common code concerning getting/setting console registry properties. - Make use of the Windows-compatible (and undocumented) CONSOLE_STATE_INFO structure for that purpose (as well as the WM_SETCONSOLEINFO): see commits r63819 and r58415 and links within for more details. Note: this structure needs to be 4-byte packed (contrary to what it is said in almost all the links from above. The difference is only visible at the level of the last member that is the ConsoleTitle string array. This was tested on windows). - Simplify some parts of console settings initialization. - Some work is still needed concerning how to correctly retrieve the default console settings (without touching the ConsoleTitle member of CONSOLE_STATE_INFO, contrary to what we do currently). [CONSOLE.DLL] - Make the console properties applet windows-compatible, in the sense that you can now run it on win2k3 and use it instead of the windows one. This implies having the same strange hacks as windows' one, namely, that the window handle parameter of the CPlApplet entry point is either used as the caller (parent) window handle, OR, as a shared section handle to shared data with CONSRV. [KERNEL32] - Rework the console applet initialization accordingly. Also we reload each time the console.dll when opening the console applet, and then unload it: this "allows" to reset all the global variables that console.dll may (and does) have. svn path=/trunk/; revision=66867
2015-03-24 23:58:44 +00:00
/* Globals */
[CONSOLE.CPL]: Rewrite the way we deal with console font samples in the console properties dialog: - Remove the font helper functions that were already moved into concfg/font.c in r74462, and use the latter instead. - Use a double list for listing the available font sizes for a given face: * a ListBox for raster fonts; * a ComboBox for TrueType fonts, allowing the user to specify a custom size. The raster ListBox is wrapped using the LIST_CTL structure so that we can use the bisection functions on it. - Allow the user to specify TrueType font size either in pixels or in points. Raster font sizes however are always in pixels. - Try to remember the nearest font size across different selected face changes. - Try to support custom-sized TrueType fonts (using the ComboBox's edit field). May need more improvements! - Retrieve the correct character cell height & width size in pixels when selecting a font (especially when it's a TrueType one). - We now support bold console fonts too, see CORE-13122 (thanks Katayama!). - Remove the commented-out "temporary code for future reference". - Use a global cached font "hCurrentFont" that gets initialized when the console properties applet is created, so that we now can have a correct font in the screen samples when one directly views e.g. the "Color" tab, without going first in the "Font" tab. This current font is of course updated whenever one changes the font settings. Tested with success on Windows 2003, Windows 7 and on ReactOS. CORE-13122 CORE-13182 #resolve svn path=/trunk/; revision=74469
2017-05-03 23:56:35 +00:00
extern HINSTANCE hApplet;
[CONSRV] - Introduce a "console configuration" library that is used by both CONSRV and the console properties applet so that they can share common code concerning getting/setting console registry properties. - Make use of the Windows-compatible (and undocumented) CONSOLE_STATE_INFO structure for that purpose (as well as the WM_SETCONSOLEINFO): see commits r63819 and r58415 and links within for more details. Note: this structure needs to be 4-byte packed (contrary to what it is said in almost all the links from above. The difference is only visible at the level of the last member that is the ConsoleTitle string array. This was tested on windows). - Simplify some parts of console settings initialization. - Some work is still needed concerning how to correctly retrieve the default console settings (without touching the ConsoleTitle member of CONSOLE_STATE_INFO, contrary to what we do currently). [CONSOLE.DLL] - Make the console properties applet windows-compatible, in the sense that you can now run it on win2k3 and use it instead of the windows one. This implies having the same strange hacks as windows' one, namely, that the window handle parameter of the CPlApplet entry point is either used as the caller (parent) window handle, OR, as a shared section handle to shared data with CONSRV. [KERNEL32] - Rework the console applet initialization accordingly. Also we reload each time the console.dll when opening the console applet, and then unload it: this "allows" to reset all the global variables that console.dll may (and does) have. svn path=/trunk/; revision=66867
2015-03-24 23:58:44 +00:00
extern PCONSOLE_STATE_INFO ConInfo;
[CONSOLE.CPL]: Rewrite the way we deal with console font samples in the console properties dialog: - Remove the font helper functions that were already moved into concfg/font.c in r74462, and use the latter instead. - Use a double list for listing the available font sizes for a given face: * a ListBox for raster fonts; * a ComboBox for TrueType fonts, allowing the user to specify a custom size. The raster ListBox is wrapped using the LIST_CTL structure so that we can use the bisection functions on it. - Allow the user to specify TrueType font size either in pixels or in points. Raster font sizes however are always in pixels. - Try to remember the nearest font size across different selected face changes. - Try to support custom-sized TrueType fonts (using the ComboBox's edit field). May need more improvements! - Retrieve the correct character cell height & width size in pixels when selecting a font (especially when it's a TrueType one). - We now support bold console fonts too, see CORE-13122 (thanks Katayama!). - Remove the commented-out "temporary code for future reference". - Use a global cached font "hCurrentFont" that gets initialized when the console properties applet is created, so that we now can have a correct font in the screen samples when one directly views e.g. the "Color" tab, without going first in the "Font" tab. This current font is of course updated whenever one changes the font settings. Tested with success on Windows 2003, Windows 7 and on ReactOS. CORE-13122 CORE-13182 #resolve svn path=/trunk/; revision=74469
2017-05-03 23:56:35 +00:00
extern HFONT hCurrentFont;
VOID ApplyConsoleInfo(HWND hwndDlg);
[CONSOLE.CPL]: Rewrite the way we deal with console font samples in the console properties dialog: - Remove the font helper functions that were already moved into concfg/font.c in r74462, and use the latter instead. - Use a double list for listing the available font sizes for a given face: * a ListBox for raster fonts; * a ComboBox for TrueType fonts, allowing the user to specify a custom size. The raster ListBox is wrapped using the LIST_CTL structure so that we can use the bisection functions on it. - Allow the user to specify TrueType font size either in pixels or in points. Raster font sizes however are always in pixels. - Try to remember the nearest font size across different selected face changes. - Try to support custom-sized TrueType fonts (using the ComboBox's edit field). May need more improvements! - Retrieve the correct character cell height & width size in pixels when selecting a font (especially when it's a TrueType one). - We now support bold console fonts too, see CORE-13122 (thanks Katayama!). - Remove the commented-out "temporary code for future reference". - Use a global cached font "hCurrentFont" that gets initialized when the console properties applet is created, so that we now can have a correct font in the screen samples when one directly views e.g. the "Color" tab, without going first in the "Font" tab. This current font is of course updated whenever one changes the font settings. Tested with success on Windows 2003, Windows 7 and on ReactOS. CORE-13122 CORE-13182 #resolve svn path=/trunk/; revision=74469
2017-05-03 23:56:35 +00:00
/* Preview Windows */
BOOL
RegisterWinPrevClass(
IN HINSTANCE hInstance);
[CONSOLE.CPL]: Rewrite the way we deal with console font samples in the console properties dialog: - Remove the font helper functions that were already moved into concfg/font.c in r74462, and use the latter instead. - Use a double list for listing the available font sizes for a given face: * a ListBox for raster fonts; * a ComboBox for TrueType fonts, allowing the user to specify a custom size. The raster ListBox is wrapped using the LIST_CTL structure so that we can use the bisection functions on it. - Allow the user to specify TrueType font size either in pixels or in points. Raster font sizes however are always in pixels. - Try to remember the nearest font size across different selected face changes. - Try to support custom-sized TrueType fonts (using the ComboBox's edit field). May need more improvements! - Retrieve the correct character cell height & width size in pixels when selecting a font (especially when it's a TrueType one). - We now support bold console fonts too, see CORE-13122 (thanks Katayama!). - Remove the commented-out "temporary code for future reference". - Use a global cached font "hCurrentFont" that gets initialized when the console properties applet is created, so that we now can have a correct font in the screen samples when one directly views e.g. the "Color" tab, without going first in the "Font" tab. This current font is of course updated whenever one changes the font settings. Tested with success on Windows 2003, Windows 7 and on ReactOS. CORE-13122 CORE-13182 #resolve svn path=/trunk/; revision=74469
2017-05-03 23:56:35 +00:00
BOOL
UnRegisterWinPrevClass(
IN HINSTANCE hInstance);
VOID
[CONSOLE.CPL]: Rewrite the way we deal with console font samples in the console properties dialog: - Remove the font helper functions that were already moved into concfg/font.c in r74462, and use the latter instead. - Use a double list for listing the available font sizes for a given face: * a ListBox for raster fonts; * a ComboBox for TrueType fonts, allowing the user to specify a custom size. The raster ListBox is wrapped using the LIST_CTL structure so that we can use the bisection functions on it. - Allow the user to specify TrueType font size either in pixels or in points. Raster font sizes however are always in pixels. - Try to remember the nearest font size across different selected face changes. - Try to support custom-sized TrueType fonts (using the ComboBox's edit field). May need more improvements! - Retrieve the correct character cell height & width size in pixels when selecting a font (especially when it's a TrueType one). - We now support bold console fonts too, see CORE-13122 (thanks Katayama!). - Remove the commented-out "temporary code for future reference". - Use a global cached font "hCurrentFont" that gets initialized when the console properties applet is created, so that we now can have a correct font in the screen samples when one directly views e.g. the "Color" tab, without going first in the "Font" tab. This current font is of course updated whenever one changes the font settings. Tested with success on Windows 2003, Windows 7 and on ReactOS. CORE-13122 CORE-13182 #resolve svn path=/trunk/; revision=74469
2017-05-03 23:56:35 +00:00
PaintText(
IN LPDRAWITEMSTRUCT drawItem,
IN PCONSOLE_STATE_INFO pConInfo,
IN TEXT_TYPE TextMode);
struct _LIST_CTL;
typedef INT (*PLIST_GETCOUNT)(IN struct _LIST_CTL* ListCtl);
typedef ULONG_PTR (*PLIST_GETDATA)(IN struct _LIST_CTL* ListCtl, IN INT Index);
typedef struct _LIST_CTL
{
HWND hWndList;
PLIST_GETCOUNT GetCount;
PLIST_GETDATA GetData;
} LIST_CTL, *PLIST_CTL;
UINT
BisectListSortedByValueEx(
IN PLIST_CTL ListCtl,
IN ULONG_PTR Value,
IN UINT itemStart,
IN UINT itemEnd,
OUT PUINT pValueItem OPTIONAL,
IN BOOL BisectRightOrLeft);
UINT
BisectListSortedByValue(
IN PLIST_CTL ListCtl,
IN ULONG_PTR Value,
OUT PUINT pValueItem OPTIONAL,
IN BOOL BisectRightOrLeft);
#endif /* CONSOLE_H__ */