]> git.lyx.org Git - lyx.git/blobdiff - src/Cursor.cpp
Refactor InsetQuotes.h enums
[lyx.git] / src / Cursor.cpp
index 1a3ee3b6cbd5613d9b5a9f2f11298774daead09f..ee54ace608a3c31a0a297af01c2f6fd6150a563a 100644 (file)
 
 #include <config.h>
 
+#include "Cursor.h"
+
 #include "Buffer.h"
 #include "BufferView.h"
 #include "CoordCache.h"
-#include "Cursor.h"
 #include "CutAndPaste.h"
-#include "DispatchResult.h"
 #include "FuncCode.h"
 #include "FuncRequest.h"
 #include "Language.h"
@@ -27,7 +27,6 @@
 #include "LyXAction.h"
 #include "LyXRC.h"
 #include "Paragraph.h"
-#include "ParIterator.h"
 #include "Row.h"
 #include "texstream.h"
 #include "Text.h"
 
 #include "support/debug.h"
 #include "support/docstream.h"
-#include "support/ExceptionMessage.h"
 #include "support/gettext.h"
 #include "support/lassert.h"
 
 #include "insets/InsetTabular.h"
-#include "insets/InsetText.h"
 
 #include "mathed/InsetMath.h"
 #include "mathed/InsetMathBrace.h"
@@ -505,7 +502,7 @@ void CursorData::clearSelection()
 }
 
 
-int CursorData::countInsetsInSelection(InsetCode const & inset_code)
+int CursorData::countInsetsInSelection(InsetCode const & inset_code) const
 {
        if (!selection_)
                return 0;
@@ -531,7 +528,7 @@ int CursorData::countInsetsInSelection(InsetCode const & inset_code)
 }
 
 
-bool CursorData::insetInSelection(InsetCode const & inset_code)
+bool CursorData::insetInSelection(InsetCode const & inset_code) const
 {
        if (!selection_)
                return false;
@@ -640,9 +637,9 @@ void CursorData::recordUndo(UndoKind kind) const
 }
 
 
-void CursorData::recordUndoInset(Inset const * in) const
+void CursorData::recordUndoInset(Inset const * inset) const
 {
-       buffer()->undo().recordUndoInset(*this, in);
+       buffer()->undo().recordUndoInset(*this, inset);
 }
 
 
@@ -672,7 +669,7 @@ void CursorData::recordUndoSelection() const
 }
 
 
-int CursorData::currentMode()
+int CursorData::currentMode() const
 {
        LASSERT(!empty(), return Inset::UNDECIDED_MODE);
        for (int i = depth() - 1; i >= 0; --i) {
@@ -900,19 +897,19 @@ void Cursor::pop()
 }
 
 
-void Cursor::push(Inset & p)
+void Cursor::push(Inset & inset)
 {
-       push_back(CursorSlice(p));
-       p.setBuffer(*buffer());
+       push_back(CursorSlice(inset));
+       inset.setBuffer(*buffer());
 }
 
 
-void Cursor::pushBackward(Inset & p)
+void Cursor::pushBackward(Inset & inset)
 {
        LASSERT(!empty(), return);
        //lyxerr << "Entering inset " << t << " front" << endl;
-       push(p);
-       p.idxFirst(*this);
+       push(inset);
+       inset.idxFirst(*this);
 }
 
 
@@ -1382,19 +1379,19 @@ void Cursor::updateTextTargetOffset()
 }
 
 
-bool Cursor::selHandle(bool sel)
+bool Cursor::selHandle(bool selecting)
 {
        //lyxerr << "Cursor::selHandle" << endl;
        if (mark())
-               sel = true;
-       if (sel == selection())
+               selecting = true;
+       if (selecting == selection())
                return false;
 
-       if (!sel)
+       if (!selecting)
                cap::saveSelection(*this);
 
        resetAnchor();
-       selection(sel);
+       selection(selecting);
        return true;
 }
 
@@ -1435,10 +1432,7 @@ bool Cursor::atFirstOrLastRow(bool up)
 ///////////////////////////////////////////////////////////////////
 
 #include "mathed/InsetMathChar.h"
-#include "mathed/InsetMathGrid.h"
-#include "mathed/InsetMathScript.h"
 #include "mathed/InsetMathUnknown.h"
-#include "mathed/MathFactory.h"
 #include "mathed/MathStream.h"
 #include "mathed/MathSupport.h"
 
@@ -1839,13 +1833,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;
 }
 
 
@@ -2405,7 +2399,9 @@ bool notifyCursorLeavesOrEnters(Cursor const & old, Cursor & cur)
 
 void Cursor::setLanguageFromInput()
 {
-       if (!lyxrc.respect_os_kbd_language)
+       if (!lyxrc.respect_os_kbd_language
+           || !inTexted()
+           || paragraph().isPassThru())
                return;
        string const & code = theApp()->inputLanguageCode();
        Language const * lang = languages.getFromCode(code, buffer()->getLanguages());
@@ -2463,6 +2459,12 @@ void Cursor::setCurrentFont()
                real_current_font.setLanguage(lang);
                real_current_font.fontInfo().setNumber(FONT_OFF);
        }
+
+       // No language in pass thru situations
+       if (cs.paragraph().isPassThru()) {
+               current_font.setLanguage(latex_language);
+               real_current_font.setLanguage(latex_language);
+       }
 }