ReactOS  0.4.14-dev-1112-g2b067d6
settings.c File Reference
#include "consrv.h"
#include "../concfg/font.h"
#include <debug.h>
Include dependency graph for settings.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI ConDrvChangeScreenBufferAttributes (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN USHORT NewScreenAttrib, IN USHORT NewPopupAttrib)
 
VOID ConSrvApplyUserSettings (IN PCONSOLE Console, IN PCONSOLE_STATE_INFO ConsoleInfo)
 

Variables

const COLORREF s_Colors [16]
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file settings.c.

Function Documentation

◆ ConDrvChangeScreenBufferAttributes()

NTSTATUS NTAPI ConDrvChangeScreenBufferAttributes ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN USHORT  NewScreenAttrib,
IN USHORT  NewPopupAttrib 
)

Definition at line 510 of file text.c.

514 {
515  USHORT X, Y;
516  PCHAR_INFO Ptr;
517 
518  COORD TopLeft = {0};
519  ULONG NumCodesToWrite;
520  USHORT OldScreenAttrib, OldPopupAttrib;
521 
522  if (Console == NULL || Buffer == NULL)
523  {
525  }
526 
527  /* Validity check */
528  ASSERT(Console == Buffer->Header.Console);
529 
530  /* Sanitize the new attributes */
531  NewScreenAttrib &= ~COMMON_LVB_SBCSDBCS;
532  NewPopupAttrib &= ~COMMON_LVB_SBCSDBCS;
533 
534  NumCodesToWrite = Buffer->ScreenBufferSize.X * Buffer->ScreenBufferSize.Y;
535  OldScreenAttrib = Buffer->ScreenDefaultAttrib;
536  OldPopupAttrib = Buffer->PopupDefaultAttrib;
537 
538  for (Y = 0; Y < Buffer->ScreenBufferSize.Y; ++Y)
539  {
541  for (X = 0; X < Buffer->ScreenBufferSize.X; ++X)
542  {
543  /*
544  * Change the current colors only if they are the old ones.
545  */
546 
547  /* Foreground color */
548  if ((Ptr->Attributes & 0x0F) == (OldScreenAttrib & 0x0F))
549  Ptr->Attributes = (Ptr->Attributes & 0xFFF0) | (NewScreenAttrib & 0x0F);
550  if ((Ptr->Attributes & 0x0F) == (OldPopupAttrib & 0x0F))
551  Ptr->Attributes = (Ptr->Attributes & 0xFFF0) | (NewPopupAttrib & 0x0F);
552 
553  /* Background color */
554  if ((Ptr->Attributes & 0xF0) == (OldScreenAttrib & 0xF0))
555  Ptr->Attributes = (Ptr->Attributes & 0xFF0F) | (NewScreenAttrib & 0xF0);
556  if ((Ptr->Attributes & 0xF0) == (OldPopupAttrib & 0xF0))
557  Ptr->Attributes = (Ptr->Attributes & 0xFF0F) | (NewPopupAttrib & 0xF0);
558 
559  ++Ptr;
560  }
561  }
562 
563  /* Save foreground and background attributes for both screen and popup */
564  Buffer->ScreenDefaultAttrib = NewScreenAttrib;
565  Buffer->PopupDefaultAttrib = NewPopupAttrib;
566 
567  /* Refresh the display if needed */
568  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
569  {
571  ConioComputeUpdateRect(Buffer, &UpdateRect, &TopLeft, NumCodesToWrite);
573  }
574 
575  return STATUS_SUCCESS;
576 }
#define Y(I)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:156
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define COMMON_LVB_SBCSDBCS
Definition: wincon.h:56
#define TermDrawRegion(Console, Region)
Definition: term.h:22
static VOID ConioComputeUpdateRect(IN PTEXTMODE_SCREEN_BUFFER Buff, IN OUT PSMALL_RECT UpdateRect, IN PCOORD Start, IN UINT Length)
Definition: text.c:178
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: bl.h:1338
unsigned short USHORT
Definition: pedump.c:61
CConsole Console
unsigned int ULONG
Definition: retypes.h:1
static int UpdateRect(TreeListData *pData, unsigned uItem, unsigned uSub)
Definition: treelist.c:1529
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define X(b, s)

Referenced by ConSrvApplyUserSettings().

◆ 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:510
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:372
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().

Variable Documentation

◆ s_Colors

const COLORREF s_Colors[16]