ReactOS  0.4.14-dev-114-gc8cbd56
settings.h File Reference
#include "concfg/settings.h"
Include dependency graph for settings.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define RGBFromAttrib(Console, Attribute)   ((Console)->Colors[(Attribute) & 0xF])
 
#define TextAttribFromAttrib(Attribute)   ( !((Attribute) & COMMON_LVB_REVERSE_VIDEO) ? (Attribute) & 0xF : ((Attribute) >> 4) & 0xF )
 
#define BkgdAttribFromAttrib(Attribute)   ( !((Attribute) & COMMON_LVB_REVERSE_VIDEO) ? ((Attribute) >> 4) & 0xF : (Attribute) & 0xF )
 
#define MakeAttrib(TextAttrib, BkgdAttrib)   (USHORT)((((BkgdAttrib) & 0xF) << 4) | ((TextAttrib) & 0xF))
 

Functions

VOID ConSrvApplyUserSettings (IN PCONSOLE Console, IN PCONSOLE_STATE_INFO ConsoleInfo)
 

Macro Definition Documentation

◆ BkgdAttribFromAttrib

#define BkgdAttribFromAttrib (   Attribute)    ( !((Attribute) & COMMON_LVB_REVERSE_VIDEO) ? ((Attribute) >> 4) & 0xF : (Attribute) & 0xF )

Definition at line 24 of file settings.h.

◆ MakeAttrib

#define MakeAttrib (   TextAttrib,
  BkgdAttrib 
)    (USHORT)((((BkgdAttrib) & 0xF) << 4) | ((TextAttrib) & 0xF))

Definition at line 25 of file settings.h.

◆ RGBFromAttrib

#define RGBFromAttrib (   Console,
  Attribute 
)    ((Console)->Colors[(Attribute) & 0xF])

Definition at line 22 of file settings.h.

◆ TextAttribFromAttrib

#define TextAttribFromAttrib (   Attribute)    ( !((Attribute) & COMMON_LVB_REVERSE_VIDEO) ? (Attribute) & 0xF : ((Attribute) >> 4) & 0xF )

Definition at line 23 of file settings.h.

Function Documentation

◆ ConSrvApplyUserSettings()

VOID ConSrvApplyUserSettings ( IN PCONSOLE  Console,
IN PCONSOLE_STATE_INFO  ConsoleInfo 
)

Definition at line 34 of file settings.c.

