ReactOS  0.4.15-dev-492-ga1108f6
settings.c File Reference
#include "consrv.h"
#include "history.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 PCONSRV_CONSOLE Console, IN PCONSOLE_STATE_INFO ConsoleInfo)
 

Variables

const COLORREF s_Colors [16]
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 16 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 497 of file text.c.

501 {
502  USHORT X, Y;
503  PCHAR_INFO Ptr;
504 
505  COORD TopLeft = {0};
506  ULONG NumCodesToWrite;
507  USHORT OldScreenAttrib, OldPopupAttrib;
508 
509  if (Console == NULL || Buffer == NULL)
510  {
512  }
513 
514  /* Validity check */
515  ASSERT(Console == Buffer->Header.Console);
516 
517  /* Sanitize the new attributes */
518  NewScreenAttrib &= ~COMMON_LVB_SBCSDBCS;
519  NewPopupAttrib &= ~COMMON_LVB_SBCSDBCS;
520 
521  NumCodesToWrite = Buffer->ScreenBufferSize.X * Buffer->ScreenBufferSize.Y;
522  OldScreenAttrib = Buffer->ScreenDefaultAttrib;
523  OldPopupAttrib = Buffer->PopupDefaultAttrib;
524 
525  for (Y = 0; Y < Buffer->ScreenBufferSize.Y; ++Y)
526  {
528  for (X = 0; X < Buffer->ScreenBufferSize.X; ++X)
529  {
530  /*
531  * Change the current colors only if they are the old ones.
532  */
533 
534  /* Foreground color */
535  if ((Ptr->Attributes & 0x0F) == (OldScreenAttrib & 0x0F))
536  Ptr->Attributes = (Ptr->Attributes & 0xFFF0) | (NewScreenAttrib & 0x0F);
537  if ((Ptr->Attributes & 0x0F) == (OldPopupAttrib & 0x0F))
538  Ptr->Attributes = (Ptr->Attributes & 0xFFF0) | (NewPopupAttrib & 0x0F);
539 
540  /* Background color */
541  if ((Ptr->Attributes & 0xF0) == (OldScreenAttrib & 0xF0))
542  Ptr->Attributes = (Ptr->Attributes & 0xFF0F) | (NewScreenAttrib & 0xF0);
543  if ((Ptr->Attributes & 0xF0) == (OldPopupAttrib & 0xF0))
544  Ptr->Attributes = (Ptr->Attributes & 0xFF0F) | (NewPopupAttrib & 0xF0);
545 
546  ++Ptr;
547  }
548  }
549 
550  /* Save foreground and background attributes for both screen and popup */
551  Buffer->ScreenDefaultAttrib = NewScreenAttrib;
552  Buffer->PopupDefaultAttrib = NewPopupAttrib;
553 
554  /* Refresh the display if needed */
555  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
556  {
558  ConioComputeUpdateRect(Buffer, &UpdateRect, &TopLeft, NumCodesToWrite);
560  }
561 
562  return STATUS_SUCCESS;
563 }
#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:143
_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:165
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:3014
#define X(b, s)

Referenced by ConSrvApplyUserSettings().

◆ ConSrvApplyUserSettings()

VOID ConSrvApplyUserSettings ( IN PCONSRV_CONSOLE  Console,
IN PCONSOLE_STATE_INFO  ConsoleInfo 
)

Console->InputBufferSize = 0;

