]> git.lyx.org Git - lyx.git/blobdiff - src/Text3.cpp
#9130 Text in main work area isn't rendered with high resolution
[lyx.git] / src / Text3.cpp
index 7350618747efe98e9c9a48997f6ef47ed9b42de9..79711f43732769b8555e611328e9b74d0588ef3a 100644 (file)
@@ -409,7 +409,8 @@ static void outline(OutlineOp mode, Cursor & cur)
                        cur.pit() = newpit - len;
                        break;
                }
-               case OutlineIn: {
+               case OutlineIn:
+               case OutlineOut: {
                        pit_type const len = distance(start, finish);
                        buf.undo().recordUndo(cur, ATOMIC_UNDO, pit, pit + len - 1);
                        for (; start != finish; ++start) {
@@ -419,7 +420,8 @@ static void outline(OutlineOp mode, Cursor & cur)
                                DocumentClass::const_iterator lit = tc.begin();
                                DocumentClass::const_iterator len = tc.end();
                                for (; lit != len; ++lit) {
-                                       if (lit->toclevel == toclevel + 1 &&
+                                       if (lit->toclevel == (mode == OutlineIn ?
+                                                             toclevel + 1 : toclevel - 1) &&
                                            start->layout().labeltype == lit->labeltype) {
                                                start->setLayout(*lit);
                                                break;
@@ -428,25 +430,6 @@ static void outline(OutlineOp mode, Cursor & cur)
                        }
                        break;
                }
-               case OutlineOut: {
-                       pit_type const len = distance(start, finish);
-                       buf.undo().recordUndo(cur, ATOMIC_UNDO, pit, pit + len - 1);
-                       for (; start != finish; ++start) {
-                               toclevel = buf.text().getTocLevel(distance(bgn, start));
-                               if (toclevel == Layout::NOT_IN_TOC)
-                                       continue;
-                               DocumentClass::const_iterator lit = tc.begin();
-                               DocumentClass::const_iterator len = tc.end();
-                               for (; lit != len; ++lit) {
-                                       if (lit->toclevel == toclevel - 1 &&
-                                               start->layout().labeltype == lit->labeltype) {
-                                                       start->setLayout(*lit);
-                                                       break;
-                                       }
-                               }
-                       }
-                       break;
-               }
        }
 }
 
@@ -1071,23 +1054,32 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                cap::replaceSelection(cur);
                pit_type pit = cur.pit();
                Paragraph const & par = pars_[pit];
-               Paragraph const & prevpar = pit > 0 ? pars_[pit - 1] : par;
-               if (pit > 0 && cur.pos() == par.beginOfBody()
-                   && ((prevpar.getDepth() > par.getDepth()
-                        && !par.layout().isEnvironment())
-                       || (prevpar.layout() != par.layout()
-                           && prevpar.layout().isEnvironment()))) {
-                       if (par.layout().isEnvironment()) {
+               pit_type prev = pit;
+               if (pit > 0) {
+                       if (!pars_[pit - 1].layout().isEnvironment())
+                               prev = depthHook(pit, par.getDepth());
+                       else if (pars_[pit - 1].getDepth() >= par.getDepth())
+                               prev = pit - 1;
+               }
+               if (prev < pit && cur.pos() == par.beginOfBody()
+                   && !par.isEnvSeparator(cur.pos())
+                   && !par.layout().isCommand()
+                   && pars_[prev].layout() != par.layout()
+                   && pars_[prev].layout().isEnvironment()) {
+                       if (par.layout().isEnvironment()
+                           && pars_[prev].getDepth() == par.getDepth()) {
                                docstring const layout = par.layout().name();
                                DocumentClass const & tc = bv->buffer().params().documentClass();
                                lyx::dispatch(FuncRequest(LFUN_LAYOUT, tc.plainLayout().name()));
                                lyx::dispatch(FuncRequest(LFUN_SEPARATOR_INSERT, "parbreak"));
-                               breakParagraph(cur, true);
+                               lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_BREAK, "inverse"));
                                lyx::dispatch(FuncRequest(LFUN_LAYOUT, layout));
                        } else {
                                lyx::dispatch(FuncRequest(LFUN_SEPARATOR_INSERT, "parbreak"));
                                breakParagraph(cur);
                        }
+                       Font const f(inherit_font, cur.current_font.language());
+                       pars_[cur.pit() - 1].resetFonts(f);
                } else {
                        breakParagraph(cur, cmd.argument() == "inverse");
                }
@@ -1546,7 +1538,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 
        case LFUN_MOUSE_DOUBLE:
                if (cmd.button() == mouse_button::button1) {
-                       selectWord(cur, WHOLE_WORD_STRICT);
+                       selectWord(cur, WHOLE_WORD);
                        bv->cursor() = cur;
                }
                break;