ReactOS
0.4.16-dev-122-g325d74c
settings.c
Go to the documentation of this file.
1
/*
2
* COPYRIGHT: See COPYING in the top level directory
3
* PROJECT: ReactOS Console Server DLL
4
* FILE: win32ss/user/winsrv/consrv/settings.c
5
* PURPOSE: Console settings management
6
* PROGRAMMERS: Johannes Anderwald
7
* Hermes Belusca-Maito (hermes.belusca@sfr.fr)
8
*/
9
10
/* INCLUDES *******************************************************************/
11
12
#include "
consrv.h
"
13
#include "
history.h
"
14
#include "../concfg/font.h"
15
16
#define NDEBUG
17
#include <debug.h>
18
19
/* GLOBALS ********************************************************************/
20
21
extern
const
COLORREF
s_Colors
[16];
22
23
24
/* FUNCTIONS ******************************************************************/
25
26
NTSTATUS
NTAPI
27
ConDrvChangeScreenBufferAttributes
(
IN
PCONSOLE
Console
,
28
IN
PTEXTMODE_SCREEN_BUFFER
Buffer
,
29
IN
USHORT
NewScreenAttrib,
30
IN
USHORT
NewPopupAttrib);
31
/*
32
* NOTE: This function explicitly references Console->ActiveBuffer.
33
* It is possible that it should go into some frontend...
34
*/
35
VOID
36
ConSrvApplyUserSettings
(
37
IN
PCONSRV_CONSOLE
Console
,
38
IN
PCONSOLE_STATE_INFO
ConsoleInfo
)
39
{
40
PCONSOLE_SCREEN_BUFFER
ActiveBuffer =
Console
->ActiveBuffer;
41
42
/*
43
* Apply terminal-edition settings:
44
* - QuickEdit and Insert modes,
45
* - History settings.
46
*/
47
Console
->QuickEdit = !!
ConsoleInfo
->QuickEdit;
48
Console
->InsertMode = !!
ConsoleInfo
->InsertMode;
50
HistoryReshapeAllBuffers
(
Console
,
51
ConsoleInfo
->HistoryBufferSize,
52
ConsoleInfo
->NumberOfHistoryBuffers,
53
ConsoleInfo
->HistoryNoDup);
54
55
/* Copy the new console palette */
56
// FIXME: Possible buffer overflow if s_colors is bigger than ConsoleInfo->ColorTable.
57
RtlCopyMemory
(
Console
->Colors,
ConsoleInfo
->ColorTable,
sizeof
(
s_Colors
));
58
59
/* Apply cursor size */
60
ActiveBuffer->
CursorInfo
.
bVisible
= (
ConsoleInfo
->CursorSize != 0);
61
ActiveBuffer->
CursorInfo
.
dwSize
=
min
(
max
(
ConsoleInfo
->CursorSize, 0), 100);
62
63
/* Update the code page */
64
if
((
Console
->OutputCodePage !=
ConsoleInfo
->CodePage) &&
65
IsValidCodePage
(
ConsoleInfo
->CodePage))
66
{
67
// ConDrvSetConsoleCP(Console, ConsoleInfo->CodePage, TRUE); // Output
68
// ConDrvSetConsoleCP(Console, ConsoleInfo->CodePage, FALSE); // Input
69
if
(
TermSetCodePage
(
Console
,
ConsoleInfo
->CodePage))
70
{
71
CON_SET_OUTPUT_CP
(
Console
,
ConsoleInfo
->CodePage);
72
Console
->InputCodePage =
ConsoleInfo
->CodePage;
73
}
74
}
75
76
// FIXME: Check ConsoleInfo->WindowSize with respect to
77
// TermGetLargestConsoleWindowSize(...).
78
79
if
(
GetType
(ActiveBuffer) ==
TEXTMODE_BUFFER
)
80
{
81
/* Resize its active screen-buffer */
82
PTEXTMODE_SCREEN_BUFFER
Buffer
= (
PTEXTMODE_SCREEN_BUFFER
)ActiveBuffer;
83
COORD
BufSize
=
ConsoleInfo
->ScreenBufferSize;
84
85
if
(
Console
->FixedSize)
86
{
87
/*
88
* The console is in fixed-size mode, so we cannot resize anything
89
* at the moment. However, keep those settings somewhere so that
90
* we can try to set them up when we will be allowed to do so.
91
*/
92
if
(
ConsoleInfo
->WindowSize.X != ActiveBuffer->
OldViewSize
.
X
||
93
ConsoleInfo
->WindowSize.Y != ActiveBuffer->
OldViewSize
.
Y
)
94
{
95
ActiveBuffer->
OldViewSize
=
ConsoleInfo
->WindowSize;
96
}
97
98
/* The buffer size is not allowed to be smaller than the view size */
99
if
(
BufSize
.X >= ActiveBuffer->
OldViewSize
.
X
&&
BufSize
.Y >= ActiveBuffer->
OldViewSize
.
Y
)
100
{
101
if
(
BufSize
.X != ActiveBuffer->
OldScreenBufferSize
.
X
||
102
BufSize
.Y != ActiveBuffer->
OldScreenBufferSize
.
Y
)
103
{
104
/*
105
* The console is in fixed-size mode, so we cannot resize anything
106
* at the moment. However, keep those settings somewhere so that
107
* we can try to set them up when we will be allowed to do so.
108
*/
109
ActiveBuffer->
OldScreenBufferSize
=
BufSize
;
110
}
111
}
112
}
113
else
114
{
115
BOOL
SizeChanged =
FALSE
;
116
117
/* Resize the console */
118
if
(
ConsoleInfo
->WindowSize.X != ActiveBuffer->
ViewSize
.
X
||
119
ConsoleInfo
->WindowSize.Y != ActiveBuffer->
ViewSize
.
Y
)
120
{
121
ActiveBuffer->
ViewSize
=
ConsoleInfo
->WindowSize;
122
SizeChanged =
TRUE
;
123
}
124
125
/* Resize the screen-buffer */
126
if
(
BufSize
.X != ActiveBuffer->
ScreenBufferSize
.
X
||
127
BufSize
.Y != ActiveBuffer->
ScreenBufferSize
.
Y
)
128
{
129
if
(
NT_SUCCESS
(
ConioResizeBuffer
((
PCONSOLE
)
Console
,
Buffer
,
BufSize
)))
130
SizeChanged =
TRUE
;
131
}
132
133
if
(SizeChanged)
TermResizeTerminal
(
Console
);
134
}
135
136
/* Apply foreground and background colors for both screen and popup */
137
ConDrvChangeScreenBufferAttributes
((
PCONSOLE
)
Console
,
138
Buffer
,
139
ConsoleInfo
->ScreenAttributes,
140
ConsoleInfo
->PopupAttributes);
141
}
142
else
// if (GetType(ActiveBuffer) == GRAPHICS_BUFFER)
143
{
144
/*
145
* In any case we do NOT modify the size of the graphics screen-buffer.
146
* We just allow resizing the view only if the new size is smaller
147
* than the older one.
148
*/
149
if
(
Console
->FixedSize)
150
{
151
/*
152
* The console is in fixed-size mode, so we cannot resize anything
153
* at the moment. However, keep those settings somewhere so that
154
* we can try to set them up when we will be allowed to do so.
155
*/
156
if
(
ConsoleInfo
->WindowSize.X <= ActiveBuffer->
ViewSize
.
X
||
157
ConsoleInfo
->WindowSize.Y <= ActiveBuffer->
ViewSize
.
Y
)
158
{
159
ActiveBuffer->
OldViewSize
=
ConsoleInfo
->WindowSize;
160
}
161
}
162
else
163
{
164
/* Resize the view if its size is bigger than the specified size */
165
if
(
ConsoleInfo
->WindowSize.X <= ActiveBuffer->
ViewSize
.
X
||
166
ConsoleInfo
->WindowSize.Y <= ActiveBuffer->
ViewSize
.
Y
)
167
{
168
ActiveBuffer->
ViewSize
=
ConsoleInfo
->WindowSize;
169
// SizeChanged = TRUE;
170
}
171
}
172
}
173
}
174
175
/* EOF */
BufSize
#define BufSize
Definition:
FsRtlTunnel.c:28
Console
CConsole Console
Definition:
RegistryExplorer.cpp:54
NTSTATUS
LONG NTSTATUS
Definition:
precomp.h:26
Buffer
Definition:
bufpool.h:45
consrv.h
TRUE
#define TRUE
Definition:
types.h:120
FALSE
#define FALSE
Definition:
types.h:117
NT_SUCCESS
#define NT_SUCCESS(StatCode)
Definition:
apphelp.c:33
IsValidCodePage
BOOL WINAPI IsValidCodePage(UINT codepage)
Definition:
locale.c:2078
BOOL
unsigned int BOOL
Definition:
ntddk_ex.h:94
void
Definition:
nsiface.idl:2307
min
#define min(a, b)
Definition:
monoChain.cc:55
TEXTMODE_BUFFER
#define TEXTMODE_BUFFER
Definition:
pccons.c:21
USHORT
unsigned short USHORT
Definition:
pedump.c:61
_CONSOLE_SCREEN_BUFFER
Definition:
conio.h:57
_CONSOLE_SCREEN_BUFFER::CursorInfo
CONSOLE_CURSOR_INFO CursorInfo
Definition:
conio.h:75
_CONSOLE_SCREEN_BUFFER::OldScreenBufferSize
COORD OldScreenBufferSize
Definition:
conio.h:65
_CONSOLE_SCREEN_BUFFER::ScreenBufferSize
COORD ScreenBufferSize
Definition:
conio.h:62
_CONSOLE_SCREEN_BUFFER::OldViewSize
COORD OldViewSize
Definition:
conio.h:66
_CONSOLE_SCREEN_BUFFER::ViewSize
COORD ViewSize
Definition:
conio.h:63
_CONSOLE_STATE_INFO
Definition:
settings.h:28
_CONSOLE
Definition:
conio.h:289
_CONSRV_CONSOLE
Definition:
conio_winsrv.h:114
_COORD
Definition:
bl.h:1338
_COORD::Y
ULONG Y
Definition:
bl.h:1340
_COORD::X
ULONG X
Definition:
bl.h:1339
_TEXTMODE_SCREEN_BUFFER
Definition:
conio.h:125
tagCONSOLE_CURSOR_INFO::bVisible
INT bVisible
Definition:
blue.h:50
tagCONSOLE_CURSOR_INFO::dwSize
ULONG dwSize
Definition:
blue.h:49
ConsoleInfo
static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition:
video.c:47
max
#define max(a, b)
Definition:
svc.c:63
TermResizeTerminal
#define TermResizeTerminal(Console)
Definition:
term.h:28
TermSetCodePage
#define TermSetCodePage(Console, CodePage)
Definition:
term.h:38
NTAPI
#define NTAPI
Definition:
typedefs.h:36
RtlCopyMemory
#define RtlCopyMemory(Destination, Source, Length)
Definition:
typedefs.h:263
IN
#define IN
Definition:
typedefs.h:39
s_Colors
static const COLORREF s_Colors[16]
Definition:
settings.c:37
ConioResizeBuffer
NTSTATUS ConioResizeBuffer(PCONSOLE Console, PTEXTMODE_SCREEN_BUFFER ScreenBuffer, COORD Size)
Definition:
text.c:359
HistoryReshapeAllBuffers
VOID HistoryReshapeAllBuffers(IN PCONSRV_CONSOLE Console, IN ULONG HistoryBufferSize, IN ULONG MaxNumberOfHistoryBuffers, IN BOOLEAN HistoryNoDup)
Definition:
history.c:371
history.h
PTEXTMODE_SCREEN_BUFFER
struct _TEXTMODE_SCREEN_BUFFER * PTEXTMODE_SCREEN_BUFFER
CON_SET_OUTPUT_CP
#define CON_SET_OUTPUT_CP(Console, CodePage)
Definition:
conio.h:323
GetType
#define GetType(This)
Definition:
conio.h:54
ConDrvChangeScreenBufferAttributes
NTSTATUS NTAPI ConDrvChangeScreenBufferAttributes(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN USHORT NewScreenAttrib, IN USHORT NewPopupAttrib)
Definition:
text.c:497
ConSrvApplyUserSettings
VOID ConSrvApplyUserSettings(IN PCONSRV_CONSOLE Console, IN PCONSOLE_STATE_INFO ConsoleInfo)
Definition:
settings.c:36
COLORREF
DWORD COLORREF
Definition:
windef.h:300
win32ss
user
winsrv
consrv
settings.c
Generated on Sat Oct 12 2024 06:15:22 for ReactOS by
1.9.6