ReactOS  0.4.14-dev-854-gb9426a3
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 35 of file settings.c.

37 {
38  PCONSOLE_SCREEN_BUFFER ActiveBuffer = Console->ActiveBuffer;
39 
40  /*
41  * Apply terminal-edition settings:
42  * - QuickEdit and Insert modes,
43  * - history settings.
44  */
45  Console->QuickEdit = !!ConsoleInfo->QuickEdit;
46  Console->InsertMode = !!ConsoleInfo->InsertMode;
47 
48  /* Copy the new console palette */
49  // FIXME: Possible buffer overflow if s_colors is bigger than ConsoleInfo->ColorTable.
50  RtlCopyMemory(Console->Colors, ConsoleInfo->ColorTable, sizeof(s_Colors));
51 
52  /* Apply cursor size */
53  ActiveBuffer->CursorInfo.bVisible = (ConsoleInfo->CursorSize != 0);
54  ActiveBuffer->CursorInfo.dwSize = min(max(ConsoleInfo->CursorSize, 0), 100);
55 
56  /* Update the code page */
57  if ((Console->OutputCodePage != ConsoleInfo->CodePage) &&
58  IsValidCodePage(ConsoleInfo->CodePage))
59  {
60  Console->InputCodePage = Console->OutputCodePage = ConsoleInfo->CodePage;
61  // ConDrvSetConsoleCP(Console, ConsoleInfo->CodePage, TRUE); // Output
62  // ConDrvSetConsoleCP(Console, ConsoleInfo->CodePage, FALSE); // Input
63 
64  Console->IsCJK = IsCJKCodePage(Console->OutputCodePage);
65  }
66 
67  // FIXME: Check ConsoleInfo->WindowSize with respect to
68  // TermGetLargestConsoleWindowSize(...).
69 
70  if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
71  {
72  /* Resize its active screen-buffer */
74  COORD BufSize = ConsoleInfo->ScreenBufferSize;
75 
76  if (Console->FixedSize)
77  {
78  /*
79  * The console is in fixed-size mode, so we cannot resize anything
80  * at the moment. However, keep those settings somewhere so that
81  * we can try to set them up when we will be allowed to do so.
82  */
83  if (ConsoleInfo->WindowSize.X != ActiveBuffer->OldViewSize.X ||
84  ConsoleInfo->WindowSize.Y != ActiveBuffer->OldViewSize.Y)
85  {
86  ActiveBuffer->OldViewSize = ConsoleInfo->WindowSize;
87  }
88 
89  /* The buffer size is not allowed to be smaller than the view size */
90  if (BufSize.X >= ActiveBuffer->OldViewSize.X && BufSize.Y >= ActiveBuffer->OldViewSize.Y)
91  {
92  if (BufSize.X != ActiveBuffer->OldScreenBufferSize.X ||
93  BufSize.Y != ActiveBuffer->OldScreenBufferSize.Y)
94  {
95  /*
96  * The console is in fixed-size mode, so we cannot resize anything
97  * at the moment. However, keep those settings somewhere so that
98  * we can try to set them up when we will be allowed to do so.
99  */
100  ActiveBuffer->OldScreenBufferSize = BufSize;
101  }
102  }
103  }
104  else
105  {
106  BOOL SizeChanged = FALSE;
107 
108  /* Resize the console */
109  if (ConsoleInfo->WindowSize.X != ActiveBuffer->ViewSize.X ||
110  ConsoleInfo->WindowSize.Y != ActiveBuffer->ViewSize.Y)
111  {
112  ActiveBuffer->ViewSize = ConsoleInfo->WindowSize;
113  SizeChanged = TRUE;
114  }
115 
116  /* Resize the screen-buffer */
117  if (BufSize.X != ActiveBuffer->ScreenBufferSize.X ||
118  BufSize.Y != ActiveBuffer->ScreenBufferSize.Y)
119  {
121  SizeChanged = TRUE;
122  }
123 
124  if (SizeChanged) TermResizeTerminal(Console);
125  }
126 
127  /* Apply foreground and background colors for both screen and popup */
129  Buffer,
130  ConsoleInfo->ScreenAttributes,
131  ConsoleInfo->PopupAttributes);
132  }
133  else // if (GetType(ActiveBuffer) == GRAPHICS_BUFFER)
134  {
135  /*
136  * In any case we do NOT modify the size of the graphics screen-buffer.
137  * We just allow resizing the view only if the new size is smaller
138  * than the older one.
139  */
140  if (Console->FixedSize)
141  {
142  /*
143  * The console is in fixed-size mode, so we cannot resize anything
144  * at the moment. However, keep those settings somewhere so that
145  * we can try to set them up when we will be allowed to do so.
146  */
147  if (ConsoleInfo->WindowSize.X <= ActiveBuffer->ViewSize.X ||
148  ConsoleInfo->WindowSize.Y <= ActiveBuffer->ViewSize.Y)
149  {
150  ActiveBuffer->OldViewSize = ConsoleInfo->WindowSize;
151  }
152  }
153  else
154  {
155  /* Resize the view if its size is bigger than the specified size */
156  if (ConsoleInfo->WindowSize.X <= ActiveBuffer->ViewSize.X ||
157  ConsoleInfo->WindowSize.Y <= ActiveBuffer->ViewSize.Y)
158  {
159  ActiveBuffer->ViewSize = ConsoleInfo->WindowSize;
160  // SizeChanged = TRUE;
161  }
162  }
163  }
164 }
#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
#define IsCJKCodePage(CodePage)
Definition: font.h:23
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
#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:385
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:1479
NTSTATUS ConioResizeBuffer(PCONSOLE Console, PTEXTMODE_SCREEN_BUFFER ScreenBuffer, COORD Size)
Definition: text.c:259
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().