From 49fce28dec18cb5b0af3e169e3b2ef31b99a6aa6 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 16 Sep 2011 09:20:36 +0000 Subject: [PATCH] select_to_next_word{,_end}: words are [a-zA-Z0-9] --- src/main.cc | 19 +++++++++++++++---- 1 file 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);