From 04ee9eeae49c2128d5c171006e8451f5664476bd Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Mon, 27 Oct 2003 12:13:16 +0000 Subject: Patches from Roy Wood: Word movement to end of word. Stuttered page movement. User defined keyboard accelerators on GTK+. --- src/Document.cxx | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/Document.cxx') diff --git a/src/Document.cxx b/src/Document.cxx index 7f4893711..130a920e1 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -791,6 +791,40 @@ int Document::NextWordStart(int pos, int delta) { return pos; } +/** + * Find the end of the next word in either a forward (delta >= 0) or backwards direction + * (delta < 0). + * This is looking for a transition between character classes although there is also some + * additional movement to transit white space. + * Used by cursor movement by word commands. + */ +int Document::NextWordEnd(int pos, int delta) { + if (delta < 0) { + if (pos > 0) { + charClassification ccStart = WordCharClass(cb.CharAt(pos-1)); + if (ccStart != ccSpace) { + while (pos > 0 && WordCharClass(cb.CharAt(pos - 1)) == ccStart) { + pos--; + } + } + while (pos > 0 && WordCharClass(cb.CharAt(pos - 1)) == ccSpace) { + pos--; + } + } + } else { + while (pos < Length() && WordCharClass(cb.CharAt(pos)) == ccSpace) { + pos++; + } + if (pos < Length()) { + charClassification ccStart = WordCharClass(cb.CharAt(pos)); + while (pos < Length() && WordCharClass(cb.CharAt(pos)) == ccStart) { + pos++; + } + } + } + return pos; +} + /** * Check that the character at the given position is a word or punctuation character and that * the previous character is of a different character class. -- cgit v1.2.3