Remove is_blank, which is identical to is_horizontal_blank

This commit is contained in:
Maxime Coste 2015-04-15 00:34:00 +01:00
parent 63bbb6e3df
commit bf02838816
5 changed files with 18 additions and 23 deletions

View File

@ -17,10 +17,10 @@ Completions shell_complete(const Context& context, CompletionFlags flags,
{
command = (pos == 0 or prefix[pos-1] == ';' or prefix[pos-1] == '|' or
(pos > 1 and prefix[pos-1] == '&' and prefix[pos-2] == '&'));
while (pos != len and is_blank(prefix[pos]))
while (pos != len and is_horizontal_blank(prefix[pos]))
++pos;
word_start = pos;
while (pos != len and not is_blank(prefix[pos]))
while (pos != len and not is_horizontal_blank(prefix[pos]))
++pos;
word_end = pos;
}

View File

@ -266,7 +266,7 @@ void to_next_word_begin(CharCount& pos, StringView line)
while (pos != len and is_word<word_type>(line[pos]))
++pos;
}
while (pos != len and is_blank(line[pos]))
while (pos != len and is_horizontal_blank(line[pos]))
++pos;
}
@ -278,7 +278,7 @@ void to_next_word_end(CharCount& pos, StringView line)
return;
++pos;
while (pos != len and is_blank(line[pos]))
while (pos != len and is_horizontal_blank(line[pos]))
++pos;
if (word_type == Word and is_punctuation(line[pos]))
@ -301,7 +301,7 @@ void to_prev_word_begin(CharCount& pos, StringView line)
return;
--pos;
while (pos != 0_char and is_blank(line[pos]))
while (pos != 0_char and is_horizontal_blank(line[pos]))
--pos;
if (word_type == Word and is_punctuation(line[pos]))

View File

@ -259,7 +259,7 @@ Selection select_sentence(const Buffer& buffer, const Selection& selection, Obje
{
BufferIterator prev_non_blank = first-1;
skip_while_reverse(prev_non_blank, buffer.begin(),
[](char c) { return is_blank(c) or is_eol(c); });
[](char c) { return is_horizontal_blank(c) or is_eol(c); });
if (is_end_of_sentence(*prev_non_blank))
first = prev_non_blank;
}
@ -273,7 +273,7 @@ Selection select_sentence(const Buffer& buffer, const Selection& selection, Obje
{
char cur = *first;
char prev = *(first-1);
if (not is_blank(cur))
if (not is_horizontal_blank(cur))
saw_non_blank = true;
if (is_eol(prev) and is_eol(cur))
{
@ -289,7 +289,7 @@ Selection select_sentence(const Buffer& buffer, const Selection& selection, Obje
}
--first;
}
skip_while(first, buffer.end(), is_blank);
skip_while(first, buffer.end(), is_horizontal_blank);
}
if (flags & ObjectFlags::ToEnd)
{
@ -304,7 +304,7 @@ Selection select_sentence(const Buffer& buffer, const Selection& selection, Obje
if (not (flags & ObjectFlags::Inner) and last != buffer.end())
{
++last;
skip_while(last, buffer.end(), is_blank);
skip_while(last, buffer.end(), is_horizontal_blank);
--last;
}
}

View File

@ -58,7 +58,7 @@ Selection select_to_next_word(const Buffer& buffer, const Selection& selection)
else if (is_word<word_type>(*begin))
skip_while(end, buffer.end(), is_word<word_type>);
skip_while(end, buffer.end(), is_blank);
skip_while(end, buffer.end(), is_horizontal_blank);
return utf8_range(begin, end-1);
}
@ -76,7 +76,7 @@ Selection select_to_next_word_end(const Buffer& buffer, const Selection& selecti
if (begin == buffer.end())
return selection;
Utf8Iterator end = begin;
skip_while(end, buffer.end(), is_blank);
skip_while(end, buffer.end(), is_horizontal_blank);
if (word_type == Word and is_punctuation(*end))
skip_while(end, buffer.end(), is_punctuation);
@ -97,7 +97,7 @@ Selection select_to_previous_word(const Buffer& buffer, const Selection& selecti
skip_while_reverse(begin, buffer.begin(), is_eol);
Utf8Iterator end = begin;
skip_while_reverse(end, buffer.begin(), is_blank);
skip_while_reverse(end, buffer.begin(), is_horizontal_blank);
bool with_end = false;
if (word_type == Word and is_punctuation(*end))
@ -153,7 +153,7 @@ Selection select_word(const Buffer& buffer,
{
skip_while(last, buffer.end(), is_word<word_type>);
if (not (flags & ObjectFlags::Inner))
skip_while(last, buffer.end(), is_blank);
skip_while(last, buffer.end(), is_horizontal_blank);
--last;
}
}
@ -161,7 +161,7 @@ Selection select_word(const Buffer& buffer,
{
if (flags & ObjectFlags::ToBegin)
{
skip_while_reverse(first, buffer.begin(), is_blank);
skip_while_reverse(first, buffer.begin(), is_horizontal_blank);
if (not is_word<word_type>(*first))
return selection;
skip_while_reverse(first, buffer.begin(), is_word<word_type>);
@ -170,7 +170,7 @@ Selection select_word(const Buffer& buffer,
}
if (flags & ObjectFlags::ToEnd)
{
skip_while(last, buffer.end(), is_blank);
skip_while(last, buffer.end(), is_horizontal_blank);
--last;
}
}

View File

@ -15,11 +15,6 @@ inline bool is_eol(Codepoint c)
return c == '\n';
}
inline bool is_blank(Codepoint c)
{
return c == ' ' or c == '\t';
}
inline bool is_horizontal_blank(Codepoint c)
{
return c == ' ' or c == '\t';
@ -36,12 +31,12 @@ inline bool is_word(Codepoint c)
template<>
inline bool is_word<WORD>(Codepoint c)
{
return not is_blank(c) and not is_eol(c);
return not is_horizontal_blank(c) and not is_eol(c);
}
inline bool is_punctuation(Codepoint c)
{
return not (is_word(c) or is_blank(c) or is_eol(c));
return not (is_word(c) or is_horizontal_blank(c) or is_eol(c));
}
enum class CharCategories
@ -59,7 +54,7 @@ inline CharCategories categorize(Codepoint c)
return CharCategories::Word;
if (is_eol(c))
return CharCategories::EndOfLine;
if (is_blank(c))
if (is_horizontal_blank(c))
return CharCategories::Blank;
return word_type == WORD ? CharCategories::Word
: CharCategories::Punctuation;