diff options
| author | Maxime Coste <mawww@kakoune.org> | 2016-12-02 13:59:34 +0000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2016-12-02 13:59:34 +0000 |
| commit | 5ff8245cc84a15d6a48bd2e19e4c70d4f8ae3f77 (patch) | |
| tree | d1bfc2c50b28ef6b6c625e7648409d7c14985cf2 /src | |
| parent | d88d0bac42aa447c5635556e4a7c48bce625489b (diff) | |
Display non breaking spaces with ⍽ in show_whitespaces hihglighter
Fixes #167
Diffstat (limited to 'src')
| -rw-r--r-- | src/highlighters.cc | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/highlighters.cc b/src/highlighters.cc index 3cf93b02..ece03ca5 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -695,26 +695,29 @@ void show_whitespaces(const Context& context, HighlightFlags flags, DisplayBuffe auto begin = buffer.iterator_at(atom_it->begin()); auto end = buffer.iterator_at(atom_it->end()); - for (BufferIterator it = begin; it != end; ++it) + for (BufferIterator it = begin; it != end; ) { - auto c = *it; - if (c == '\t' or c == ' ' or c == '\n') + auto coord = it.coord(); + Codepoint cp = utf8::read_codepoint<utf8::InvalidPolicy::Pass>(it, end); + if (cp == '\t' or cp == ' ' or cp == '\n' or cp == 0xA0) { - if (it != begin) - atom_it = ++line.split(atom_it, it.coord()); - if (it+1 != end) - atom_it = line.split(atom_it, (it+1).coord()); + if (coord != begin.coord()) + atom_it = ++line.split(atom_it, coord); + if (it != end) + atom_it = line.split(atom_it, it.coord()); - if (c == '\t') + if (cp == '\t') { int column = (int)get_column(buffer, tabstop, it.coord()); int count = tabstop - (column % tabstop); atom_it->replace("→" + String(' ', CharCount{count-1})); } - else if (c == ' ') + else if (cp == ' ') atom_it->replace("·"); - else if (c == '\n') + else if (cp == '\n') atom_it->replace("¬"); + else if (cp == 0xA0) + atom_it->replace("⍽"); atom_it->face = whitespaceface; break; } |
