\screen_font_sans "Helvetica"
\screen_font_typewriter "Courier"
\open_buffers_in_tabs false
+\mac_like_word_movement true
#
# COLOR SECTION ###################################
{ "\\language_package", LyXRC::RC_LANGUAGE_PACKAGE },
{ "\\language_use_babel", LyXRC::RC_LANGUAGE_USE_BABEL },
{ "\\load_session", LyXRC::RC_LOADSESSION },
+ { "\\mac_like_word_movement", LyXRC::RC_MAC_LIKE_WORD_MOVEMENT },
{ "\\macro_edit_style", LyXRC::RC_MACRO_EDIT_STYLE },
{ "\\make_backup", LyXRC::RC_MAKE_BACKUP },
{ "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE },
tex_allows_spaces = false;
date_insert_format = "%x";
cursor_follows_scrollbar = false;
+ mac_like_word_movement = false;
macro_edit_style = MACRO_EDIT_INLINE_BOX;
dialogs_iconify_with_main = false;
label_init_length = 3;
lexrc >> cursor_follows_scrollbar;
break;
+ case RC_MAC_LIKE_WORD_MOVEMENT:
+ lexrc >> mac_like_word_movement;
+ break;
+
case RC_MACRO_EDIT_STYLE:
if (lexrc.next()) {
switch (lexrc.getInteger()) {
}
if (tag != RC_LAST)
break;
+ case RC_MAC_LIKE_WORD_MOVEMENT:
+ if (ignore_system_lyxrc ||
+ mac_like_word_movement
+ != system_lyxrc.mac_like_word_movement) {
+ os << "\\mac_like_word_movement "
+ << convert<string>(mac_like_word_movement) << '\n';
+ }
+ if (tag != RC_LAST)
+ break;
case RC_MACRO_EDIT_STYLE:
if (ignore_system_lyxrc ||
macro_edit_style
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_MAC_LIKE_WORD_MOVEMENT:
+ str = _("Use the Mac OS X conventions for the word-level cursor movement");
+ 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;
RC_CONVERTER_CACHE_MAXAGE,
RC_COPIER,
RC_CURSOR_FOLLOWS_SCROLLBAR,
+ RC_MAC_LIKE_WORD_MOVEMENT,
RC_CUSTOM_EXPORT_COMMAND,
RC_CUSTOM_EXPORT_FORMAT,
RC_DATE_INSERT_FORMAT,
///
std::string gui_language;
///
+ bool mac_like_word_movement;
+ ///
bool cursor_follows_scrollbar;
///
enum MacroEditStyle {
if (Inset const * inset = getInset(pos))
return inset->isChar();
char_type const c = d->text_[pos];
- return !isLetterChar(c) && !isDigit(c);
+ return !isLetterChar(c) && !isDigit(c) && !lyx::isSpace(c);
+}
+
+
+bool Paragraph::isSpace(pos_type pos) const
+{
+ if (Inset const * inset = getInset(pos))
+ return inset->isSpace();
+ char_type const c = d->text_[pos];
+ return lyx::isSpace(c);
}
bool isLetter(pos_type pos) const;
/// True if the element at this point is a character that is not a letter.
bool isChar(pos_type pos) const;
+ /// True if the element at this point is a space
+ bool isSpace(pos_type pos) const;
/// returns true if at least one line break or line separator has been deleted
/// at the beginning of the paragraph (either physically or logically)
Paragraph const & par = cur.paragraph();
// Paragraph boundary is a word boundary
- if (pos == lastpos && pit != cur.lastpit())
- return setCursor(cur, pit + 1, 0);
+ if (pos == lastpos)
+ if (pit != cur.lastpit())
+ return setCursor(cur, pit + 1, 0);
+ else
+ return false;
+
+ if (lyxrc.mac_like_word_movement) {
+ // 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))
+ // Skip over either a non-char inset or a full word
+ if (pos != lastpos && !par.isLetter(pos))
+ ++pos;
+ else while (pos != lastpos && par.isLetter(pos))
+ ++pos;
+ } else {
+ LASSERT(pos < lastpos, /**/); // see above
+ if (par.isLetter(pos))
+ while (pos != lastpos && par.isLetter(pos))
+ ++pos;
+ else if (par.isChar(pos))
+ while (pos != lastpos && par.isChar(pos))
+ ++pos;
+ else if (!par.isSpace(pos)) // non-char inset
++pos;
- // Skip through trailing punctuation and spaces.
- while (pos != lastpos && par.isChar(pos))
- ++pos;
+ // Skip over white space
+ while (pos != lastpos && par.isSpace(pos))
+ ++pos;
+ }
return setCursor(cur, pit, pos);
}
if (pos == 0 && pit != 0)
return setCursor(cur, pit - 1, getPar(pit - 1).size());
- // Skip through puctuation and spaces.
- while (pos != 0 && par.isChar(pos - 1))
- --pos;
+ if (lyxrc.mac_like_word_movement) {
+ // Skip through puctuation and spaces.
+ while (pos != 0 && par.isChar(pos - 1))
+ --pos;
- // Skip over either a non-char inset or a full word
- if (pos != 0 && !par.isLetter(pos - 1) && !par.isChar(pos - 1))
- --pos;
- else while (pos != 0 && par.isLetter(pos - 1))
+ // Skip over either a non-char inset or a full word
+ if (pos != 0 && !par.isLetter(pos - 1) && !par.isChar(pos - 1))
--pos;
+ else while (pos != 0 && par.isLetter(pos - 1))
+ --pos;
+ } else {
+ // Skip over white space
+ while (pos != 0 && par.isSpace(pos - 1))
+ --pos;
+
+ if (pos != 0 && par.isLetter(pos - 1))
+ while (pos != 0 && par.isLetter(pos - 1))
+ --pos;
+ else if (pos != 0 && par.isChar(pos - 1))
+ while (pos != 0 && par.isChar(pos - 1))
+ --pos;
+ else if (pos != 0 && !par.isSpace(pos - 1)) // non-char inset
+ --pos;
+ }
return setCursor(cur, pit, pos);
}