]> git.lyx.org Git - lyx.git/blobdiff - src/text2.C
This commit introduces Application_pimpl and cleanup the header includes of the affec...
[lyx.git] / src / text2.C
index 37d1a3056642828a072d2f1498a4ef4f7adf159a..403300a987fab14de7d3b2cd3ace8f558daf237b 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "buffer.h"
 #include "buffer_funcs.h"
+#include "bufferlist.h"
 #include "bufferparams.h"
 #include "BufferView.h"
 #include "Bullet.h"
@@ -36,6 +37,7 @@
 #include "gettext.h"
 #include "language.h"
 #include "LColor.h"
+#include "lyxfunc.h"
 #include "lyxrc.h"
 #include "lyxrow.h"
 #include "lyxrow_funcs.h"
 #include "paragraph_funcs.h"
 #include "ParagraphParameters.h"
 #include "pariterator.h"
+#include "lyxserver.h"
+#include "lyxsocket.h"
 #include "undo.h"
 #include "vspace.h"
 
+#include "frontends/Application.h"
 #include "frontends/font_metrics.h"
-#include "frontends/LyXView.h"
 
 #include "insets/insetenv.h"
 
+#include "mathed/InsetMathHull.h"
+
 #include "support/textutils.h"
 
 #include <boost/current_function.hpp>
@@ -364,13 +370,13 @@ void LyXText::setLayout(LCursor & cur, string const & layout)
        if (lyxlayout->is_environment) {
                // move everything in a new environment inset
                lyxerr[Debug::DEBUG] << "setting layout " << layout << endl;
-               bv.owner()->dispatch(FuncRequest(LFUN_LINE_BEGIN));
-               bv.owner()->dispatch(FuncRequest(LFUN_LINE_END_SELECT));
-               bv.owner()->dispatch(FuncRequest(LFUN_CUT));
+               theApp->lyxFunc().dispatch(FuncRequest(LFUN_LINE_BEGIN));
+               theApp->lyxFunc().dispatch(FuncRequest(LFUN_LINE_END_SELECT));
+               theApp->lyxFunc().dispatch(FuncRequest(LFUN_CUT));
                InsetBase * inset = new InsetEnvironment(params, layout);
                insertInset(cur, inset);
                //inset->edit(cur, true);
-               //bv.owner()->dispatch(FuncRequest(LFUN_PASTE));
+               //theApp->lyxFunc().dispatch(FuncRequest(LFUN_PASTE));
                return;
        }
 
@@ -553,7 +559,7 @@ void LyXText::toggleFree(LCursor & cur, LyXFont const & font, bool toggleall)
        if (font == LyXFont(LyXFont::ALL_IGNORE)) {
                // Could only happen with user style
                cur.message(_("No font change defined. "
-                             "Use Character under the Layout menu to define font change."));
+                                          "Use Character under the Layout menu to define font change."));
                return;
        }
 
@@ -717,6 +723,7 @@ void LyXText::setCursor(CursorSlice & cur, pit_type par, pos_type pos)
 void LyXText::setCursorIntern(LCursor & cur,
                              pit_type par, pos_type pos, bool setfont, bool boundary)
 {
+       BOOST_ASSERT(this == cur.text());
        cur.boundary(boundary);
        setCursor(cur.top(), par, pos);
        cur.setTargetX();
@@ -801,8 +808,8 @@ pos_type LyXText::getColumnNearX(pit_type const pit,
                c = bidi.vis2log(vc);
                last_tmpx = tmpx;
                if (body_pos > 0 && c == body_pos - 1) {
-                        string lsep = layout->labelsep;
-                        docstring dlsep(lsep.begin(), lsep.end());
+                       string lsep = layout->labelsep;
+                       docstring dlsep(lsep.begin(), lsep.end());
                        tmpx += r.label_hfill +
                                font_metrics::width(dlsep, getLabelFont(par));
                        if (par.isLineSeparator(body_pos - 1))
@@ -1078,7 +1085,10 @@ bool LyXText::cursorUp(LCursor & cur)
        if (!cur.selection()) {
                int const y = bv_funcs::getPos(cur, cur.boundary()).y_;
                LCursor old = cur;
-               editXY(cur, x, y - par.rows()[row].ascent() - 1);
+               // Go to middle of previous row. 16 found to work OK;
+               // 12 = top/bottom margin of display math
+               int const margin = 3 * InsetMathHull::displayMargin() / 2;
+               editXY(cur, x, y - par.rows()[row].ascent() - margin);
                cur.clearSelection();
 
                // This happens when you move out of an inset.
@@ -1124,7 +1134,9 @@ bool LyXText::cursorDown(LCursor & cur)
        if (!cur.selection()) {
                int const y = bv_funcs::getPos(cur, cur.boundary()).y_;
                LCursor old = cur;
-               editXY(cur, x, y + par.rows()[row].descent() + 1);
+               // To middle of next row
+               int const margin = 3 * InsetMathHull::displayMargin() / 2;
+               editXY(cur, x, y + par.rows()[row].descent() + margin);
                cur.clearSelection();
 
                // This happens when you move out of an inset.