Definition at line 36 of file settings.c.

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;
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  Console->InputCodePage = Console->OutputCodePage = ConsoleInfo->CodePage;
68  // ConDrvSetConsoleCP(Console, ConsoleInfo->CodePage, TRUE); // Output
69  // ConDrvSetConsoleCP(Console, ConsoleInfo->CodePage, FALSE); // Input
70 
71  Console->IsCJK = IsCJKCodePage(Console->OutputCodePage);
72  }
73 
74  // FIXME: Check ConsoleInfo->WindowSize with respect to
75  // TermGetLargestConsoleWindowSize(...).
76 
77  if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
78  {
79  /* Resize its active screen-buffer */
81  COORD BufSize = ConsoleInfo->ScreenBufferSize;
82 
83  if (Console->FixedSize)
84  {
85  /*
86  * The console is in fixed-size mode, so we cannot resize anything
87  * at the moment. However, keep those settings somewhere so that
88  * we can try to set them up when we will be allowed to do so.
89  */
90  if (ConsoleInfo->WindowSize.X != ActiveBuffer->OldViewSize.X ||
91  ConsoleInfo->WindowSize.Y != ActiveBuffer->OldViewSize.Y)
92  {
93  ActiveBuffer->OldViewSize = ConsoleInfo->WindowSize;
94  }
95 
96  /* The buffer size is not allowed to be smaller than the view size */
97  if (BufSize.X >= ActiveBuffer->OldViewSize.X && BufSize.Y >= ActiveBuffer->OldViewSize.Y)
98  {
99  if (BufSize.X != ActiveBuffer->OldScreenBufferSize.X ||
100  BufSize.Y != ActiveBuffer->OldScreenBufferSize.Y)
101  {
102  /*
103  * The console is in fixed-size mode, so we cannot resize anything
104  * at the moment. However, keep those settings somewhere so that
105  * we can try to set them up when we will be allowed to do so.
106  */
107  ActiveBuffer->OldScreenBufferSize = BufSize;
108  }
109  }
110  }
111  else
112  {
113  BOOL SizeChanged = FALSE;
114 
115  /* Resize the console */
116  if (ConsoleInfo->WindowSize.X != ActiveBuffer->ViewSize.X ||
117  ConsoleInfo->WindowSize.Y != ActiveBuffer->ViewSize.Y)
118  {
119  ActiveBuffer->ViewSize = ConsoleInfo->WindowSize;
120  SizeChanged = TRUE;
121  }
122 
123  /* Resize the screen-buffer */
124  if (BufSize.X != ActiveBuffer->ScreenBufferSize.X ||
125  BufSize.Y != ActiveBuffer->ScreenBufferSize.Y)
126  {
128  SizeChanged = TRUE;
129  }
130 
131  if (SizeChanged) TermResizeTerminal(Console);
132  }
133 
134  /* Apply foreground and background colors for both screen and popup */
136  Buffer,
137  ConsoleInfo->ScreenAttributes,
138  ConsoleInfo->PopupAttributes);
139  }
140  else // if (GetType(ActiveBuffer) == GRAPHICS_BUFFER)
141  {
142  /*
143  * In any case we do NOT modify the size of the graphics screen-buffer.
144  * We just allow resizing the view only if the new size is smaller
145  * than the older one.
146  */
147  if (Console->FixedSize)
148  {
149  /*
150  * The console is in fixed-size mode, so we cannot resize anything
151  * at the moment. However, keep those settings somewhere so that
152  * we can try to set them up when we will be allowed to do so.
153  */
154  if (ConsoleInfo->WindowSize.X <= ActiveBuffer->ViewSize.X ||
155  ConsoleInfo->WindowSize.Y <= ActiveBuffer->ViewSize.Y)
156  {
157  ActiveBuffer->OldViewSize = ConsoleInfo->WindowSize;
158  }
159  }
160  else
161  {
162  /* Resize the view if its size is bigger than the specified size */
163  if (ConsoleInfo->WindowSize.X <= ActiveBuffer->ViewSize.X ||
164  ConsoleInfo->WindowSize.Y <= ActiveBuffer->ViewSize.Y)
165  {
166  ActiveBuffer->ViewSize = ConsoleInfo->WindowSize;
167  // SizeChanged = TRUE;
168  }
169  }
170  }
171 }
#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
COORD OldScreenBufferSize
Definition: conio.h:65
#define IsCJKCodePage(CodePage)
Definition: font.h:23
COORD ScreenBufferSize
Definition: conio.h:62
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: bufpool.h:45
#define BufSize
Definition: FsRtlTunnel.c:28
ULONG X
Definition: bl.h:1340
VOID HistoryReshapeAllBuffers(IN PCONSRV_CONSOLE Console, IN ULONG HistoryBufferSize, IN ULONG MaxNumberOfHistoryBuffers, IN BOOLEAN HistoryNoDup)
Definition: history.c:371
#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:497
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:359
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:75
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]

Definition at line 98 of file conwnd.c.

Referenced by ConSrvApplyUserSettings().