80da24ecf8
We were using std::basic_string_view as a stand-in for std::span so that
we could change over all at once when C++20 dropped with full span
support. That day's not here yet, but as of 54a7fce3e
we're using GSL 3,
whose span is C++20-compliant.
This commit replaces every instance of basic_string_view that was not
referring to an actual string with a span of the appropriate type.
I moved the `const` qualifier into span's `T` because while
`basic_string_view.at()` returns `const T&`, `span.at()` returns `T&`
(without the const). I wanted to maintain the invariant that members of
the span were immutable.
* Mechanical Changes
* `sv.at(x)` -> `gsl::at(sp, x)`
* `sv.c{begin,end}` -> `sp.{begin,end}` (span's iterators are const)
I had to replace a `std::basic_string<>` with a `std::vector<>` in
ConImeInfo, and I chose to replace a manual array walk in
ScreenInfoUiaProviderBase with a ranged-for. Please review those
specifically.
This will almost certainly cause a code size regression in Windows
because I'm blowing out all the PGO counts. Whoops.
Related: #3956, #975.
92 lines
3.1 KiB
C++
92 lines
3.1 KiB
C++
/*++
|
|
Copyright (c) Microsoft Corporation
|
|
Licensed under the MIT license.
|
|
|
|
Module Name:
|
|
- conimeinfo.h
|
|
|
|
Abstract:
|
|
- This module contains the structures for the console IME entrypoints
|
|
for overall control
|
|
|
|
Author:
|
|
- Michael Niksa (MiNiksa) 10-May-2018
|
|
|
|
Revision History:
|
|
- From pieces of convarea.cpp originally authored by KazuM
|
|
--*/
|
|
|
|
#pragma once
|
|
|
|
#include "../inc/conime.h"
|
|
#include "../buffer/out/OutputCell.hpp"
|
|
#include "../buffer/out/TextAttribute.hpp"
|
|
#include "../renderer/inc/FontInfo.hpp"
|
|
#include "../types/inc/viewport.hpp"
|
|
|
|
#include "conareainfo.h"
|
|
|
|
class SCREEN_INFORMATION;
|
|
|
|
class ConsoleImeInfo final
|
|
{
|
|
public:
|
|
// IME composition string information
|
|
// There is one "composition string" per line that must be rendered on the screen
|
|
std::vector<ConversionAreaInfo> ConvAreaCompStr;
|
|
|
|
ConsoleImeInfo();
|
|
~ConsoleImeInfo() = default;
|
|
ConsoleImeInfo(const ConsoleImeInfo&) = delete;
|
|
ConsoleImeInfo(ConsoleImeInfo&&) = delete;
|
|
ConsoleImeInfo& operator=(const ConsoleImeInfo&) & = delete;
|
|
ConsoleImeInfo& operator=(ConsoleImeInfo&&) & = delete;
|
|
|
|
void RefreshAreaAttributes();
|
|
void ClearAllAreas();
|
|
|
|
[[nodiscard]] HRESULT ResizeAllAreas(const COORD newSize);
|
|
|
|
void WriteCompMessage(const std::wstring_view text,
|
|
const gsl::span<const BYTE> attributes,
|
|
const gsl::span<const WORD> colorArray);
|
|
|
|
void WriteResultMessage(const std::wstring_view text);
|
|
|
|
void RedrawCompMessage();
|
|
|
|
void SaveCursorVisibility();
|
|
void RestoreCursorVisibility();
|
|
|
|
private:
|
|
[[nodiscard]] HRESULT _AddConversionArea();
|
|
|
|
void _ClearComposition();
|
|
|
|
void _WriteUndeterminedChars(const std::wstring_view text,
|
|
const gsl::span<const BYTE> attributes,
|
|
const gsl::span<const WORD> colorArray);
|
|
|
|
void _InsertConvertedString(const std::wstring_view text);
|
|
|
|
static TextAttribute s_RetrieveAttributeAt(const size_t pos,
|
|
const gsl::span<const BYTE> attributes,
|
|
const gsl::span<const WORD> colorArray);
|
|
|
|
static std::vector<OutputCell> s_ConvertToCells(const std::wstring_view text,
|
|
const gsl::span<const BYTE> attributes,
|
|
const gsl::span<const WORD> colorArray);
|
|
|
|
std::vector<OutputCell>::const_iterator _WriteConversionArea(const std::vector<OutputCell>::const_iterator begin,
|
|
const std::vector<OutputCell>::const_iterator end,
|
|
COORD& pos,
|
|
const Microsoft::Console::Types::Viewport view,
|
|
SCREEN_INFORMATION& screenInfo);
|
|
|
|
bool _isSavedCursorVisible;
|
|
|
|
std::wstring _text;
|
|
std::vector<BYTE> _attributes;
|
|
std::vector<WORD> _colorArray;
|
|
};
|