From 6cebb34085c8649032f7ab672e383ced994b6bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Mon, 13 Oct 2003 00:38:09 +0000 Subject: [PATCH] Get rid of LyXFunc::dispatch that takes a string. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7898 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 8 +++ src/frontends/controllers/ChangeLog | 4 ++ .../controllers/ControlCommandBuffer.C | 3 +- src/frontends/qt2/ChangeLog | 14 +++-- src/frontends/qt2/lyx_gui.C | 3 +- src/frontends/xforms/ChangeLog | 4 ++ src/frontends/xforms/lyx_gui.C | 4 +- src/insets/insettext.C | 4 +- src/lyxfunc.C | 52 +++++++------------ src/lyxfunc.h | 3 -- src/lyxserver.C | 4 +- src/text2.C | 2 +- 12 files changed, 58 insertions(+), 47 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index eece349091..dea28c94be 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2003-10-13 Lars Gullik Bjønnes + + * lyxserver.C (callback): adjust + + * lyxfunc.C (getStatus): add a missing brace in commented code + (ensureBufferClean): reindent + (dispatch): delete version taking a string + 2003-10-11 Lars Gullik Bjønnes * LaTeX.C (deplog): move found file handlig from here... diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 152a2e64d0..6d4bc5ef96 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,7 @@ +2003-10-13 Lars Gullik Bjønnes + + * ControlCommandBuffer.C (dispatch): adjust for dispatch change + 2003-10-08 Angus Leeming Fix doxygen warnings. diff --git a/src/frontends/controllers/ControlCommandBuffer.C b/src/frontends/controllers/ControlCommandBuffer.C index 4b8c3576ea..c64f1a731f 100644 --- a/src/frontends/controllers/ControlCommandBuffer.C +++ b/src/frontends/controllers/ControlCommandBuffer.C @@ -16,6 +16,7 @@ #include "bufferview_funcs.h" #include "lyxfunc.h" #include "LyXAction.h" +#include "funcrequest.h" #include "frontends/LyXView.h" #include "support/lyxalgo.h" #include "support/lstrings.h" @@ -124,5 +125,5 @@ void ControlCommandBuffer::dispatch(string const & str) history_.push_back(str); history_pos_ = history_.end(); - lv_.getLyXFunc().dispatch(str, true); + lv_.getLyXFunc().dispatch(lyxaction.lookupFunc(str), true); } diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 9fd97273bf..40bf47a5ae 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,7 @@ +2003-10-13 Lars Gullik Bjønnes + + * lyx_gui.C (start): adjust for distpatch change + 2003-10-08 Jean-Marc Lasgouttes * qfont_loader.C: add #include (needed for LyX/Mac) @@ -21,11 +25,11 @@ 2003-10-06 Michael Schmitt - * QDelimiterDialog.h: - * QMathDialog.h: - * QSearchDialog.h: - * floatplacement.h: - * iconpalette.h: + * QDelimiterDialog.h: + * QMathDialog.h: + * QSearchDialog.h: + * floatplacement.h: + * iconpalette.h: * panelstack.h: add #include . 2003-10-01 Vitaly Lipatov diff --git a/src/frontends/qt2/lyx_gui.C b/src/frontends/qt2/lyx_gui.C index bd252f01c3..0b1a1fa405 100644 --- a/src/frontends/qt2/lyx_gui.C +++ b/src/frontends/qt2/lyx_gui.C @@ -21,6 +21,7 @@ // FIXME: move this stuff out again #include "bufferlist.h" +#include "LyXAction.h" #include "lyxfunc.h" #include "lyxrc.h" #include "lyxserver.h" @@ -145,7 +146,7 @@ void start(string const & batch, vector const & files) // handle the batch commands the user asked for if (!batch.empty()) { - view.getLyXFunc().dispatch(batch); + view.getLyXFunc().dispatch(lyxaction.lookupFunc(batch)); } qApp->exec(); diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 30a76c4696..8bca6e674f 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,7 @@ +2003-10-13 Lars Gullik Bjønnes + + * lyx_gui.C (start): adjust for dispatch change + 2003-10-07 Angus Leeming * FormExternal.[Ch]: diff --git a/src/frontends/xforms/lyx_gui.C b/src/frontends/xforms/lyx_gui.C index 0a2b331057..29e851a86b 100644 --- a/src/frontends/xforms/lyx_gui.C +++ b/src/frontends/xforms/lyx_gui.C @@ -21,9 +21,11 @@ #include "bufferlist.h" #include "BufferView.h" #include "debug.h" +#include "funcrequest.h" #include "gettext.h" #include "LColor.h" #include "lyx_main.h" +#include "LyXAction.h" #include "lyxfunc.h" #include "lyxrc.h" #include "lyxserver.h" @@ -295,7 +297,7 @@ void start(string const & batch, vector const & files) // handle the batch commands the user asked for if (!batch.empty()) - view.getLyXFunc().dispatch(batch); + view.getLyXFunc().dispatch(lyxaction.lookupFunc(batch)); // enter the event loop while (!finished) { diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 921289d1cd..6b3bede4da 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -399,7 +399,7 @@ bool InsetText::lockInsetInInset(BufferView * bv, UpdatableInset * inset) for (; it != end; ++it) { if (it->inset == inset) { lyxerr << "InsetText::lockInsetInInset: 1 a" << endl; - text_.setCursorIntern( + text_.setCursorIntern( std::distance(paragraphs.begin(), pit), it->pos); lyxerr << "InsetText::lockInsetInInset: 1 b" << endl; lyxerr << "bv: " << bv << " inset: " << inset << endl; @@ -615,7 +615,7 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd) if (cmd.argument.size()) { if (cmd.argument == "left") text_.setCursorIntern(0, 0); - else + else text_.setCursor(paragraphs.size() - 1, paragraphs.back().size()); } else { int tmp_y = (cmd.y < 0) ? 0 : cmd.y; diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 43f9b42153..25f67589a5 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -400,7 +400,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const break; } flag.setOnOff(ev.argument[0] == align); - } else + } else { disable = true; char align = mathcursor->halign(); @@ -817,39 +817,27 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const } -void LyXFunc::dispatch(string const & s, bool verbose) -{ - FuncRequest func = lyxaction.lookupFunc(s); - - if (func.action == LFUN_UNKNOWN_ACTION) { - owner->message(bformat(_("Unknown function (%1$s)"), s)); - return; - } - - dispatch(func, verbose); -} - - namespace { - bool ensureBufferClean(BufferView * bv) { - Buffer & buf = *bv->buffer(); - if (buf.isClean()) - return true; +bool ensureBufferClean(BufferView * bv) +{ + Buffer & buf = *bv->buffer(); + if (buf.isClean()) + return true; - string const file = MakeDisplayPath(buf.fileName(), 30); - string text = bformat(_("The document %1$s has unsaved " - "changes.\n\nDo you want to save " - "the document?"), file); - int const ret = Alert::prompt(_("Save changed document?"), - text, 0, 1, _("&Save"), - _("&Cancel")); + string const file = MakeDisplayPath(buf.fileName(), 30); + string text = bformat(_("The document %1$s has unsaved " + "changes.\n\nDo you want to save " + "the document?"), file); + int const ret = Alert::prompt(_("Save changed document?"), + text, 0, 1, _("&Save"), + _("&Cancel")); - if (ret == 0) - bv->owner()->dispatch(FuncRequest(LFUN_MENUWRITE)); + if (ret == 0) + bv->owner()->dispatch(FuncRequest(LFUN_MENUWRITE)); - return buf.isClean(); - } + return buf.isClean(); +} } //namespace anon @@ -953,7 +941,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose) // FINISHED means that the cursor should be // one position after the inset. } - + if (result == FINISHED_RIGHT) { view()->text->cursorRight(view()); moveCursorUpdate(); @@ -980,7 +968,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose) owner->clearMessage(); goto exit_with_message; } - + if (result == FINISHED_DOWN) { RowList::iterator const irow = view()->text->cursorIRow(); if (irow != view()->text->lastRow()) { @@ -1568,7 +1556,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose) while (!argument.empty()) { string first; argument = split(argument, first, ';'); - dispatch(first); + dispatch(lyxaction.lookupFunc(first)); } } break; diff --git a/src/lyxfunc.h b/src/lyxfunc.h index 21d34fda03..f42e1954eb 100644 --- a/src/lyxfunc.h +++ b/src/lyxfunc.h @@ -45,9 +45,6 @@ public: /// LyX dispatcher, executes lyx actions. void dispatch(FuncRequest const &, bool verbose = false); - /// Dispatch via a string argument - void dispatch(std::string const & s, bool verbose = false); - /// return the status bar state string std::string const view_status_message(); diff --git a/src/lyxserver.C b/src/lyxserver.C index e0f4336f35..d258cb5474 100644 --- a/src/lyxserver.C +++ b/src/lyxserver.C @@ -41,6 +41,8 @@ #include "lyxserver.h" #include "debug.h" +#include "funcrequest.h" +#include "LyXAction.h" #include "lyxfunc.h" #include "support/lstrings.h" #include "support/lyxlib.h" @@ -481,7 +483,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg) // support currently. (Lgb) - serv->func->dispatch(cmd + ' ' + arg); + serv->func->dispatch(FuncRequest(lyxaction.lookupFunc(cmd), arg)); string const rval = serv->func->getMessage(); //modified june 1999 stefano@zool.su.se: diff --git a/src/text2.C b/src/text2.C index 44d4867696..e3994ced4f 100644 --- a/src/text2.C +++ b/src/text2.C @@ -1894,7 +1894,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor) deleted = true; - bool selection_position_was_oldcursor_position = + bool selection_position_was_oldcursor_position = selection.cursor.par() == old_cursor.par() && selection.cursor.pos() == old_cursor.pos();