summaryrefslogtreecommitdiff
path: root/src/display_buffer.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-12-17 04:07:09 +0000
committerMaxime Coste <frrrwww@gmail.com>2015-12-17 04:07:49 +0000
commit8dcffd8f5a4a29d89716c114214d24803fe93d9f (patch)
tree68d43656cc3f7f9ebe001f281c1ac528f0f87ef3 /src/display_buffer.cc
parent925d41f59672f2e4fad1355e880193f75dcfd952 (diff)
Initial, WIP spelling implementation
Add a ranges highlighter that takes a timestamped list of ranges and associated face. Add a spell.kak file that uses aspell pipe interface to fill a range-faces option.
Diffstat (limited to 'src/display_buffer.cc')
-rw-r--r--src/display_buffer.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/display_buffer.cc b/src/display_buffer.cc
index 61078657..c112679d 100644
--- a/src/display_buffer.cc
+++ b/src/display_buffer.cc
@@ -9,6 +9,33 @@
namespace Kakoune
{
+String option_to_string(BufferRange range)
+{
+ return format("{}.{},{}.{}",
+ range.begin.line+1, range.begin.column+1,
+ range.end.line+1, range.end.column+1);
+}
+
+void option_from_string(StringView str, BufferRange& opt)
+{
+ auto comma = find(str, ',');
+ auto dot_begin = find(StringView{str.begin(), comma}, '.');
+ auto dot_end = find(StringView{comma, str.end()}, '.');
+
+ if (comma == str.end() or dot_begin == comma or dot_end == str.end())
+ throw runtime_error(format("'{}' does not follow <line>.<column>,<line>.<column> format", str));
+
+ ByteCoord begin{str_to_int({str.begin(), dot_begin}) - 1,
+ str_to_int({dot_begin+1, comma}) - 1};
+
+ ByteCoord end{str_to_int({comma+1, dot_end}) - 1,
+ str_to_int({dot_end+1, str.end()}) - 1};
+
+ opt.begin = begin;
+ opt.end = end;
+}
+
+
StringView DisplayAtom::content() const
{
switch (m_type)