a8e4bedae3
## Summary of the Pull Request Introduces `til::rle`, a vector-like container which stores elements of type T in a run length encoded format. This allows efficient compaction of repeated elements within the vector. ## References * #8000 - Supports buffer rewrite work. A re-use of `til::rle` will be useful as a column counter as we pursue NxM storage and presentation. * #3075 - The new iterators allow skipping forward by multiple units, which wasn't possible under `TextBuffer-/OutputCellIterator`. Additionally it also allows a bulk insertions. * #8787 and #410 - High probability this should be `pmr`-ified like `bitmap` for things like `chafa` and `cacafire` which are changing the run length frequently. ## PR Checklist * [x] Closes #8741 * [x] I work here. * [x] Tests added. * [x] Tests passed. ## Validation Steps Performed * [x] Ran `cacafire` in `OpenConsole.exe` and it looked beautiful * [x] Ran new suite of `RunLengthEncodingTests.cpp` Co-authored-by: Michael Niksa <miniksa@microsoft.com>
70 lines
2 KiB
C++
70 lines
2 KiB
C++
/*++
|
|
Copyright (c) Microsoft Corporation
|
|
Licensed under the MIT license.
|
|
|
|
Module Name:
|
|
- textBufferCellIterator.hpp
|
|
|
|
Abstract:
|
|
- This module abstracts walking through text on the screen
|
|
- It is currently intended for read-only operations
|
|
|
|
Author(s):
|
|
- Michael Niksa (MiNiksa) 29-Jun-2018
|
|
--*/
|
|
|
|
#pragma once
|
|
|
|
#include "CharRow.hpp"
|
|
#include "AttrRow.hpp"
|
|
#include "OutputCellView.hpp"
|
|
#include "../../types/inc/viewport.hpp"
|
|
|
|
class TextBuffer;
|
|
|
|
class TextBufferCellIterator
|
|
{
|
|
public:
|
|
TextBufferCellIterator(const TextBuffer& buffer, COORD pos);
|
|
TextBufferCellIterator(const TextBuffer& buffer, COORD pos, const Microsoft::Console::Types::Viewport limits);
|
|
|
|
operator bool() const noexcept;
|
|
|
|
bool operator==(const TextBufferCellIterator& it) const noexcept;
|
|
bool operator!=(const TextBufferCellIterator& it) const noexcept;
|
|
|
|
TextBufferCellIterator& operator+=(const ptrdiff_t& movement);
|
|
TextBufferCellIterator& operator-=(const ptrdiff_t& movement);
|
|
TextBufferCellIterator& operator++();
|
|
TextBufferCellIterator& operator--();
|
|
TextBufferCellIterator operator++(int);
|
|
TextBufferCellIterator operator--(int);
|
|
TextBufferCellIterator operator+(const ptrdiff_t& movement);
|
|
TextBufferCellIterator operator-(const ptrdiff_t& movement);
|
|
|
|
ptrdiff_t operator-(const TextBufferCellIterator& it);
|
|
|
|
const OutputCellView& operator*() const noexcept;
|
|
const OutputCellView* operator->() const noexcept;
|
|
|
|
protected:
|
|
void _SetPos(const COORD newPos);
|
|
void _GenerateView();
|
|
static const ROW* s_GetRow(const TextBuffer& buffer, const COORD pos);
|
|
|
|
OutputCellView _view;
|
|
|
|
const ROW* _pRow;
|
|
ATTR_ROW::const_iterator _attrIter;
|
|
const TextBuffer& _buffer;
|
|
const Microsoft::Console::Types::Viewport _bounds;
|
|
bool _exceeded;
|
|
COORD _pos;
|
|
|
|
#if UNIT_TESTING
|
|
friend class TextBufferIteratorTests;
|
|
friend class TextBufferTests;
|
|
friend class ApiRoutinesTests;
|
|
#endif
|
|
};
|