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.
73 lines
2.1 KiB
C++
73 lines
2.1 KiB
C++
/*++
|
|
Copyright (c) Microsoft Corporation
|
|
Licensed under the MIT license.
|
|
|
|
Module Name:
|
|
- AttrRow.hpp
|
|
|
|
Abstract:
|
|
- contains data structure for the attributes of one row of screen buffer
|
|
|
|
Author(s):
|
|
- Michael Niksa (miniksa) 10-Apr-2014
|
|
- Paul Campbell (paulcam) 10-Apr-2014
|
|
|
|
Revision History:
|
|
- From components of output.h/.c
|
|
by Therese Stowell (ThereseS) 1990-1991
|
|
- Pulled into its own file from textBuffer.hpp/cpp (AustDi, 2017)
|
|
--*/
|
|
|
|
#pragma once
|
|
|
|
#include "TextAttributeRun.hpp"
|
|
#include "AttrRowIterator.hpp"
|
|
|
|
class ATTR_ROW final
|
|
{
|
|
public:
|
|
using const_iterator = typename AttrRowIterator;
|
|
|
|
ATTR_ROW(const UINT cchRowWidth, const TextAttribute attr);
|
|
|
|
void Reset(const TextAttribute attr);
|
|
|
|
TextAttribute GetAttrByColumn(const size_t column) const;
|
|
TextAttribute GetAttrByColumn(const size_t column,
|
|
size_t* const pApplies) const;
|
|
|
|
size_t GetNumberOfRuns() const noexcept;
|
|
|
|
size_t FindAttrIndex(const size_t index,
|
|
size_t* const pApplies) const;
|
|
|
|
bool SetAttrToEnd(const UINT iStart, const TextAttribute attr);
|
|
void ReplaceAttrs(const TextAttribute& toBeReplacedAttr, const TextAttribute& replaceWith) noexcept;
|
|
|
|
void Resize(const size_t newWidth);
|
|
|
|
[[nodiscard]] HRESULT InsertAttrRuns(const gsl::span<const TextAttributeRun> newAttrs,
|
|
const size_t iStart,
|
|
const size_t iEnd,
|
|
const size_t cBufferWidth);
|
|
|
|
static std::vector<TextAttributeRun> PackAttrs(const std::vector<TextAttribute>& attrs);
|
|
|
|
const_iterator begin() const noexcept;
|
|
const_iterator end() const noexcept;
|
|
|
|
const_iterator cbegin() const noexcept;
|
|
const_iterator cend() const noexcept;
|
|
|
|
friend bool operator==(const ATTR_ROW& a, const ATTR_ROW& b) noexcept;
|
|
friend class AttrRowIterator;
|
|
|
|
private:
|
|
std::vector<TextAttributeRun> _list;
|
|
size_t _cchRowWidth;
|
|
|
|
#ifdef UNIT_TESTING
|
|
friend class AttrRowTests;
|
|
#endif
|
|
};
|