diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2011-09-16 09:20:36 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2011-09-16 09:20:36 +0000 |
| commit | 49fce28dec18cb5b0af3e169e3b2ef31b99a6aa6 (patch) | |
| tree | 6ec4c33e5ba99b87e1bfac5b804fc9a8403c14b4 /src | |
| parent | 3afbbefd9baad3413ecadd1d7b804e4f02c33a55 (diff) | |
select_to_next_word{,_end}: words are [a-zA-Z0-9]
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cc | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/main.cc b/src/main.cc index 4a7bfd17..9d9abda2 100644 --- a/src/main.cc +++ b/src/main.cc @@ -289,13 +289,24 @@ bool is_blank(char c) return c == ' ' or c == '\t' or c == '\n'; } +bool is_word(char c) +{ + if (c >= '0' and c <= '9') + return true; + if (c >= 'a' and c <= 'z') + return true; + if (c >= 'A' and c <= 'Z') + return true; + return false; +} + Selection select_to_next_word(const BufferIterator& cursor) { BufferIterator end = cursor; - while (not end.is_end() and not is_blank(*end)) + while (not end.is_end() and is_word(*end)) ++end; - while (not end.is_end() and is_blank(*end)) + while (not end.is_end() and not is_word(*end)) ++end; return Selection(cursor, end); @@ -304,10 +315,10 @@ Selection select_to_next_word(const BufferIterator& cursor) Selection select_to_next_word_end(const BufferIterator& cursor) { BufferIterator end = cursor; - while (not end.is_end() and is_blank(*end)) + while (not end.is_end() and not is_word(*end)) ++end; - while (not end.is_end() and not is_blank(*end)) + while (not end.is_end() and is_word(*end)) ++end; return Selection(cursor, end); |
