From 75c631df7f1124b6bf53f48f8d82ecb42fdb9c52 Mon Sep 17 00:00:00 2001 From: Stephan Witt Date: Sat, 25 May 2013 18:02:21 +0200 Subject: [PATCH] On Mac, moving down a paragraph should place the cursor at the end of the current paragraph (unless it's already there, in which case it should move to the end of the next paragraph). Change the preference setting name (mac_like_word_movement to mac_like_cursor_movement) to better reflect its function. Patch and description from Bennett Helm --- development/MacOSX/lyxrc.dist.in | 2 +- lib/scripts/prefs2prefs_prefs.py | 8 +++++++- src/LyXRC.cpp | 26 +++++++++++++------------- src/LyXRC.h | 4 ++-- src/Text.cpp | 4 ++-- src/Text2.cpp | 8 +++++++- src/frontends/qt4/GuiPrefs.cpp | 6 +++--- src/frontends/qt4/ui/PrefEditUi.ui | 6 +++--- 8 files changed, 38 insertions(+), 26 deletions(-) diff --git a/development/MacOSX/lyxrc.dist.in b/development/MacOSX/lyxrc.dist.in index 598d8a34d1..43d353f536 100644 --- a/development/MacOSX/lyxrc.dist.in +++ b/development/MacOSX/lyxrc.dist.in @@ -28,7 +28,7 @@ \screen_font_sans "Helvetica" \screen_font_typewriter "Courier" \open_buffers_in_tabs false -\mac_like_word_movement true +\mac_like_cursor_movement true \scroll_wheel_zoom "off" diff --git a/lib/scripts/prefs2prefs_prefs.py b/lib/scripts/prefs2prefs_prefs.py index 662f650aef..a3d4c432d9 100644 --- a/lib/scripts/prefs2prefs_prefs.py +++ b/lib/scripts/prefs2prefs_prefs.py @@ -57,6 +57,9 @@ # Add option to use the system's theme icons # No conversion necessary. +# Incremented to format 13, by bh +# Rename mac_like_word_movement to mac_like_cursor_movement + import re ########################################################### @@ -290,6 +293,8 @@ def remove_default_language(line): return no_match return (True, "") +def mac_cursor_movement(line): + return simple_renaming(line, "\\mac_like_word_movement", "\\mac_like_cursor_movement") # End conversions for LyX 2.0 to 2.1 #################################### @@ -313,5 +318,6 @@ conversions = [ [ 9, [ remove_default_language ]], [ 10, []], [ 11, [split_pdf_format]], - [ 12, []] + [ 12, []], + [ 13, [mac_cursor_movement]] ] diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index d270b0e915..6c7809c7e5 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -55,7 +55,7 @@ namespace os = support::os; namespace { -static unsigned int const LYXRC_FILEFORMAT = 12; // vfr: System theme's icons +static unsigned int const LYXRC_FILEFORMAT = 13; // vfr: System theme's icons // when adding something to this array keep it sorted! LexerKeyword lyxrcTags[] = { @@ -134,7 +134,7 @@ LexerKeyword lyxrcTags[] = { { "\\language_package_selection", LyXRC::RC_LANGUAGE_PACKAGE_SELECTION }, { "\\load_session", LyXRC::RC_LOADSESSION }, { "\\mac_dontswap_ctrl_meta", LyXRC::RC_MAC_DONTSWAP_CTRL_META }, - { "\\mac_like_word_movement", LyXRC::RC_MAC_LIKE_WORD_MOVEMENT }, + { "\\mac_like_cursor_movement", LyXRC::RC_MAC_LIKE_CURSOR_MOVEMENT }, { "\\macro_edit_style", LyXRC::RC_MACRO_EDIT_STYLE }, { "\\make_backup", LyXRC::RC_MAKE_BACKUP }, { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE }, @@ -331,7 +331,7 @@ void LyXRC::setDefaults() scroll_wheel_zoom = SCROLL_WHEEL_ZOOM_CTRL; paragraph_markers = false; mac_dontswap_ctrl_meta = false; - mac_like_word_movement = false; + mac_like_cursor_movement = false; macro_edit_style = MACRO_EDIT_INLINE_BOX; dialogs_iconify_with_main = false; preview = PREVIEW_OFF; @@ -931,8 +931,8 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) lexrc >> mac_dontswap_ctrl_meta; break; - case RC_MAC_LIKE_WORD_MOVEMENT: - lexrc >> mac_like_word_movement; + case RC_MAC_LIKE_CURSOR_MOVEMENT: + lexrc >> mac_like_cursor_movement; break; case RC_MACRO_EDIT_STYLE: @@ -1784,12 +1784,12 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c } if (tag != RC_LAST) break; - case RC_MAC_LIKE_WORD_MOVEMENT: + case RC_MAC_LIKE_CURSOR_MOVEMENT: if (ignore_system_lyxrc || - mac_like_word_movement - != system_lyxrc.mac_like_word_movement) { - os << "\\mac_like_word_movement " - << convert(mac_like_word_movement) << '\n'; + mac_like_cursor_movement + != system_lyxrc.mac_like_cursor_movement) { + os << "\\mac_like_cursor_movement " + << convert(mac_like_cursor_movement) << '\n'; } if (tag != RC_LAST) break; @@ -2967,7 +2967,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_LANGUAGE_PACKAGE_SELECTION: case LyXRC::RC_LYXRCFORMAT: case LyXRC::RC_MAC_DONTSWAP_CTRL_META: - case LyXRC::RC_MAC_LIKE_WORD_MOVEMENT: + case LyXRC::RC_MAC_LIKE_CURSOR_MOVEMENT: case LyXRC::RC_MACRO_EDIT_STYLE: case LyXRC::RC_MAKE_BACKUP: case LyXRC::RC_MARK_FOREIGN_LANGUAGE: @@ -3145,8 +3145,8 @@ string const LyXRC::getDescription(LyXRCTags tag) str = _("Make Apple key act as Meta and Control key as Ctrl."); break; - case RC_MAC_LIKE_WORD_MOVEMENT: - str = _("Use the Mac OS X conventions for the word-level cursor movement"); + case RC_MAC_LIKE_CURSOR_MOVEMENT: + str = _("Use the Mac OS X conventions for cursor movement"); break; case RC_SHOW_MACRO_LABEL: diff --git a/src/LyXRC.h b/src/LyXRC.h index a4464c2d4a..903d53f7e4 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -114,7 +114,7 @@ public: RC_LYXRCFORMAT, RC_MACRO_EDIT_STYLE, RC_MAC_DONTSWAP_CTRL_META, - RC_MAC_LIKE_WORD_MOVEMENT, + RC_MAC_LIKE_CURSOR_MOVEMENT, RC_MAKE_BACKUP, RC_MARK_FOREIGN_LANGUAGE, RC_MOUSE_WHEEL_SPEED, @@ -428,7 +428,7 @@ public: /// bool mac_dontswap_ctrl_meta; /// - bool mac_like_word_movement; + bool mac_like_cursor_movement; /// bool cursor_follows_scrollbar; /// diff --git a/src/Text.cpp b/src/Text.cpp index 38e865f039..5bb70418eb 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -1057,7 +1057,7 @@ bool Text::cursorForwardOneWord(Cursor & cur) return false; } - if (lyxrc.mac_like_word_movement) { + if (lyxrc.mac_like_cursor_movement) { // Skip through trailing punctuation and spaces. while (pos != lastpos && (par.isChar(pos) || par.isSpace(pos))) ++pos; @@ -1099,7 +1099,7 @@ bool Text::cursorBackwardOneWord(Cursor & cur) if (pos == 0 && pit != 0) return setCursor(cur, pit - 1, getPar(pit - 1).size()); - if (lyxrc.mac_like_word_movement) { + if (lyxrc.mac_like_cursor_movement) { // Skip through punctuation and spaces. while (pos != 0 && (par.isChar(pos - 1) || par.isSpace(pos - 1))) --pos; diff --git a/src/Text2.cpp b/src/Text2.cpp index 012eb69b50..7893b8ed71 100644 --- a/src/Text2.cpp +++ b/src/Text2.cpp @@ -773,7 +773,13 @@ bool Text::cursorDownParagraph(Cursor & cur) { bool updated = false; if (cur.pit() != cur.lastpit()) - updated = setCursor(cur, cur.pit() + 1, 0); + if (lyxrc.mac_like_cursor_movement) + if (cur.pos() == cur.lastpos()) + updated = setCursor(cur, cur.pit() + 1, getPar(cur.pit() + 1).size()); + else + updated = setCursor(cur, cur.pit(), cur.lastpos()); + else + updated = setCursor(cur, cur.pit() + 1, 0); else updated = setCursor(cur, cur.pit(), cur.lastpos()); return updated; diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 5a59521268..b53384dff7 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -2683,7 +2683,7 @@ PrefEdit::PrefEdit(GuiPreferences * form) this, SIGNAL(changed())); connect(scrollBelowCB, SIGNAL(clicked()), this, SIGNAL(changed())); - connect(macLikeWordMovementCB, SIGNAL(clicked()), + connect(macLikeCursorMovementCB, SIGNAL(clicked()), this, SIGNAL(changed())); connect(sortEnvironmentsCB, SIGNAL(clicked()), this, SIGNAL(changed())); @@ -2712,7 +2712,7 @@ void PrefEdit::apply(LyXRC & rc) const { rc.cursor_follows_scrollbar = cursorFollowsCB->isChecked(); rc.scroll_below_document = scrollBelowCB->isChecked(); - rc.mac_like_word_movement = macLikeWordMovementCB->isChecked(); + rc.mac_like_cursor_movement = macLikeCursorMovementCB->isChecked(); rc.sort_layouts = sortEnvironmentsCB->isChecked(); rc.group_layouts = groupEnvironmentsCB->isChecked(); switch (macroEditStyleCO->currentIndex()) { @@ -2734,7 +2734,7 @@ void PrefEdit::update(LyXRC const & rc) { cursorFollowsCB->setChecked(rc.cursor_follows_scrollbar); scrollBelowCB->setChecked(rc.scroll_below_document); - macLikeWordMovementCB->setChecked(rc.mac_like_word_movement); + macLikeCursorMovementCB->setChecked(rc.mac_like_cursor_movement); sortEnvironmentsCB->setChecked(rc.sort_layouts); groupEnvironmentsCB->setChecked(rc.group_layouts); macroEditStyleCO->setCurrentIndex(rc.macro_edit_style); diff --git a/src/frontends/qt4/ui/PrefEditUi.ui b/src/frontends/qt4/ui/PrefEditUi.ui index 98e5b507b2..fba2ce69cc 100644 --- a/src/frontends/qt4/ui/PrefEditUi.ui +++ b/src/frontends/qt4/ui/PrefEditUi.ui @@ -92,12 +92,12 @@ - + Skip trailing non-word characters - Use Mac-style for cursor moving between &words + Use M&ac-style cursor movement @@ -273,7 +273,7 @@ cursorFollowsCB cursorWidthSB scrollBelowCB - macLikeWordMovementCB + macLikeCursorMovementCB sortEnvironmentsCB groupEnvironmentsCB macroEditStyleCO