Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce til::rle - a run length encoded vector #10099

Merged
4 commits merged into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/spelling/allow/allow.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Apc
apc
clickable
copyable
dalet
Dcs
dcs
Expand Down
565 changes: 30 additions & 535 deletions src/buffer/out/AttrRow.cpp

Large diffs are not rendered by default.

43 changes: 13 additions & 30 deletions src/buffer/out/AttrRow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ Revision History:

#pragma once

#include "TextAttributeRun.hpp"
#include "AttrRowIterator.hpp"
#include "til/rle.h"
#include "TextAttribute.hpp"

class ATTR_ROW final
{
using rle_vector = til::small_rle<TextAttribute, uint16_t, 1>;

public:
using const_iterator = typename AttrRowIterator;
using const_iterator = rle_vector::const_iterator;

ATTR_ROW(const UINT cchRowWidth, const TextAttribute attr)
noexcept;
ATTR_ROW(uint16_t width, TextAttribute attr);

~ATTR_ROW() = default;

Expand All @@ -39,28 +40,13 @@ class ATTR_ROW final
noexcept = default;
ATTR_ROW& operator=(ATTR_ROW&&) noexcept = default;

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;

std::vector<uint16_t> GetHyperlinks();

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);
TextAttribute GetAttrByColumn(uint16_t column) const;
std::vector<uint16_t> GetHyperlinks() const;

static std::vector<TextAttributeRun> PackAttrs(const std::vector<TextAttribute>& attrs);
bool SetAttrToEnd(uint16_t beginIndex, TextAttribute attr);
void ReplaceAttrs(const TextAttribute& toBeReplacedAttr, const TextAttribute& replaceWith);
void Resize(uint16_t newWidth);
void Replace(uint16_t beginIndex, uint16_t endIndex, const TextAttribute& newAttr);

const_iterator begin() const noexcept;
const_iterator end() const noexcept;
Expand All @@ -69,17 +55,14 @@ class ATTR_ROW final
const_iterator cend() const noexcept;

friend bool operator==(const ATTR_ROW& a, const ATTR_ROW& b) noexcept;
friend class AttrRowIterator;
friend class ROW;

private:
void Reset(const TextAttribute attr);

boost::container::small_vector<TextAttributeRun, 1> _list;
size_t _cchRowWidth;
rle_vector _data;

#ifdef UNIT_TESTING
friend class AttrRowTests;
friend class CommonState;
#endif
};
136 changes: 0 additions & 136 deletions src/buffer/out/AttrRowIterator.cpp

This file was deleted.

80 changes: 0 additions & 80 deletions src/buffer/out/AttrRowIterator.hpp

This file was deleted.

Loading