diff options
| author | Maxime Coste <mawww@kakoune.org> | 2021-09-29 21:28:30 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2021-09-30 20:12:58 +1000 |
| commit | 5f8753caec8b9aba8e9793dab972d80a2f222d60 (patch) | |
| tree | 4a4942df65c9ed6974455ef74eddd755c225a1d3 /src/selection.hh | |
| parent | 05fb07fbc6c3a9fcccd69b03b01bf063f524868b (diff) | |
rework selection insert/replace using a for_each method
expose that method so that various commands can take advantage of
it for performance or simplicity purposes.
Diffstat (limited to 'src/selection.hh')
| -rw-r--r-- | src/selection.hh | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/selection.hh b/src/selection.hh index 3c6d879d..5d6e7427 100644 --- a/src/selection.hh +++ b/src/selection.hh @@ -87,6 +87,12 @@ enum class InsertMode : unsigned OpenLineAbove }; +BufferCoord get_insert_pos(const Buffer& buffer, const Selection& sel, InsertMode mode); + +void replace(Buffer& buffer, Selection& sel, StringView content); +void insert(Buffer& buffer, Selection& sel, StringView content, InsertMode mode); + + struct SelectionList { static constexpr MemoryDomain Domain = MemoryDomain::Selections; @@ -145,9 +151,12 @@ struct SelectionList size_t timestamp() const { return m_timestamp; } void force_timestamp(size_t timestamp) { m_timestamp = timestamp; } + using ApplyFunc = FunctionRef<void (size_t index, Selection& sel)>; + void for_each(ApplyFunc apply); + void insert(ConstArrayView<String> strings, InsertMode mode); - using ContentFunc = FunctionRef<String (size_t index, BufferCoord insert_pos)>; - void insert(ContentFunc get_content, InsertMode mode); + void replace(ConstArrayView<String> strings); + void erase(); private: |
