X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FText3.cpp;h=fa9fa8d69f0c9d22f09682e965a693aa38280c4c;hb=8c6ac457ecc69f57ab54cd8c9b8b7893607c65d6;hp=6808b3d78ea02dacd396304379a17702d4914101;hpb=e1ce2f92db49d50c688414a32944be8e718faa2e;p=lyx.git diff --git a/src/Text3.cpp b/src/Text3.cpp index 6808b3d78e..fa9fa8d69f 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -27,12 +27,12 @@ #include "BufferView.h" #include "Cursor.h" #include "CutAndPaste.h" -#include "debug.h" +#include "support/debug.h" #include "DispatchResult.h" #include "ErrorList.h" #include "factory.h" #include "FuncRequest.h" -#include "gettext.h" +#include "support/gettext.h" #include "InsetList.h" #include "Intl.h" #include "Language.h" @@ -69,7 +69,6 @@ #include "mathed/InsetMathHull.h" #include "mathed/MathMacroTemplate.h" -#include #include #include @@ -507,8 +506,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) case LFUN_CHAR_FORWARD: case LFUN_CHAR_FORWARD_SELECT: - //lyxerr << BOOST_CURRENT_FUNCTION - // << " LFUN_CHAR_FORWARD[SEL]:\n" << cur << endl; + //LYXERR0(" LFUN_CHAR_FORWARD[SEL]:\n" << cur); needsUpdate |= cur.selHandle(cmd.action == LFUN_CHAR_FORWARD_SELECT); needsUpdate |= cursorForward(cur); @@ -670,7 +668,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) break; } - case LFUN_BREAK_LINE: { + case LFUN_NEW_LINE: { // Not allowed by LaTeX (labels or empty par) if (cur.pos() > cur.paragraph().beginOfBody()) { // this avoids a double undo @@ -684,6 +682,21 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) } break; } + + case LFUN_LINE_BREAK: { + // Not allowed by LaTeX (labels or empty par) + if (cur.pos() > cur.paragraph().beginOfBody()) { + // this avoids a double undo + // FIXME: should not be needed, ideally + if (!cur.selection()) + cur.recordUndo(); + cap::replaceSelection(cur); + cur.insert(new InsetLinebreak); + cur.posForward(); + moveCursor(cur, false); + } + break; + } case LFUN_CHAR_DELETE_FORWARD: if (!cur.selection()) { @@ -858,25 +871,28 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) moveCursor(cur, false); break; - case LFUN_HYPHENATION_POINT_INSERT: - specialChar(cur, InsetSpecialChar::HYPHENATION); - break; - - case LFUN_LIGATURE_BREAK_INSERT: - specialChar(cur, InsetSpecialChar::LIGATURE_BREAK); - break; - - case LFUN_DOTS_INSERT: - specialChar(cur, InsetSpecialChar::LDOTS); - break; - - case LFUN_END_OF_SENTENCE_PERIOD_INSERT: - specialChar(cur, InsetSpecialChar::END_OF_SENTENCE); - break; - - case LFUN_MENU_SEPARATOR_INSERT: - specialChar(cur, InsetSpecialChar::MENU_SEPARATOR); + case LFUN_SPECIALCHAR_INSERT: { + string const name = to_utf8(cmd.argument()); + if (name == "hyphenation") + specialChar(cur, InsetSpecialChar::HYPHENATION); + else if (name == "ligature-break") + specialChar(cur, InsetSpecialChar::LIGATURE_BREAK); + else if (name == "slash") + specialChar(cur, InsetSpecialChar::SLASH); + else if (name == "nobreakdash") + specialChar(cur, InsetSpecialChar::NOBREAKDASH); + else if (name == "dots") + specialChar(cur, InsetSpecialChar::LDOTS); + else if (name == "end-of-sentence") + specialChar(cur, InsetSpecialChar::END_OF_SENTENCE); + else if (name == "menu-separator") + specialChar(cur, InsetSpecialChar::MENU_SEPARATOR); + else if (name.empty()) + lyxerr << "LyX function 'specialchar-insert' needs an argument." << endl; + else + lyxerr << "Wrong argument for LyX function 'specialchar-insert'." << endl; break; + } case LFUN_WORD_UPCASE: changeCase(cur, text_uppercase); @@ -1137,37 +1153,40 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) // ignore motions deeper nested than the real anchor Cursor & bvcur = cur.bv().cursor(); - if (bvcur.anchor_.hasPart(cur)) { - CursorSlice old = bvcur.top(); - - int const wh = bv->workHeight(); - int const y = std::max(0, std::min(wh - 1, cmd.y)); - - tm.setCursorFromCoordinates(cur, cmd.x, y); - cur.setTargetX(cmd.x); + if (!bvcur.anchor_.hasPart(cur)) { + cur.undispatched(); + break; + } + CursorSlice old = bvcur.top(); + + int const wh = bv->workHeight(); + int const y = std::max(0, std::min(wh - 1, cmd.y)); + + tm.setCursorFromCoordinates(cur, cmd.x, y); + cur.setTargetX(cmd.x); + if (cmd.y >= wh) + lyx::dispatch(FuncRequest(LFUN_DOWN_SELECT)); + else if (cmd.y < 0) + lyx::dispatch(FuncRequest(LFUN_UP_SELECT)); + // This is to allow jumping over large insets + if (cur.top() == old) { if (cmd.y >= wh) lyx::dispatch(FuncRequest(LFUN_DOWN_SELECT)); else if (cmd.y < 0) lyx::dispatch(FuncRequest(LFUN_UP_SELECT)); - // This is to allow jumping over large insets - if (cur.top() == old) { - if (cmd.y >= wh) - lyx::dispatch(FuncRequest(LFUN_DOWN_SELECT)); - else if (cmd.y < 0) - lyx::dispatch(FuncRequest(LFUN_UP_SELECT)); - } - - if (cur.top() == old) - cur.noUpdate(); - else { - // don't set anchor_ - bvcur.setCursor(cur); - bvcur.selection() = true; - //lyxerr << "MOTION: " << bv->cursor() << endl; - } + } - } else - cur.undispatched(); + if (cur.top() == old) + cur.noUpdate(); + else { + // FIXME: This is brute force! But without it the selected + // area is not corrected updated while moving the mouse. + cur.updateFlags(Update::Force | Update::FitCursor); + // don't set anchor_ + bvcur.setCursor(cur); + bvcur.selection() = true; + //lyxerr << "MOTION: " << bv->cursor() << endl; + } break; } @@ -1203,17 +1222,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) // "auto_region_delete", which defaults to // true (on). - if (lyxrc.auto_region_delete && cur.selection()) { - pit_type const begpit = cur.selBegin().pit(); - pit_type const endpit = cur.selEnd().pit(); + if (lyxrc.auto_region_delete && cur.selection()) cutSelection(cur, false, false); - // When a selection spans multiple paragraphs, the metrics update - // mechanism sometimes fail to detect that a full update is needed. - // In this case, we force the full update: - // (see http://bugzilla.lyx.org/show_bug.cgi?id=4317) - if (isMainText(cur.bv().buffer()) && begpit != endpit) - cur.updateFlags(Update::Force); - } cur.clearSelection(); Font const old_font = cur.real_current_font; @@ -1239,7 +1249,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) content : cmd.argument(); string const data = InsetCommandMailer::params2string("href", p); if (p["target"].empty()) { - bv->showInsetDialog("href", data, 0); + bv->showDialog("href", data); } else { FuncRequest fr(LFUN_INSET_INSERT, data); dispatch(cur, fr); @@ -1256,7 +1266,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) string const data = InsetCommandMailer::params2string("label", p); if (cmd.argument().empty()) { - bv->showInsetDialog("label", data, 0); + bv->showDialog("label", data); } else { FuncRequest fr(LFUN_INSET_INSERT, data); dispatch(cur, fr); @@ -1390,6 +1400,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) case LFUN_TOC_INSERT: case LFUN_HFILL_INSERT: case LFUN_LINE_INSERT: + case LFUN_NEWPAGE_INSERT: case LFUN_PAGEBREAK_INSERT: case LFUN_CLEARPAGE_INSERT: case LFUN_CLEARDOUBLEPAGE_INSERT: @@ -1580,7 +1591,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) string data; params2string(cur.paragraph(), data); data = "show\n" + data; - bv->showDialogWithData("paragraph", data); + bv->showDialog("paragraph", data); break; } @@ -1665,7 +1676,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) arg = cur.selectionAsString(false); } } - bv->showDialogWithData("thesaurus", to_utf8(arg)); + bv->showDialog("thesaurus", to_utf8(arg)); break; } @@ -1729,8 +1740,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) break; default: - LYXERR(Debug::ACTION, BOOST_CURRENT_FUNCTION - << ": Command " << cmd << " not DISPATCHED by Text"); + LYXERR(Debug::ACTION, "Command " << cmd << " not DISPATCHED by Text"); cur.undispatched(); break; } @@ -1948,12 +1958,8 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, // always allow this, since we will inset a raw quote // if an inset is not allowed. break; - case LFUN_HYPHENATION_POINT_INSERT: - case LFUN_LIGATURE_BREAK_INSERT: case LFUN_HFILL_INSERT: - case LFUN_MENU_SEPARATOR_INSERT: - case LFUN_DOTS_INSERT: - case LFUN_END_OF_SENTENCE_PERIOD_INSERT: + case LFUN_SPECIALCHAR_INSERT: code = SPECIALCHAR_CODE; break; case LFUN_SPACE_INSERT: @@ -2094,8 +2100,9 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_PARAGRAPH_UP: case LFUN_PARAGRAPH_DOWN: case LFUN_LINE_BEGIN: + case LFUN_LINE_BREAK: case LFUN_LINE_END: - case LFUN_BREAK_LINE: + case LFUN_NEW_LINE: case LFUN_CHAR_DELETE_FORWARD: case LFUN_DELETE_FORWARD_SKIP: case LFUN_CHAR_DELETE_BACKWARD: @@ -2116,6 +2123,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_DATE_INSERT: case LFUN_SELF_INSERT: case LFUN_LINE_INSERT: + case LFUN_NEWPAGE_INSERT: case LFUN_PAGEBREAK_INSERT: case LFUN_CLEARPAGE_INSERT: case LFUN_CLEARDOUBLEPAGE_INSERT: