ReactOS  0.4.13-dev-563-g0561610
settings.c File Reference
#include "consrv.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 14 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 383 of file text.c.

387 {
388  ULONG X, Y, Length;
389  PCHAR_INFO Ptr;
390 
391  COORD TopLeft = {0};
392  ULONG NumCodesToWrite;
393  USHORT OldScreenAttrib, OldPopupAttrib;
394 
395  if (Console == NULL || Buffer == NULL)
396  {
398  }
399 
400  /* Validity check */
401  ASSERT(Console == Buffer->Header.Console);
402 
403  NumCodesToWrite = Buffer->ScreenBufferSize.X * Buffer->ScreenBufferSize.Y;
404  OldScreenAttrib = Buffer->ScreenDefaultAttrib;
405  OldPopupAttrib = Buffer->PopupDefaultAttrib;
406 
407  X = TopLeft.X;
408  Y = (TopLeft.Y + Buffer->VirtualY) % Buffer->ScreenBufferSize.Y;
409  Length = NumCodesToWrite;
410 
411  // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work
412  // Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X]; // May work
413 
414  while (Length--)
415  {
416  // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work either
417  Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X];
418 
419  /*
420  * Change the current colors only if they are the old ones.
421  */
422 
423  /* Foreground color */
424  if ((Ptr->Attributes & 0x0F) == (OldScreenAttrib & 0x0F))
425  Ptr->Attributes = (Ptr->Attributes & 0xFFF0) | (NewScreenAttrib & 0x0F);
426  if ((Ptr->Attributes & 0x0F) == (OldPopupAttrib & 0x0F))
427  Ptr->Attributes = (Ptr->Attributes & 0xFFF0) | (NewPopupAttrib & 0x0F);
428 
429  /* Background color */
430  if ((Ptr->Attributes & 0xF0) == (OldScreenAttrib & 0xF0))
431  Ptr->Attributes = (Ptr->Attributes & 0xFF0F) | (NewScreenAttrib & 0xF0);
432  if ((Ptr->Attributes & 0xF0) == (OldPopupAttrib & 0xF0))
433  Ptr->Attributes = (Ptr->Attributes & 0xFF0F) | (NewPopupAttrib & 0xF0);
434 
435  // ++Ptr;
436 
437  if (++X == Buffer->ScreenBufferSize.X)
438  {
439  X = 0;
440 
441  if (++Y == Buffer->ScreenBufferSize.Y)
442  {
443  Y = 0;
444  }
445  }
446  }
447 
448  /* Save foreground and background colors for both screen and popup */
449  Buffer->ScreenDefaultAttrib = (NewScreenAttrib & 0x00FF);
450  Buffer->PopupDefaultAttrib = (NewPopupAttrib & 0x00FF);
451 
452  /* Refresh the display if needed */
453  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
454  {
456  ConioComputeUpdateRect(Buffer, &UpdateRect, &TopLeft, NumCodesToWrite);
458  }
459 
460  return STATUS_SUCCESS;
461 }
#define Y(I)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#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:160
while(1)
Definition: macro.lex.yy.c:740
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
ULONG X
Definition: bl.h:1340
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
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:2777
ULONG Y
Definition: bl.h:1341
#define X(b, s)

Referenced by ConSrvApplyUserSettings().

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

Variable Documentation

◆ s_Colors

const COLORREF s_Colors[16]