Replace some macros with constexpr (#3362)

This commit is contained in:
Chester Liu 2019-11-02 01:33:09 +08:00 committed by Michael Niksa
parent 8c8672c87a
commit 86e0ea73e2
10 changed files with 11 additions and 13 deletions

View file

@ -19,14 +19,14 @@ Revision History:
#include "../inc/conattrs.hpp"
// the following values are used to create the textmode cursor.
#define CURSOR_SMALL_SIZE 25 // large enough to be one pixel on a six pixel font
class TextBuffer;
class Cursor final
{
public:
static const unsigned int s_InvertCursorColor = INVALID_COLOR;
// the following values are used to create the textmode cursor.
static constexpr unsigned int CURSOR_SMALL_SIZE = 25; // large enough to be one pixel on a six pixel font
Cursor(const ULONG ulSize, TextBuffer& parentBuffer) noexcept;

View file

@ -29,6 +29,8 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
// Used by WriteCharsLegacy.
#define IS_GLYPH_CHAR(wch) (((wch) < L' ') || ((wch) == 0x007F))
constexpr unsigned int LOCAL_BUFFER_SIZE = 100;
// Routine Description:
// - This routine updates the cursor position. Its input is the non-special
// cased new location of the cursor. For example, if the cursor were being

View file

@ -40,8 +40,6 @@ Return Value:
const BOOL fKeepCursorVisible,
_Inout_opt_ PSHORT psScrollY);
#define LOCAL_BUFFER_SIZE 100
/*++
Routine Description:
This routine writes a string to the screen, processing any embedded

View file

@ -412,7 +412,7 @@ void SetCurrentCommandLine(COOKED_READ_DATA& cookedReadData, _In_ SHORT Index) /
{
if (cookedReadData.HasHistory() &&
cookedReadData.History().GetNumberOfCommands() &&
cookedReadData.ScreenInfo().GetBufferSize().Width() >= MINIMUM_COMMAND_PROMPT_SIZE + 2)
cookedReadData.ScreenInfo().GetBufferSize().Width() >= Popup::MINIMUM_COMMAND_PROMPT_SIZE + 2)
{
try
{

View file

@ -1223,7 +1223,7 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
WindowSize,
siExisting.GetAttributes(),
siExisting.GetAttributes(),
CURSOR_SMALL_SIZE,
Cursor::CURSOR_SMALL_SIZE,
&ScreenInfo);
if (!NT_SUCCESS(Status))

View file

@ -24,13 +24,13 @@ Revision History:
#include "screenInfo.hpp"
#include "readDataCooked.hpp"
#define MINIMUM_COMMAND_PROMPT_SIZE 5
class CommandHistory;
class Popup
{
public:
static constexpr unsigned int MINIMUM_COMMAND_PROMPT_SIZE = 5;
using UserInputFunction = std::function<NTSTATUS(COOKED_READ_DATA&, bool&, DWORD&, wchar_t&)>;
Popup(SCREEN_INFORMATION& screenInfo, const COORD proposedSize);

View file

@ -2032,7 +2032,7 @@ const SCREEN_INFORMATION& SCREEN_INFORMATION::GetMainBuffer() const
WindowSize,
GetAttributes(),
*GetPopupAttributes(),
CURSOR_SMALL_SIZE,
Cursor::CURSOR_SMALL_SIZE,
ppsiNewScreenBuffer);
if (NT_SUCCESS(Status))
{

View file

@ -29,7 +29,7 @@ Settings::Settings() :
_uFontFamily(0),
_uFontWeight(0),
// FaceName initialized below
_uCursorSize(CURSOR_SMALL_SIZE),
_uCursorSize(Cursor::CURSOR_SMALL_SIZE),
_bFullScreen(false),
_bQuickEdit(true),
_bInsertMode(true),

View file

@ -21,7 +21,7 @@ Revision History:
#include "../buffer/out/TextAttribute.hpp"
// To prevent invisible windows, set a lower threshold on window alpha channel.
#define MIN_WINDOW_OPACITY 0x4D // 0x4D is approximately 30% visible/opaque (70% transparent). Valid range is 0x00-0xff.
constexpr unsigned short MIN_WINDOW_OPACITY = 0x4D; // 0x4D is approximately 30% visible/opaque (70% transparent). Valid range is 0x00-0xff.
#include "ConsoleArguments.hpp"
#include "../inc/conattrs.hpp"

View file

@ -21,8 +21,6 @@ Author(s):
#include "terminalOutput.hpp"
#include <math.h>
#define XTERM_COLOR_TABLE_SIZE (256)
namespace Microsoft::Console::VirtualTerminal
{
class AdaptDispatch : public ITermDispatch