diff options
author | Neil <nyamatongwe@gmail.com> | 2025-02-01 09:07:57 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2025-02-01 09:07:57 +1100 |
commit | bd03d24f8bd44813db8ed1c73c5a46400d94a7cf (patch) | |
tree | 74c7984b59a193a54db66bd94d15c595a512ed0b /src/Selection.h | |
parent | 97691047e0c13b92639d340ee9f34dde67941e18 (diff) | |
download | scintilla-mirror-bd03d24f8bd44813db8ed1c73c5a46400d94a7cf.tar.gz |
Implement serialization of Selection to and from strings.
Requires std::from_chars to be available.
Diffstat (limited to 'src/Selection.h')
-rw-r--r-- | src/Selection.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Selection.h b/src/Selection.h index 7f3fd937b..68e7a4e54 100644 --- a/src/Selection.h +++ b/src/Selection.h @@ -20,6 +20,7 @@ public: if (virtualSpace < 0) virtualSpace = 0; } + explicit SelectionPosition(std::string_view sv); void Reset() noexcept { position = 0; virtualSpace = 0; @@ -63,6 +64,7 @@ public: bool IsValid() const noexcept { return position >= 0; } + std::string ToString() const; }; // Ordered range to make drawing simpler @@ -112,6 +114,7 @@ struct SelectionRange { } constexpr SelectionRange(Sci::Position caret_, Sci::Position anchor_) noexcept : caret(caret_), anchor(anchor_) { } + explicit SelectionRange(std::string_view sv); bool Empty() const noexcept { return anchor == caret; } @@ -147,6 +150,7 @@ struct SelectionRange { bool Trim(SelectionRange range) noexcept; // If range is all virtual collapse to start of virtual space void MinimizeVirtualSpace() noexcept; + std::string ToString() const; }; // Deliberately an enum rather than an enum class to allow treating as bool @@ -165,6 +169,8 @@ public: SelTypes selType; Selection(); // Allocates so may throw. + explicit Selection(std::string_view sv); + bool IsRectangular() const noexcept; Sci::Position MainCaret() const noexcept; Sci::Position MainAnchor() const noexcept; @@ -210,6 +216,7 @@ public: return ranges; } void SetRanges(const Ranges &rangesToSet); + std::string ToString() const; }; } |