Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes: > This is candidate for branch too. More problems remain in work > skipping, but eating insets was the worst.
With this additional patch, word movement should be closer to what the mac does. It works through a lyxrc setting word_forward_goes_to_end (!) that is not associated to a UI element but can be set in lyxrc.dist. An alternative to this would be to add a parameter ("mac" or whatever) to word-(|delete-)(for|back)ward, and get the right UI by changing mac.bind. The advantage is that scripting would be more robust. What would you prefer? Problems that remain: - cursor should stop at paragraph boundary. - single quote should be part of words (but not at boundary?) - we probably have to handle both the words-are-strings-of-letters word-are-separated-by-spaces semantics. Other? JMarc
svndiff src/LyXRC.h src/Text.cpp src/LyXRC.cpp development/ Index: src/LyXRC.h =================================================================== --- src/LyXRC.h (revision 25370) +++ src/LyXRC.h (working copy) @@ -62,6 +62,7 @@ public: RC_CONVERTER_CACHE_MAXAGE, RC_COPIER, RC_CURSOR_FOLLOWS_SCROLLBAR, + RC_WORD_FORWARD_GOES_TO_END, RC_CUSTOM_EXPORT_COMMAND, RC_CUSTOM_EXPORT_FORMAT, RC_DATE_INSERT_FORMAT, @@ -364,6 +365,8 @@ public: /// bool cursor_follows_scrollbar; /// + bool word_forward_goes_to_end; + /// enum MacroEditStyle { MACRO_EDIT_INLINE_BOX = 0, MACRO_EDIT_INLINE, Index: src/Text.cpp =================================================================== --- src/Text.cpp (revision 25375) +++ src/Text.cpp (working copy) @@ -589,15 +589,27 @@ bool Text::cursorForwardOneWord(Cursor & pos_type pos = cur.pos(); Paragraph const & par = cur.paragraph(); - // Skip over either a non-char inset or a full word - if (pos != lastpos && !par.isLetter(pos) && !par.isChar(pos)) - ++pos; - else while (pos != lastpos && par.isLetter(pos)) + if (lyxrc.word_forward_goes_to_end) { + // Skip through trailing punctuation and spaces. + while (pos != lastpos && par.isChar(pos)) ++pos; - // Skip through trailing punctuation and spaces. - while (pos != lastpos && par.isChar(pos)) - ++pos; + // Skip over either a non-char inset or a full word + if (pos != lastpos && !par.isLetter(pos) && !par.isChar(pos)) + ++pos; + else while (pos != lastpos && par.isLetter(pos)) + ++pos; + } else { + // Skip over either a non-char inset or a full word + if (pos != lastpos && !par.isLetter(pos) && !par.isChar(pos)) + ++pos; + else while (pos != lastpos && par.isLetter(pos)) + ++pos; + + // Skip through trailing punctuation and spaces. + while (pos != lastpos && par.isChar(pos)) + ++pos; + } if (pos == lastpos && pit != cur.lastpit()) { ++pit; Index: src/LyXRC.cpp =================================================================== --- src/LyXRC.cpp (revision 25370) +++ src/LyXRC.cpp (working copy) @@ -180,7 +180,8 @@ LexerKeyword lyxrcTags[] = { { "\\view_dvi_paper_option", LyXRC::RC_VIEWDVI_PAPEROPTION }, // compatibility with versions older than 1.4.0 only { "\\viewer", LyXRC::RC_VIEWER}, - { "\\visual_cursor" ,LyXRC::RC_VISUAL_CURSOR} + { "\\visual_cursor", LyXRC::RC_VISUAL_CURSOR}, + { "\\word_forward_goes_to_end", LyXRC::RC_WORD_FORWARD_GOES_TO_END}, }; const int lyxrcCount = sizeof(lyxrcTags) / sizeof(lyxrcTags[0]); @@ -283,6 +284,7 @@ void LyXRC::setDefaults() tex_allows_spaces = false; date_insert_format = "%x"; cursor_follows_scrollbar = false; + word_forward_goes_to_end = false; macro_edit_style = MACRO_EDIT_INLINE_BOX; dialogs_iconify_with_main = false; label_init_length = 3; @@ -798,6 +800,10 @@ int LyXRC::read(Lexer & lexrc) lexrc >> cursor_follows_scrollbar; break; + case RC_WORD_FORWARD_GOES_TO_END: + lexrc >> word_forward_goes_to_end; + break; + case RC_MACRO_EDIT_STYLE: if (lexrc.next()) { switch (lexrc.getInteger()) { @@ -1482,6 +1488,15 @@ void LyXRC::write(ostream & os, bool ign } if (tag != RC_LAST) break; + case RC_WORD_FORWARD_GOES_TO_END: + if (ignore_system_lyxrc || + word_forward_goes_to_end + != system_lyxrc.word_forward_goes_to_end) { + os << "\\word_forward_goes_to_end " + << convert<string>(word_forward_goes_to_end) << '\n'; + } + if (tag != RC_LAST) + break; case RC_MACRO_EDIT_STYLE: if (ignore_system_lyxrc || macro_edit_style @@ -2444,6 +2459,10 @@ string const LyXRC::getDescription(LyXRC str = _("LyX normally doesn't update the cursor position if you move the scrollbar. Set to true if you'd prefer to always have the cursor on screen."); break; + case RC_WORD_FORWARD_GOES_TO_END: + str = _("When moving the cursor one word forward, LyX normally jumps to the beginning of the next word. Set to true if you'd prefer to always go to the end of the next word."); + break; + case RC_SHOW_MACRO_LABEL: str = _("Show a small box around a Math Macro with the macro name when the cursor is inside."); break; Index: development/MacOSX/lyxrc.dist.in =================================================================== --- development/MacOSX/lyxrc.dist.in (revision 25370) +++ development/MacOSX/lyxrc.dist.in (working copy) @@ -11,6 +11,8 @@ # modifications you should do them from inside LyX and save \bind_file "mac" +\word_forward_goes_to_end true + # # MISC SECTION ######################################