Bennett Helm <[EMAIL PROTECTED]> writes:

> The standard behavior on Mac is to have forward-word jumps to the end
> of the current word, and backward-word jumps to the beginning of the
> previous word. That's what I'd want.

This is what emacs does. In the meantime, I have implemented the other
possibility, the one that works like PC programs. I would be
interested to see people test it and tell me whether it is better than
the current one.

Implementing the mac behaviour via either a hidden pref or a parameter
to the lfun (to use different bindings) would be possible.

> Another difference from Mac standard: in jumping forward/backward by
> words, LyX treats an apostrophe as a word break. Thus, in jumping
> forward by words in "I don't", LyX will go from after the "I" to
> after the "n" to after the "t", whereas Mac standard is to go
> straight from after the "I" to after the "t".

What does the mac do when a word is enclosed by apostrophes?

JMarc

svndiff src/Text.cpp

Index: src/Text.cpp
===================================================================
--- src/Text.cpp	(révision 21639)
+++ src/Text.cpp	(copie de travail)
@@ -815,19 +815,25 @@ bool Text::cursorRightOneWord(Cursor & c
 	BOOST_ASSERT(this == cur.text());
 
 	Cursor old = cur;
-
-	if (old.pos() == old.lastpos() && old.pit() != old.lastpit()) {
-		++old.pit();
-		old.pos() = 0;
+	pos_type const lastpos = old.lastpos();
+	pit_type pit = old.pit();
+	pos_type pos = old.pos();
+
+	if (pos == lastpos && pit != old.lastpit()) {
+		++pit;
+		pos = 0;
 	} else {
+		Paragraph & par = old.paragraph();
+		// at least one step
+		++pos;
 		// Advance through word.
-		while (old.pos() != old.lastpos() && old.paragraph().isLetter(old.pos()))
-			++old.pos();
-		// Skip through trailing nonword stuff.
-		while (old.pos() != old.lastpos() && !old.paragraph().isLetter(old.pos()))
-			++old.pos();
+		while (pos != lastpos && par.isLetter(pos))
+			++pos;
+		// Skip through trailing spaces.
+		while (pos != lastpos && par.isSeparator(pos))
+			++pos;
 	}
-	return setCursor(cur, old.pit(), old.pos());
+	return setCursor(cur, pit, pos);
 }
 
 
@@ -836,19 +842,23 @@ bool Text::cursorLeftOneWord(Cursor & cu
 	BOOST_ASSERT(this == cur.text());
 
 	Cursor old = cur;
+	pos_type pos = old.pos();
 
-	if (old.pos() == 0 && old.pit() != 0) {
+	if (pos == 0 && old.pit() != 0) {
 		--old.pit();
-		old.pos() = old.lastpos();
+		pos = old.lastpos();
 	} else {
-		// Skip through initial nonword stuff.
-		while (old.pos() != 0 && !old.paragraph().isLetter(old.pos() - 1))
-			--old.pos();
+		Paragraph & par = old.paragraph();
+		// at least one step
+		--pos;
+		// Skip through spaces.
+		while (pos != 0 && par.isSeparator(pos - 1))
+			--pos;
 		// Advance through word.
-		while (old.pos() != 0 && old.paragraph().isLetter(old.pos() - 1))
-			--old.pos();
+		while (pos != 0 && par.isLetter(pos - 1))
+			--pos;
 	}
-	return setCursor(cur, old.pit(), old.pos());
+	return setCursor(cur, old.pit(), pos);
 }
 
 

Reply via email to