diff --git a/README.asciidoc b/README.asciidoc index 453926eb..78f1b267 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -824,9 +824,9 @@ Options are typed, their type can be if an element needs to contain a colon, it can be escaped with a backslash. * `range-faces`: a `:` separated list of a pairs of a buffer range - (`.,.`) and a face - (separated by `|`), except for the first element which is just the - timestamp of the buffer. + (`.,.` or + `.+`) and a face (separated by `|`), + except for the first element which is just the timestamp of the buffer. * `completions`: a `:` separated list of `||` candidates, except for the first element which follows the `.[+]@` format to define where the diff --git a/doc/manpages/options.asciidoc b/doc/manpages/options.asciidoc index 24e4ee4f..93427bbb 100644 --- a/doc/manpages/options.asciidoc +++ b/doc/manpages/options.asciidoc @@ -24,9 +24,9 @@ Types with a backslash *range-faces*:: a `:` separated list of a pairs of a buffer range - (`.,.`) and a face - (separated by `|`), except for the first element which is just the - timestamp of the buffer. + (`.,.` or + `.+`) and a face (separated by `|`), + except for the first element which is just the timestamp of the buffer. *completions*:: a `:` separated list of `||` candidates, except for the first element which follows the diff --git a/rc/base/spell.kak b/rc/base/spell.kak index b54d111a..4d496f77 100644 --- a/rc/base/spell.kak +++ b/rc/base/spell.kak @@ -34,13 +34,12 @@ Formats of language supported: case "$line" in [\#\&]*) if expr "$line" : '^&' >/dev/null; then - begin=$(printf %s\\n "$line" | cut -d ' ' -f 4 | sed 's/:$//') + pos=$(printf %s\\n "$line" | cut -d ' ' -f 4 | sed 's/:$//') else - begin=$(printf %s\\n "$line" | cut -d ' ' -f 3) + pos=$(printf %s\\n "$line" | cut -d ' ' -f 3) fi word=$(printf %s\\n "$line" | cut -d ' ' -f 2) - end=$((begin + ${#word})) - regions="$regions:$line_num.$begin,$line_num.$end|Error" + regions="$regions:$line_num.$pos+${#word}|Error" ;; '') line_num=$((line_num + 1));; \*) ;; diff --git a/src/display_buffer.cc b/src/display_buffer.cc index fdf3b1c4..4ac6a2fb 100644 --- a/src/display_buffer.cc +++ b/src/display_buffer.cc @@ -14,29 +14,33 @@ String option_to_string(BufferRange range) { return format("{}.{},{}.{}", range.begin.line+1, range.begin.column+1, - range.end.line+1, range.end.column+1); + range.end.line, range.end.column); } 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()}, '.'); + auto sep = find_if(str, [](char c){ return c == ',' or c == '+'; }); + auto dot_beg = find(StringView{str.begin(), sep}, '.'); + auto dot_end = find(StringView{sep, str.end()}, '.'); - if (comma == str.end() or dot_begin == comma or dot_end == str.end()) - throw runtime_error(format("'{}' does not follow .,. format", str)); + if (sep == str.end() or dot_beg == sep or + (*sep == ',' and dot_end == str.end())) + throw runtime_error(format("'{}' does not follow .,. or .+ format", str)); - BufferCoord begin{str_to_int({str.begin(), dot_begin}) - 1, - str_to_int({dot_begin+1, comma}) - 1}; + const BufferCoord beg{str_to_int({str.begin(), dot_beg}) - 1, + str_to_int({dot_beg+1, sep}) - 1}; - BufferCoord end{str_to_int({comma+1, dot_end}) - 1, - str_to_int({dot_end+1, str.end()}) - 1}; + const bool len = (*sep == '+'); + const BufferCoord end{len ? beg.line : str_to_int({sep+1, dot_end}) - 1, + len ? beg.column + str_to_int({sep+1, str.end()}) + : str_to_int({dot_end+1, str.end()}) }; - opt.begin = begin; - opt.end = end; + if (beg.line < 0 or beg.column < 0 or end.line < 0 or end.column < 0) + throw runtime_error("coordinates elements should be >= 1"); + + opt = { beg, end }; } - StringView DisplayAtom::content() const { switch (m_type)