]> git.lyx.org Git - lyx.git/blobdiff - src/Text3.cpp
Move bind file format tag to LyXAction.cpp, and rename it.
[lyx.git] / src / Text3.cpp
index d97dfd0b09498b53c1e65f25797bb166bd12c398..cc234fa512cd9c31a49b2889b549ae37da95fee4 100644 (file)
@@ -245,7 +245,7 @@ static bool doInsertInset(Cursor & cur, Text * text,
                if (edit)
                        inset->edit(cur, true);
                // Now put this into inset
-               cur.text()->insertStringAsLines(cur, ds, cur.current_font);
+               cur.text()->insertStringAsLines(cur, ds, Font(inherit_font));
                cur.leaveInset(*inset);
                return true;
        }
@@ -839,7 +839,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                Cursor dummy = cur;
                                dummy.pos() = dummy.pit() = 0;
                                if (cur.bv().checkDepm(dummy, cur))
-                                       cur.forceBufferUpdate();;
+                                       cur.forceBufferUpdate();
                        }
                }
                break;
@@ -1348,33 +1348,37 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        }
 
        case LFUN_QUOTE_INSERT: {
-               Paragraph & par = cur.paragraph();
+               // this avoids a double undo
+               // FIXME: should not be needed, ideally
+               if (!cur.selection())
+                       cur.recordUndo();
+               cap::replaceSelection(cur);
+
+               Paragraph const & par = cur.paragraph();
                pos_type pos = cur.pos();
-               BufferParams const & bufparams = bv->buffer().params();
+
                Layout const & style = par.layout();
                InsetLayout const & ilayout = cur.inset().getLayout();
-               if (!style.pass_thru && !ilayout.isPassThru()
-                   && par.getFontSettings(bufparams, pos).language()->lang() != "hebrew") {
-                       // this avoids a double undo
-                       // FIXME: should not be needed, ideally
-                       if (!cur.selection())
-                               cur.recordUndo();
-                       cap::replaceSelection(cur);
-                       pos = cur.pos();
-                       char_type c;
-                       if (pos == 0)
-                               c = ' ';
-                       else if (cur.prevInset() && cur.prevInset()->isSpace())
-                               c = ' ';
-                       else
+               BufferParams const & bufparams = bv->buffer().params();
+               bool const hebrew = 
+                       par.getFontSettings(bufparams, pos).language()->lang() == "hebrew";
+               bool const allow_inset_quote = 
+                       !(style.pass_thru || ilayout.isPassThru() || hebrew);
+               
+               if (allow_inset_quote) {
+                       char_type c = ' ';
+                       if (pos > 0 && (!cur.prevInset() || !cur.prevInset()->isSpace()))
                                c = par.getChar(pos - 1);
-                       string arg = to_utf8(cmd.argument());
-                       cur.insert(new InsetQuotes(cur.buffer(), c, (arg == "single")
-                               ? InsetQuotes::SingleQuotes : InsetQuotes::DoubleQuotes));
+                       string const arg = to_utf8(cmd.argument());
+                       InsetQuotes::QuoteTimes const quote_type = (arg == "single")
+                               ? InsetQuotes::SingleQuotes : InsetQuotes::DoubleQuotes;
+                       cur.insert(new InsetQuotes(cur.buffer(), c, quote_type));
                        cur.posForward();
-               }
-               else
+               } else {
+                       // The cursor might have been invalidated by the replaceSelection.
+                       cur.buffer()->changed(true);
                        lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, "\""));
+               }                       
                break;
        }
 
@@ -1750,6 +1754,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                if (cmd.argument().empty())
                        cur.errorMessage(from_utf8(N_("Missing argument")));
                else {
+                       cur.recordUndo();
                        string s = to_utf8(cmd.argument());
                        string const s1 = token(s, ' ', 1);
                        int const nargs = s1.empty() ? 0 : convert<int>(s1);
@@ -2179,10 +2184,12 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                // The redraw is useful because of the painting of
                // misspelled markers depends on the cursor position.
                // Trigger a redraw for cursor moves inside misspelled text.
-               if (cur.paragraph().id() == last_pid && cur.pos() != last_pos) {
-                       needsUpdate |= last_misspelled || cur.paragraph().isMisspelled(cur.pos());
-               } else if (cur.paragraph().id() != last_pid) {
-                       needsUpdate |= last_misspelled || cur.paragraph().isMisspelled(cur.pos());
+               if (!cur.inTexted()) {
+                       // move from regular text to math
+                       needsUpdate = last_misspelled;
+               } else if (cur.paragraph().id() != last_pid || cur.pos() != last_pos) {
+                       // move inside regular text
+                       needsUpdate = last_misspelled || cur.paragraph().isMisspelled(cur.pos());
                }
        }
 
@@ -2205,7 +2212,6 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor);
                return;
        }
-
        if (!needsUpdate
            && &oldTopSlice.inset() == &cur.inset()
            && oldTopSlice.idx() == cur.idx()