36 {
37  PCONSOLE_SCREEN_BUFFER ActiveBuffer = Console->ActiveBuffer;
38 
39  /*
40  * Apply terminal-edition settings:
41  * - QuickEdit and Insert modes,
42  * - history settings.
43  */
44  Console->QuickEdit = !!ConsoleInfo->QuickEdit;
45  Console->InsertMode = !!ConsoleInfo->InsertMode;
46 
47  /* Copy the new console palette */
48  // FIXME: Possible buffer overflow if s_colors is bigger than ConsoleInfo->ColorTable.
49  RtlCopyMemory(Console->Colors, ConsoleInfo->ColorTable, sizeof(s_Colors));
50 
51  /* Apply cursor size */
52  ActiveBuffer->CursorInfo.bVisible = (ConsoleInfo->CursorSize != 0);
53  ActiveBuffer->CursorInfo.dwSize = min(max(ConsoleInfo->CursorSize, 0), 100);
54 
55  /* Update the code page */
56  if ((Console->OutputCodePage != ConsoleInfo->CodePage) &&
57  IsValidCodePage(ConsoleInfo->CodePage))
58  {
59  Console->InputCodePage = Console->OutputCodePage = ConsoleInfo->CodePage;
60  // ConDrvSetConsoleCP(Console, ConsoleInfo->CodePage, TRUE); // Output
61  // ConDrvSetConsoleCP(Console, ConsoleInfo->CodePage, FALSE); // Input
62  }
63 
64  // FIXME: Check ConsoleInfo->WindowSize with respect to
65  // TermGetLargestConsoleWindowSize(...).
66 
67  if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
68  {
69  /* Resize its active screen-buffer */
71  COORD BufSize = ConsoleInfo->ScreenBufferSize;
72 
73  if (Console->FixedSize)
74  {
75  /*
76  * The console is in fixed-size mode, so we cannot resize anything
77  * at the moment. However, keep those settings somewhere so that
78  * we can try to set them up when we will be allowed to do so.
79  */
80  if (ConsoleInfo->WindowSize.X != ActiveBuffer->OldViewSize.X ||
81  ConsoleInfo->WindowSize.Y != ActiveBuffer->OldViewSize.Y)
82  {
83  ActiveBuffer->OldViewSize = ConsoleInfo->WindowSize;
84  }
85 
86  /* The buffer size is not allowed to be smaller than the view size */
87  if (BufSize.X >= ActiveBuffer->OldViewSize.X && BufSize.Y >= ActiveBuffer->OldViewSize.Y)
88  {
89  if (BufSize.X != ActiveBuffer->OldScreenBufferSize.X ||
90  BufSize.Y != ActiveBuffer->OldScreenBufferSize.Y)
91  {
92  /*
93  * The console is in fixed-size mode, so we cannot resize anything
94  * at the moment. However, keep those settings somewhere so that
95  * we can try to set them up when we will be allowed to do so.
96  */
97  ActiveBuffer->OldScreenBufferSize = BufSize;
98  }
99  }
100  }
101  else
102  {
103  BOOL SizeChanged = FALSE;
104 
105  /* Resize the console */
106  if (ConsoleInfo->WindowSize.X != ActiveBuffer->ViewSize.X ||
107  ConsoleInfo->WindowSize.Y != ActiveBuffer->ViewSize.Y)
108  {
109  ActiveBuffer->ViewSize = ConsoleInfo->WindowSize;
110  SizeChanged = TRUE;
111  }
112 
113  /* Resize the screen-buffer */
114  if (BufSize.X != ActiveBuffer->ScreenBufferSize.X ||
115  BufSize.Y != ActiveBuffer->ScreenBufferSize.Y)
116  {
118  SizeChanged = TRUE;
119  }
120 
121  if (SizeChanged) TermResizeTerminal(Console);
122  }
123 
124  /* Apply foreground and background colors for both screen and popup */
126  Buffer,
127  ConsoleInfo->ScreenAttributes,
128  ConsoleInfo->PopupAttributes);
129  }
130  else // if (GetType(ActiveBuffer) == GRAPHICS_BUFFER)
131  {
132  /*
133  * In any case we do NOT modify the size of the graphics screen-buffer.
134  * We just allow resizing the view only if the new size is smaller
135  * than the older one.
136  */
137  if (Console->FixedSize)
138  {
139  /*
140  * The console is in fixed-size mode, so we cannot resize anything
141  * at the moment. However, keep those settings somewhere so that
142  * we can try to set them up when we will be allowed to do so.
143  */
144  if (ConsoleInfo->WindowSize.X <= ActiveBuffer->ViewSize.X ||
145  ConsoleInfo->WindowSize.Y <= ActiveBuffer->ViewSize.Y)
146  {
147  ActiveBuffer->OldViewSize = ConsoleInfo->WindowSize;
148  }
149  }
150  else
151  {
152  /* Resize the view if its size is bigger than the specified size */
153  if (ConsoleInfo->WindowSize.X <= ActiveBuffer->ViewSize.X ||
154  ConsoleInfo->WindowSize.Y <= ActiveBuffer->ViewSize.Y)
155  {
156  ActiveBuffer->ViewSize = ConsoleInfo->WindowSize;
157  // SizeChanged = TRUE;
158  }
159  }
160  }
161 }
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
const COLORREF s_Colors[16]
Definition: conwnd.c:98
#define TermResizeTerminal(Console)
Definition: term.h:28
#define TEXTMODE_BUFFER
Definition: pccons.c:21
COORD OldScreenBufferSize
Definition: conio.h:90
COORD ScreenBufferSize
Definition: conio.h:87
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: bufpool.h:45
#define BufSize
Definition: FsRtlTunnel.c:28
ULONG X
Definition: bl.h:1340
BOOLEAN bVisible
Definition: blue.h:41
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI ConDrvChangeScreenBufferAttributes(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN USHORT NewScreenAttrib, IN USHORT NewPopupAttrib)
Definition: text.c:383
INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
Definition: gettype.c:129
Definition: bl.h:1338
BOOL WINAPI IsValidCodePage(UINT CodePage)
Definition: nls.c:1468
NTSTATUS ConioResizeBuffer(PCONSOLE Console, PTEXTMODE_SCREEN_BUFFER ScreenBuffer, COORD Size)
Definition: text.c:257
static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: video.c:47
#define min(a, b)
Definition: monoChain.cc:55
CConsole Console
CONSOLE_CURSOR_INFO CursorInfo
Definition: conio.h:102
ULONG Y
Definition: bl.h:1341
struct _TEXTMODE_SCREEN_BUFFER * PTEXTMODE_SCREEN_BUFFER

Referenced by GuiApplyUserSettings().