X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FCursor.cpp;h=41cf26ec1758fa0b1caa72d2994616f03aba556a;hb=d9f1f7e348d3175bb9bd72d42a113bf1e644031e;hp=35a34527c0c48a3dee29e10c479c343bed867f46;hpb=c7efb677f8550a44b1262944c15515097723fa31;p=lyx.git diff --git a/src/Cursor.cpp b/src/Cursor.cpp index 35a34527c0..41cf26ec17 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -22,6 +22,7 @@ #include "DispatchResult.h" #include "FuncCode.h" #include "FuncRequest.h" +#include "Language.h" #include "Layout.h" #include "LyXAction.h" #include "LyXRC.h" @@ -51,6 +52,8 @@ #include "mathed/MathFactory.h" #include "mathed/InsetMathMacro.h" +#include "frontends/Application.h" + #include #include #include @@ -121,19 +124,19 @@ DocIterator bruteFind(Cursor const & c, int x, int y) CursorData::CursorData() : DocIterator(), anchor_(), selection_(false), mark_(false), - word_selection_(false), autocorrect_(false), current_font(inherit_font) + word_selection_(false), current_font(inherit_font) {} CursorData::CursorData(Buffer * buffer) : DocIterator(buffer), anchor_(), selection_(false), mark_(false), - word_selection_(false), autocorrect_(false), current_font(inherit_font) + word_selection_(false), current_font(inherit_font) {} CursorData::CursorData(DocIterator const & dit) : DocIterator(dit), anchor_(), selection_(false), mark_(false), - word_selection_(false), autocorrect_(false), current_font(inherit_font) + word_selection_(false), current_font(inherit_font) {} @@ -344,7 +347,7 @@ docstring parbreak(CursorData const * cur) } -docstring CursorData::selectionAsString(bool with_label) const +docstring CursorData::selectionAsString(bool const with_label, bool const skipdelete) const { if (!selection()) return docstring(); @@ -352,8 +355,12 @@ docstring CursorData::selectionAsString(bool with_label) const if (inMathed()) return cap::grabSelection(*this); - int const label = with_label + int label = with_label ? AS_STR_LABEL | AS_STR_INSETS : AS_STR_INSETS; + if (skipdelete) + label = with_label + ? AS_STR_LABEL | AS_STR_INSETS | AS_STR_SKIPDELETE + : AS_STR_INSETS | AS_STR_SKIPDELETE; idx_type const startidx = selBegin().idx(); idx_type const endidx = selEnd().idx(); @@ -609,6 +616,12 @@ void CursorData::endUndoGroup() const } +void CursorData::splitUndoGroup() const +{ + buffer()->undo().splitUndoGroup(*this); +} + + void CursorData::recordUndo(pit_type from, pit_type to) const { buffer()->undo().recordUndo(*this, from, to); @@ -1826,13 +1839,13 @@ bool Cursor::inMacroMode() const InsetMathUnknown * Cursor::activeMacro() { - return inMacroMode() ? prevAtom().nucleus()->asUnknownInset() : 0; + return inMacroMode() ? prevAtom().nucleus()->asUnknownInset() : nullptr; } InsetMathUnknown const * Cursor::activeMacro() const { - return inMacroMode() ? prevAtom().nucleus()->asUnknownInset() : 0; + return inMacroMode() ? prevAtom().nucleus()->asUnknownInset() : nullptr; } @@ -2390,6 +2403,20 @@ bool notifyCursorLeavesOrEnters(Cursor const & old, Cursor & cur) } +void Cursor::setLanguageFromInput() +{ + if (!lyxrc.respect_os_kbd_language) + return; + string const & code = theApp()->inputLanguageCode(); + Language const * lang = languages.getFromCode(code, buffer()->getLanguages()); + if (lang) { + current_font.setLanguage(lang); + real_current_font.setLanguage(lang); + } else + LYXERR0("setLanguageFromCode: unknown language code " << code); +} + + void Cursor::setCurrentFont() { CursorSlice const & cs = innerTextSlice(); @@ -2423,6 +2450,9 @@ void Cursor::setCurrentFont() current_font = par.getFontSettings(bufparams, cpos); real_current_font = tm.displayFont(cpit, cpos); + // set language to input language + setLanguageFromInput(); + // special case for paragraph end if (cs.pos() == lastpos() && tm.isRTLBoundary(cpit, cs.pos()) @@ -2444,12 +2474,6 @@ void Cursor::checkBufferStructure() // In case the master has no gui associated with it, // the TocItem is not updated (part of bug 5699). buffer()->tocBackend().updateItem(*this); - - // If the last tracked change of the paragraph has just been - // deleted, then we need to recompute the buffer flag - // tracked_changes_present_. - if (inTexted() && paragraph().isChangeUpdateRequired()) - disp_.forceChangesUpdate(); }