the FuncRequest changes

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4887 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2002-08-07 08:11:41 +00:00
parent 658ab90d1c
commit b8198905dc
47 changed files with 381 additions and 331 deletions

View File

@ -237,7 +237,7 @@ BufferView::UpdateCodes operator|(BufferView::UpdateCodes uc1,
} }
bool BufferView::dispatch(kb_action action, string const & argument) bool BufferView::dispatch(FuncRequest const & ev)
{ {
return pimpl_->dispatch(action, argument); return pimpl_->dispatch(ev);
} }

View File

@ -16,7 +16,6 @@
#include "LString.h" #include "LString.h"
#include "undo.h" #include "undo.h"
#include "commandtags.h"
#include "insets/inset.h" #include "insets/inset.h"
#include "WordLangTuple.h" #include "WordLangTuple.h"
@ -203,7 +202,7 @@ public:
/// ///
void stuffClipboard(string const &) const; void stuffClipboard(string const &) const;
/// ///
bool dispatch(kb_action action, string const & argument); bool dispatch(FuncRequest const & argument);
private: private:
/// ///
struct Pimpl; struct Pimpl;

View File

@ -39,6 +39,7 @@
#include "gettext.h" #include "gettext.h"
#include "ParagraphParameters.h" #include "ParagraphParameters.h"
#include "undo_funcs.h" #include "undo_funcs.h"
#include "funcrequest.h"
#include "insets/insetbib.h" #include "insets/insetbib.h"
#include "insets/insettext.h" #include "insets/insettext.h"
@ -617,8 +618,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
if (paste_internally) if (paste_internally)
owner_->getLyXFunc()->dispatch(LFUN_PASTE); owner_->getLyXFunc()->dispatch(LFUN_PASTE);
else else
owner_->getLyXFunc()->dispatch(LFUN_PASTESELECTION, owner_->getLyXFunc()->dispatch(FuncRequest(LFUN_PASTESELECTION, "paragraph"));
string("paragraph"));
selection_possible = false; selection_possible = false;
return; return;
} }
@ -734,7 +734,7 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
// We are in inset locking mode. // We are in inset locking mode.
/* LyX does a kind of work-area grabbing for insets. /* LyX does a kind of work-area grabbing for insets.
Only a ButtonPress Event outside the inset will Only a ButtonPress FuncRequest outside the inset will
force a insetUnlock. */ force a insetUnlock. */
bv_->theLockingInset()-> bv_->theLockingInset()->
insetButtonRelease(bv_, x, y, button); insetButtonRelease(bv_, x, y, button);
@ -1485,14 +1485,14 @@ void BufferView::Pimpl::MenuInsertLyXFile(string const & filen)
} }
bool BufferView::Pimpl::dispatch(kb_action action, string const & argument) bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
{ {
lyxerr[Debug::ACTION] << "BufferView::Pimpl::Dispatch: action[" lyxerr[Debug::ACTION] << "BufferView::Pimpl::Dispatch: action["
<< action <<"] arg[" << argument << "]" << endl; << ev.action <<"] arg[" << ev.argument << "]" << endl;
LyXTextClass const & tclass = buffer_->params.getLyXTextClass(); LyXTextClass const & tclass = buffer_->params.getLyXTextClass();
switch (action) { switch (ev.action) {
// --- Misc ------------------------------------------- // --- Misc -------------------------------------------
case LFUN_APPENDIX: case LFUN_APPENDIX:
{ {
@ -1542,13 +1542,8 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
break; break;
case LFUN_PASTESELECTION: case LFUN_PASTESELECTION:
{ pasteClipboard(ev.argument == "paragraph");
bool asPara = false; break;
if (argument == "paragraph")
asPara = true;
pasteClipboard(asPara);
}
break;
case LFUN_CUT: case LFUN_CUT:
bv_->cut(); bv_->cut();
@ -1621,28 +1616,28 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
break; break;
case LFUN_FILE_INSERT: case LFUN_FILE_INSERT:
MenuInsertLyXFile(argument); MenuInsertLyXFile(ev.argument);
break; break;
case LFUN_FILE_INSERT_ASCII_PARA: case LFUN_FILE_INSERT_ASCII_PARA:
InsertAsciiFile(bv_, argument, true); InsertAsciiFile(bv_, ev.argument, true);
break; break;
case LFUN_FILE_INSERT_ASCII: case LFUN_FILE_INSERT_ASCII:
InsertAsciiFile(bv_, argument, false); InsertAsciiFile(bv_, ev.argument, false);
break; break;
case LFUN_LAYOUT: case LFUN_LAYOUT:
{ {
lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) " lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
<< argument << endl; << ev.argument << endl;
// This is not the good solution to the empty argument // This is not the good solution to the empty argument
// problem, but it will hopefully suffice for 1.2.0. // problem, but it will hopefully suffice for 1.2.0.
// The correct solution would be to augument the // The correct solution would be to augument the
// function list/array with information about what // function list/array with information about what
// functions needs arguments and their type. // functions needs arguments and their type.
if (argument.empty()) { if (ev.argument.empty()) {
owner_->getLyXFunc()->setErrorMessage( owner_->getLyXFunc()->setErrorMessage(
_("LyX function 'layout' needs an argument.")); _("LyX function 'layout' needs an argument."));
break; break;
@ -1650,8 +1645,8 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
// Derive layout number from given argument (string) // Derive layout number from given argument (string)
// and current buffer's textclass (number). */ // and current buffer's textclass (number). */
bool hasLayout = tclass.hasLayout(argument); bool hasLayout = tclass.hasLayout(ev.argument);
string layout = argument; string layout = ev.argument;
// If the entry is obsolete, use the new one instead. // If the entry is obsolete, use the new one instead.
if (hasLayout) { if (hasLayout) {
@ -1662,7 +1657,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
if (!hasLayout) { if (!hasLayout) {
owner_->getLyXFunc()->setErrorMessage( owner_->getLyXFunc()->setErrorMessage(
string(N_("Layout ")) + argument + string(N_("Layout ")) + ev.argument +
N_(" not known")); N_(" not known"));
break; break;
} }
@ -1699,7 +1694,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
break; break;
case LFUN_LANGUAGE: case LFUN_LANGUAGE:
lang(bv_, argument); lang(bv_, ev.argument);
switchKeyMap(); switchKeyMap();
owner_->view_state_changed(); owner_->view_state_changed();
break; break;
@ -1745,7 +1740,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
break; break;
case LFUN_FONT_SIZE: case LFUN_FONT_SIZE:
fontSize(bv_, argument); fontSize(bv_, ev.argument);
owner_->view_state_changed(); owner_->view_state_changed();
break; break;
@ -1817,16 +1812,16 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
case LFUN_INSERT_LABEL: case LFUN_INSERT_LABEL:
MenuInsertLabel(bv_, argument); MenuInsertLabel(bv_, ev.argument);
break; break;
case LFUN_REF_INSERT: case LFUN_REF_INSERT:
if (argument.empty()) { if (ev.argument.empty()) {
InsetCommandParams p("ref"); InsetCommandParams p("ref");
owner_->getDialogs()->createRef(p.getAsString()); owner_->getDialogs()->createRef(p.getAsString());
} else { } else {
InsetCommandParams p; InsetCommandParams p;
p.setFromString(argument); p.setFromString(ev.argument);
InsetRef * inset = new InsetRef(p, *buffer_); InsetRef * inset = new InsetRef(p, *buffer_);
if (!insertInset(inset)) if (!insertInset(inset))
@ -1837,16 +1832,16 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
break; break;
case LFUN_BOOKMARK_SAVE: case LFUN_BOOKMARK_SAVE:
savePosition(strToUnsignedInt(argument)); savePosition(strToUnsignedInt(ev.argument));
break; break;
case LFUN_BOOKMARK_GOTO: case LFUN_BOOKMARK_GOTO:
restorePosition(strToUnsignedInt(argument)); restorePosition(strToUnsignedInt(ev.argument));
break; break;
case LFUN_REF_GOTO: case LFUN_REF_GOTO:
{ {
string label(argument); string label = ev.argument;
if (label.empty()) { if (label.empty()) {
InsetRef * inset = InsetRef * inset =
static_cast<InsetRef*>(getInsetByCode(Inset::REF_CODE)); static_cast<InsetRef*>(getInsetByCode(Inset::REF_CODE));
@ -2657,7 +2652,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
cur_value = par->params().spacing().getValue(); cur_value = par->params().spacing().getValue();
} }
istringstream istr(argument.c_str()); istringstream istr(ev.argument.c_str());
string tmp; string tmp;
istr >> tmp; istr >> tmp;
@ -2683,7 +2678,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
new_spacing = Spacing::Default; new_spacing = Spacing::Default;
} else { } else {
lyxerr << _("Unknown spacing argument: ") lyxerr << _("Unknown spacing argument: ")
<< argument << endl; << ev.argument << endl;
} }
if (cur_spacing != new_spacing || cur_value != new_value) { if (cur_spacing != new_spacing || cur_value != new_value) {
par->params().spacing(Spacing(new_spacing, new_value)); par->params().spacing(Spacing(new_spacing, new_value));
@ -2716,7 +2711,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
case LFUN_URL: case LFUN_URL:
{ {
InsetCommandParams p; InsetCommandParams p;
if (action == LFUN_HTMLURL) if (ev.action == LFUN_HTMLURL)
p.setCmdName("htmlurl"); p.setCmdName("htmlurl");
else else
p.setCmdName("url"); p.setCmdName("url");
@ -2727,7 +2722,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
case LFUN_INSERT_URL: case LFUN_INSERT_URL:
{ {
InsetCommandParams p; InsetCommandParams p;
p.setFromString(argument); p.setFromString(ev.argument);
InsetUrl * inset = new InsetUrl(p); InsetUrl * inset = new InsetUrl(p);
if (!insertInset(inset)) if (!insertInset(inset))
@ -2763,25 +2758,25 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
case LFUN_INSET_FLOAT: case LFUN_INSET_FLOAT:
// check if the float type exist // check if the float type exist
if (floatList.typeExist(argument)) { if (floatList.typeExist(ev.argument)) {
insertAndEditInset(new InsetFloat(buffer_->params, insertAndEditInset(new InsetFloat(buffer_->params,
argument)); ev.argument));
} else { } else {
lyxerr << "Non-existent float type: " lyxerr << "Non-existent float type: "
<< argument << endl; << ev.argument << endl;
} }
break; break;
case LFUN_INSET_WIDE_FLOAT: case LFUN_INSET_WIDE_FLOAT:
// check if the float type exist // check if the float type exist
if (floatList.typeExist(argument)) { if (floatList.typeExist(ev.argument)) {
InsetFloat * new_inset = InsetFloat * new_inset =
new InsetFloat(buffer_->params, argument); new InsetFloat(buffer_->params, ev.argument);
new_inset->wide(true); new_inset->wide(true);
insertAndEditInset(new_inset); insertAndEditInset(new_inset);
} else { } else {
lyxerr << "Non-existent float type: " lyxerr << "Non-existent float type: "
<< argument << endl; << ev.argument << endl;
} }
break; break;
@ -2817,14 +2812,14 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
case LFUN_TABULAR_INSERT: case LFUN_TABULAR_INSERT:
{ {
if (argument.empty()) { if (ev.argument.empty()) {
owner_->getDialogs()->showTabularCreate(); owner_->getDialogs()->showTabularCreate();
break; break;
} }
int r = 2; int r = 2;
int c = 2; int c = 2;
::sscanf(argument.c_str(),"%d%d", &r, &c); ::sscanf(ev.argument.c_str(),"%d%d", &r, &c);
InsetTabular * new_inset = InsetTabular * new_inset =
new InsetTabular(*buffer_, r, c); new InsetTabular(*buffer_, r, c);
bool const rtl = bool const rtl =
@ -2857,9 +2852,9 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
{ {
int x = 0; int x = 0;
int y = 0; int y = 0;
if (::sscanf(argument.c_str(), " %d %d", &x, &y) != 2) { if (::sscanf(ev.argument.c_str(), " %d %d", &x, &y) != 2) {
lyxerr << "SETXY: Could not parse coordinates in '" lyxerr << "SETXY: Could not parse coordinates in '"
<< argument << std::endl; << ev.argument << std::endl;
} }
bv_->getLyXText()->setCursorFromCoordinates(bv_, x, y); bv_->getLyXText()->setCursorFromCoordinates(bv_, x, y);
} }
@ -2901,13 +2896,13 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
case LFUN_HUNG_UMLAUT: case LFUN_HUNG_UMLAUT:
case LFUN_CIRCLE: case LFUN_CIRCLE:
case LFUN_OGONEK: case LFUN_OGONEK:
if (argument.empty()) { if (ev.argument.empty()) {
// As always... // As always...
owner_->getLyXFunc()->handleKeyFunc(action); owner_->getLyXFunc()->handleKeyFunc(ev.action);
} else { } else {
owner_->getLyXFunc()->handleKeyFunc(action); owner_->getLyXFunc()->handleKeyFunc(ev.action);
owner_->getIntl()->getTransManager() owner_->getIntl()->getTransManager()
.TranslateAndInsert(argument[0], bv_->getLyXText()); .TranslateAndInsert(ev.argument[0], bv_->getLyXText());
update(bv_->getLyXText(), update(bv_->getLyXText(),
BufferView::SELECT BufferView::SELECT
| BufferView::FITCUR | BufferView::FITCUR
@ -2916,45 +2911,45 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
break; break;
case LFUN_MATH: case LFUN_MATH:
mathDispatch(bv_, argument); mathDispatch(bv_, ev.argument);
break; break;
case LFUN_MATH_MACRO: case LFUN_MATH_MACRO:
mathDispatchMathMacro(bv_, argument); mathDispatchMathMacro(bv_, ev.argument);
break; break;
case LFUN_MATH_DELIM: case LFUN_MATH_DELIM:
mathDispatchMathDelim(bv_, argument); mathDispatchMathDelim(bv_, ev.argument);
break; break;
case LFUN_INSERT_MATRIX: case LFUN_INSERT_MATRIX:
mathDispatchInsertMatrix(bv_, argument); mathDispatchInsertMatrix(bv_, ev.argument);
break; break;
case LFUN_INSERT_MATH: case LFUN_INSERT_MATH:
mathDispatchInsertMath(bv_, argument); mathDispatchInsertMath(bv_, ev.argument);
break; break;
case LFUN_MATH_IMPORT_SELECTION: // Imports LaTeX from the X selection case LFUN_MATH_IMPORT_SELECTION: // Imports LaTeX from the X selection
mathDispatchMathImportSelection(bv_, argument); mathDispatchMathImportSelection(bv_, ev.argument);
break; break;
case LFUN_MATH_DISPLAY: // Open or create a displayed math inset case LFUN_MATH_DISPLAY: // Open or create a displayed math inset
mathDispatchMathDisplay(bv_, argument); mathDispatchMathDisplay(bv_, ev.argument);
break; break;
case LFUN_MATH_MODE: // Open or create an inlined math inset case LFUN_MATH_MODE: // Open or create an inlined math inset
mathDispatchMathMode(bv_, argument); mathDispatchMathMode(bv_, ev.argument);
break; break;
case LFUN_GREEK: // Insert a single greek letter case LFUN_GREEK: // Insert a single greek letter
mathDispatchGreek(bv_, argument); mathDispatchGreek(bv_, ev.argument);
break; break;
case LFUN_CITATION_INSERT: case LFUN_CITATION_INSERT:
{ {
InsetCommandParams p; InsetCommandParams p;
p.setFromString(argument); p.setFromString(ev.argument);
InsetCitation * inset = new InsetCitation(p); InsetCitation * inset = new InsetCitation(p);
if (!insertInset(inset)) if (!insertInset(inset))
@ -2969,14 +2964,14 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
// ale970405+lasgoutt970425 // ale970405+lasgoutt970425
// The argument can be up to two tokens separated // The argument can be up to two tokens separated
// by a space. The first one is the bibstyle. // by a space. The first one is the bibstyle.
string const db = token(argument, ' ', 0); string const db = token(ev.argument, ' ', 0);
string const bibstyle = token(argument, ' ', 1); string const bibstyle = token(ev.argument, ' ', 1);
InsetCommandParams p("BibTeX", db, bibstyle); InsetCommandParams p("BibTeX", db, bibstyle);
InsetBibtex * inset = new InsetBibtex(p); InsetBibtex * inset = new InsetBibtex(p);
if (insertInset(inset)) { if (insertInset(inset)) {
if (argument.empty()) if (ev.argument.empty())
inset->edit(bv_); inset->edit(bv_);
} else } else
delete inset; delete inset;
@ -2989,7 +2984,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
InsetBibtex * inset = InsetBibtex * inset =
static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE)); static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
if (inset) { if (inset) {
inset->addDatabase(argument); inset->addDatabase(ev.argument);
} }
} }
break; break;
@ -2999,7 +2994,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
InsetBibtex * inset = InsetBibtex * inset =
static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE)); static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
if (inset) { if (inset) {
inset->delDatabase(argument); inset->delDatabase(ev.argument);
} }
} }
break; break;
@ -3009,14 +3004,14 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
InsetBibtex * inset = InsetBibtex * inset =
static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE)); static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
if (inset) { if (inset) {
inset->setOptions(argument); inset->setOptions(ev.argument);
} }
} }
break; break;
case LFUN_INDEX_INSERT: case LFUN_INDEX_INSERT:
{ {
string entry = argument; string entry = ev.argument;
if (entry.empty()) { if (entry.empty()) {
entry = bv_->getLyXText()->getStringToIndex(bv_); entry = bv_->getLyXText()->getStringToIndex(bv_);
} }
@ -3047,7 +3042,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
case LFUN_PARENTINSERT: case LFUN_PARENTINSERT:
{ {
InsetCommandParams p("lyxparent", argument); InsetCommandParams p("lyxparent", ev.argument);
Inset * inset = new InsetParent(p, *buffer_); Inset * inset = new InsetParent(p, *buffer_);
if (!insertInset(inset, tclass.defaultLayoutName())) if (!insertInset(inset, tclass.defaultLayoutName()))
delete inset; delete inset;
@ -3058,7 +3053,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
case LFUN_CHILD_INSERT: case LFUN_CHILD_INSERT:
{ {
InsetInclude::Params p; InsetInclude::Params p;
p.cparams.setFromString(argument); p.cparams.setFromString(ev.argument);
p.masterFilename_ = buffer_->fileName(); p.masterFilename_ = buffer_->fileName();
InsetInclude * inset = new InsetInclude(p); InsetInclude * inset = new InsetInclude(p);
@ -3072,19 +3067,19 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
break; break;
case LFUN_FLOAT_LIST: case LFUN_FLOAT_LIST:
if (floatList.typeExist(argument)) { if (floatList.typeExist(ev.argument)) {
Inset * inset = new InsetFloatList(argument); Inset * inset = new InsetFloatList(ev.argument);
if (!insertInset(inset, tclass.defaultLayoutName())) if (!insertInset(inset, tclass.defaultLayoutName()))
delete inset; delete inset;
} else { } else {
lyxerr << "Non-existent float type: " lyxerr << "Non-existent float type: "
<< argument << endl; << ev.argument << endl;
} }
break; break;
case LFUN_THESAURUS_ENTRY: case LFUN_THESAURUS_ENTRY:
{ {
string arg = argument; string arg = ev.argument;
if (arg.empty()) { if (arg.empty()) {
arg = bv_->getLyXText()->selectionAsString(buffer_, arg = bv_->getLyXText()->selectionAsString(buffer_,
@ -3105,7 +3100,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
case LFUN_SELFINSERT: case LFUN_SELFINSERT:
{ {
if (argument.empty()) break; if (ev.argument.empty()) break;
/* Automatically delete the currently selected /* Automatically delete the currently selected
* text and replace it with what is being * text and replace it with what is being
@ -3129,8 +3124,8 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
beforeChange(lt); beforeChange(lt);
LyXFont const old_font(lt->real_current_font); LyXFont const old_font(lt->real_current_font);
string::const_iterator cit = argument.begin(); string::const_iterator cit = ev.argument.begin();
string::const_iterator end = argument.end(); string::const_iterator end = ev.argument.end();
for (; cit != end; ++cit) { for (; cit != end; ++cit) {
owner_->getIntl()->getTransManager(). owner_->getIntl()->getTransManager().
TranslateAndInsert(*cit, lt); TranslateAndInsert(*cit, lt);
@ -3158,8 +3153,8 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
struct tm * now_tm = localtime(&now_time_t); struct tm * now_tm = localtime(&now_time_t);
setlocale(LC_TIME, ""); setlocale(LC_TIME, "");
string arg; string arg;
if (!argument.empty()) if (!ev.argument.empty())
arg = argument; arg = ev.argument;
else else
arg = lyxrc.date_insert_format; arg = lyxrc.date_insert_format;
char datetmp[32]; char datetmp[32];
@ -3265,7 +3260,8 @@ void BufferView::Pimpl::smartQuote()
if (style->pass_thru || if (style->pass_thru ||
(!insertInset(new InsetQuotes(c, bv_->buffer()->params)))) (!insertInset(new InsetQuotes(c, bv_->buffer()->params))))
bv_->owner()->getLyXFunc()->dispatch(LFUN_SELFINSERT, string("\"")); bv_->owner()->getLyXFunc()
->dispatch(FuncRequest(LFUN_SELFINSERT, "\""));
} }

View File

@ -11,7 +11,6 @@
#define BUFFERVIEW_PIMPL_H #define BUFFERVIEW_PIMPL_H
#include "BufferView.h" #include "BufferView.h"
#include "commandtags.h"
#include "frontends/Timeout.h" #include "frontends/Timeout.h"
#include "frontends/key_state.h" #include "frontends/key_state.h"
#include "frontends/mouse_state.h" #include "frontends/mouse_state.h"
@ -125,7 +124,7 @@ struct BufferView::Pimpl : public boost::signals::trackable {
/// ///
void updateInset(Inset * inset, bool mark_dirty); void updateInset(Inset * inset, bool mark_dirty);
/// ///
bool dispatch(kb_action action, string const & argument); bool dispatch(FuncRequest const & ev);
private: private:
/** /**
* Return the on-screen dimensions of the inset at the cursor. * Return the on-screen dimensions of the inset at the cursor.

View File

@ -1,3 +1,16 @@
2002-08-07 André Pönitz <poenitz@gmx.net>
* funcrequest.h: new class to wrap a kb_action and its argument
* BufferView.[Ch]:
* BufferView_pimpl[Ch]:
* LaTeX.C:
* LyXAction.[Ch]:
* lyxfunc.[Ch]:
* lyxrc.C: subsequent changes
2002-08-07 John Levon <levon@movementarian.org> 2002-08-07 John Levon <levon@movementarian.org>
* BufferView_pimpl.C (redoCurrentBuffer): fix screen update when * BufferView_pimpl.C (redoCurrentBuffer): fix screen update when

View File

@ -22,6 +22,7 @@
#include "gettext.h" #include "gettext.h"
#include "lyxfunc.h" #include "lyxfunc.h"
#include "debug.h" #include "debug.h"
#include "funcrequest.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/FileInfo.h" #include "support/FileInfo.h"
#include "support/lstrings.h" #include "support/lstrings.h"
@ -197,7 +198,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
if (lfun) { if (lfun) {
ostringstream str; ostringstream str;
str << _("LaTeX run number") << ' ' << count; str << _("LaTeX run number") << ' ' << count;
lfun->dispatch(LFUN_MESSAGE, str.str().c_str(), false); lfun->dispatch(FuncRequest(LFUN_MESSAGE, str.str().c_str()));
} }
this->operator()(); this->operator()();
@ -233,7 +234,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
// no checks for now // no checks for now
lyxerr[Debug::LATEX] << "Running MakeIndex." << endl; lyxerr[Debug::LATEX] << "Running MakeIndex." << endl;
if (lfun) { if (lfun) {
lfun->dispatch(LFUN_MESSAGE, _("Running MakeIndex."), false); lfun->dispatch(FuncRequest(LFUN_MESSAGE, _("Running MakeIndex.")));
} }
rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx"))); rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx")));
@ -248,7 +249,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
// no checks for now // no checks for now
lyxerr[Debug::LATEX] << "Running BibTeX." << endl; lyxerr[Debug::LATEX] << "Running BibTeX." << endl;
if (lfun) { if (lfun) {
lfun->dispatch(LFUN_MESSAGE, _("Running BibTeX."), false); lfun->dispatch(FuncRequest(LFUN_MESSAGE, _("Running BibTeX.")));
} }
updateBibtexDependencies(head, bibtex_info); updateBibtexDependencies(head, bibtex_info);
@ -283,7 +284,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
ostringstream str; ostringstream str;
str << _("LaTeX run number") << ' ' << count; str << _("LaTeX run number") << ' ' << count;
// check lyxstring string stream and gcc 3.1 before fixing // check lyxstring string stream and gcc 3.1 before fixing
lfun->dispatch(LFUN_MESSAGE, str.str().c_str(), false); lfun->dispatch(FuncRequest(LFUN_MESSAGE, str.str().c_str()));
} }
this->operator()(); this->operator()();
@ -313,7 +314,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
// no checks for now // no checks for now
lyxerr[Debug::LATEX] << "Running MakeIndex." << endl; lyxerr[Debug::LATEX] << "Running MakeIndex." << endl;
if (lfun) { if (lfun) {
lfun->dispatch(LFUN_MESSAGE, _("Running MakeIndex."), false); lfun->dispatch(FuncRequest(LFUN_MESSAGE, _("Running MakeIndex.")));
} }
rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx"))); rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx")));
@ -339,7 +340,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
if (lfun) { if (lfun) {
ostringstream str; ostringstream str;
str << _("LaTeX run number") << ' ' << count; str << _("LaTeX run number") << ' ' << count;
lfun->dispatch(LFUN_MESSAGE, str.str().c_str(), false); lfun->dispatch(FuncRequest(LFUN_MESSAGE, str.str().c_str()));
} }
this->operator()(); this->operator()();

View File

@ -74,14 +74,14 @@ void LyXAction::init()
static bool init; static bool init;
if (init) return; if (init) return;
struct lfun_item { struct ev_item {
kb_action action; kb_action action;
char const * name; char const * name;
char const * helpText; char const * helpText;
unsigned int attrib; unsigned int attrib;
}; };
lfun_item items[] = { ev_item items[] = {
{ LFUN_ACUTE, "accent-acute", "", Noop }, { LFUN_ACUTE, "accent-acute", "", Noop },
{ LFUN_BREVE, "accent-breve", "", Noop }, { LFUN_BREVE, "accent-breve", "", Noop },
{ LFUN_CARON, "accent-caron", "", Noop }, { LFUN_CARON, "accent-caron", "", Noop },
@ -483,10 +483,7 @@ int LyXAction::getPseudoAction(kb_action action, string const & arg) const
static unsigned int pseudo_counter = LFUN_LASTACTION; static unsigned int pseudo_counter = LFUN_LASTACTION;
// Create new pseudo action. // Create new pseudo action.
pseudo_func tmp_p; lyx_pseudo_map[++pseudo_counter] = FuncRequest(action, arg);
tmp_p.action = action;
tmp_p.arg = arg;
lyx_pseudo_map[++pseudo_counter] = tmp_p;
// First ensure that the action is in lyx_arg_map; // First ensure that the action is in lyx_arg_map;
lyx_arg_map[action]; lyx_arg_map[action];
@ -517,8 +514,8 @@ kb_action LyXAction::retrieveActionArg(int pseudo, string & arg) const
if (pit != lyx_pseudo_map.end()) { if (pit != lyx_pseudo_map.end()) {
lyxerr[Debug::ACTION] << "Found the pseudoaction: [" lyxerr[Debug::ACTION] << "Found the pseudoaction: ["
<< pit->second.action << '|' << pit->second.action << '|'
<< pit->second.arg << "]\n"; << pit->second.argument << "]\n";
arg = pit->second.arg; arg = pit->second.argument;
return pit->second.action; return pit->second.action;
} else { } else {
lyxerr << "Lyx Error: Unrecognized pseudo-action " lyxerr << "Lyx Error: Unrecognized pseudo-action "

View File

@ -8,12 +8,12 @@
#include <map> #include <map>
#include "commandtags.h" #include "funcrequest.h"
#include "LString.h"
#include <boost/utility.hpp> #include <boost/utility.hpp>
/** This class encapsulates LyX action and user command operations. /** This class encapsulates LyX action and user command operations.
*/ */
class LyXAction : boost::noncopyable { class LyXAction : boost::noncopyable {
private: private:
/// ///
@ -26,20 +26,13 @@ private:
string helpText; string helpText;
}; };
///
struct pseudo_func {
///
kb_action action;
///
string arg;
};
public: public:
/// ///
typedef std::map<string, kb_action> func_map; typedef std::map<string, kb_action> func_map;
/// ///
typedef std::map<kb_action, func_info> info_map; typedef std::map<kb_action, func_info> info_map;
/// ///
typedef std::map<unsigned int, pseudo_func> pseudo_map; typedef std::map<unsigned int, FuncRequest> pseudo_map;
/// ///
typedef std::map<string, unsigned int> arg_item; typedef std::map<string, unsigned int> arg_item;
/// ///

View File

@ -18,10 +18,11 @@
*/ */
class WordLangTuple { class WordLangTuple {
public: public:
WordLangTuple() {}; WordLangTuple() {}
WordLangTuple(string const & w, string const & c) WordLangTuple(string const & w, string const & c)
: word_(w), code_(c) {} : word_(w), code_(c)
{}
/// return the word /// return the word
string const word() const { string const word() const {

View File

@ -5,7 +5,7 @@
* This is basically the Communicator class from the lyx cvs module all * This is basically the Communicator class from the lyx cvs module all
* over again. * over again.
* *
* Eventually, we will switch back to the XTL+LyXFunc combination that * FuncRequestually, we will switch back to the XTL+LyXFunc combination that
* worked so nicely on a very small number of compilers and systems (when * worked so nicely on a very small number of compilers and systems (when
* most systems can support those required features). * most systems can support those required features).
* *
@ -42,7 +42,7 @@ class BufferParams;
elaborate. This is basically the Communicator class from the lyx cvs module elaborate. This is basically the Communicator class from the lyx cvs module
all over again. all over again.
Eventually, we will switch back to the XTL+LyXFunc combination that FuncRequestually, we will switch back to the XTL+LyXFunc combination that
worked so nicely on a very small number of compilers and systems. worked so nicely on a very small number of compilers and systems.
See the "dialogbase" branch of lyx-devel cvs module for xtl implementation. See the "dialogbase" branch of lyx-devel cvs module for xtl implementation.
*/ */

View File

@ -123,7 +123,7 @@ public:
void resetAutosaveTimer(); void resetAutosaveTimer();
protected: protected:
/// view of a buffer. Eventually there will be several. /// view of a buffer. FuncRequestually there will be several.
boost::shared_ptr<BufferView> bufferview_; boost::shared_ptr<BufferView> bufferview_;
/// view's menubar /// view's menubar

View File

@ -25,6 +25,8 @@
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
#include "lyxfunc.h" #include "lyxfunc.h"
#include "BufferView.h" #include "BufferView.h"
#include "funcrequest.h"
ControlCommand::ControlCommand(LyXView & lv, Dialogs & d, kb_action ac) ControlCommand::ControlCommand(LyXView & lv, Dialogs & d, kb_action ac)
: ControlInset<InsetCommand, InsetCommandParams>(lv, d), : ControlInset<InsetCommand, InsetCommandParams>(lv, d),
@ -55,6 +57,7 @@ void ControlCommand::applyParamsToInset()
void ControlCommand::applyParamsNoInset() void ControlCommand::applyParamsNoInset()
{ {
if (action_ == LFUN_NOACTION) return; if (action_ == LFUN_NOACTION)
lv_.getLyXFunc()->dispatch(action_, params().getAsString()); return;
lv_.getLyXFunc()->dispatch(FuncRequest(action_, params().getAsString()));
} }

View File

@ -18,6 +18,7 @@
#include "BufferView.h" #include "BufferView.h"
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
#include "lyxfunc.h" #include "lyxfunc.h"
#include "funcrequest.h"
#include "support/forkedcontr.h" #include "support/forkedcontr.h"
#include "support/lstrings.h" #include "support/lstrings.h"
@ -65,7 +66,7 @@ void ControlForks::apply()
for (vector<string>::const_iterator it = pids_.begin(); for (vector<string>::const_iterator it = pids_.begin();
it != pids_.end(); ++it) { it != pids_.end(); ++it) {
lv_.getLyXFunc()->dispatch(LFUN_FORKS_KILL, *it); lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_FORKS_KILL, *it));
} }
pids_.clear(); pids_.clear();

View File

@ -21,6 +21,7 @@
#include "gettext.h" #include "gettext.h"
#include "helper_funcs.h" #include "helper_funcs.h"
#include "lyxrc.h" #include "lyxrc.h"
#include "funcrequest.h"
#include "support/filetools.h" #include "support/filetools.h"
@ -72,15 +73,16 @@ string const ControlInclude::Browse(string const & in_name, Type in_type)
void ControlInclude::load(string const & file) void ControlInclude::load(string const & file)
{ {
lv_.getLyXFunc()->dispatch(LFUN_CHILDOPEN, file); lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_CHILDOPEN, file));
} }
bool ControlInclude::fileExists(string const & file) bool ControlInclude::fileExists(string const & file)
{ {
string const fileWithAbsPath = MakeAbsPath(file, OnlyPath(params().masterFilename_)); string const fileWithAbsPath
= MakeAbsPath(file, OnlyPath(params().masterFilename_));
if (params().noload){ if (params().noload) {
if (prefixIs(file, "../") || prefixIs(file, "/")) if (prefixIs(file, "../") || prefixIs(file, "/"))
Alert::alert(_("Warning!"), Alert::alert(_("Warning!"),
@ -92,7 +94,6 @@ bool ControlInclude::fileExists(string const & file)
return true; return true;
else else
Alert::alert(_("Warning!"), Alert::alert(_("Warning!"), _("Specified file doesn't exist"));
_("Specified file doesn't exist"));
return false; return false;
} }

View File

@ -20,6 +20,7 @@
#include "ControlRef.h" #include "ControlRef.h"
#include "lyxfunc.h" #include "lyxfunc.h"
#include "bufferlist.h" #include "bufferlist.h"
#include "funcrequest.h"
#include "support/filetools.h" // MakeAbsPath, MakeDisplayPath #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
@ -44,14 +45,14 @@ vector<string> const ControlRef::getLabelList(string const & name) const
void ControlRef::gotoRef(string const & ref) const void ControlRef::gotoRef(string const & ref) const
{ {
lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_SAVE, "0", false); lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"), false);
lv_.getLyXFunc()->dispatch(LFUN_REF_GOTO, ref); lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_REF_GOTO, ref));
} }
void ControlRef::gotoBookmark() const void ControlRef::gotoBookmark() const
{ {
lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_GOTO, "0", false); lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"), false);
} }

View File

@ -21,6 +21,7 @@
#include "ButtonControllerBase.h" #include "ButtonControllerBase.h"
#include "BufferView.h" #include "BufferView.h"
#include "lyxfunc.h" #include "lyxfunc.h"
#include "funcrequest.h"
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
@ -34,7 +35,7 @@ ControlTabularCreate::ControlTabularCreate(LyXView & lv, Dialogs & d)
ControlTabularCreate::rowsCols & ControlTabularCreate::params() ControlTabularCreate::rowsCols & ControlTabularCreate::params()
{ {
return params_; return params_;
} }
@ -51,7 +52,6 @@ void ControlTabularCreate::apply()
view().apply(); view().apply();
string const val(tostr(params().first) + " " + tostr(params().second)); string const val = tostr(params().first) + " " + tostr(params().second);
lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_TABULAR_INSERT, val));
lv_.getLyXFunc()->dispatch(LFUN_TABULAR_INSERT, val);
} }

View File

@ -15,12 +15,15 @@
#include "QtLyXView.h" #include "QtLyXView.h"
#include "debug.h" #include "debug.h"
#include "funcrequest.h"
#include "FileDialog_private.h" #include "FileDialog_private.h"
LyXFileDialog::LyXFileDialog(LyXView * lv, kb_action a, string const & p, string const & m, string const & t) LyXFileDialog::LyXFileDialog(LyXView * lv, kb_action a,
: QFileDialog(p.c_str(), m.c_str(), qApp->mainWidget(), t.c_str(), a == LFUN_SELECT_FILE_SYNC), string const & p, string const & m, string const & t)
lv_(lv), action_(a) : QFileDialog(p.c_str(), m.c_str(), qApp->mainWidget(), t.c_str(),
a == LFUN_SELECT_FILE_SYNC),
lv_(lv), action_(a)
{ {
setCaption(t.c_str()); setCaption(t.c_str());
} }
@ -33,9 +36,10 @@ void LyXFileDialog::done(int what)
if (action_ == LFUN_SELECT_FILE_SYNC) { if (action_ == LFUN_SELECT_FILE_SYNC) {
QDialog::done(what); QDialog::done(what);
return; return;
} else if (what == QDialog::Accepted) {
lv_->getLyXFunc()->dispatch(action_, selectedFile().data(), false);
} }
if (what == QDialog::Accepted)
lv_->getLyXFunc()->dispatch(FuncRequest(action_, selectedFile().data()));
delete this; delete this;
} }

View File

@ -148,7 +148,7 @@ void Toolbar::Pimpl::changed_layout(string const & sel)
for (LyXTextClass::const_iterator cit = tc.begin(); for (LyXTextClass::const_iterator cit = tc.begin();
cit != end; ++cit) { cit != end; ++cit) {
if (_((*cit)->name()) == sel) { if (_((*cit)->name()) == sel) {
owner_->getLyXFunc()->dispatch(LFUN_LAYOUT, (*cit)->name()); owner_->getLyXFunc()->dispatch(FuncRequest(LFUN_LAYOUT, (*cit)->name()));
return; return;
} }
} }

View File

@ -23,6 +23,7 @@
#include "debug.h" #include "debug.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "lyxfunc.h" #include "lyxfunc.h"
#include "funcrequest.h"
#include FORMS_H_LOCATION #include FORMS_H_LOCATION
#include "delim.xbm" #include "delim.xbm"
@ -31,7 +32,8 @@
static int const delim_rversion[] = { static int const delim_rversion[] = {
1,1,3,3,4,5,7,7,9,9,10,11, 1,1,3,3,4,5,7,7,9,9,10,11,
13,13,14,15,16,17,19,19,20,21,22,23 }; 13,13,14,15,16,17,19,19,20,21,22,23
};
static char const * delim_values[] = { static char const * delim_values[] = {
"(", ")", "lceil", "rceil", "uparrow", "Uparrow", "(", ")", "lceil", "rceil", "uparrow", "Uparrow",
@ -91,9 +93,11 @@ void FormMathsDelim::apply()
ostringstream ost; ostringstream ost;
ost << delim_values[left] << ' ' << delim_values[right]; ost << delim_values[left] << ' ' << delim_values[right];
lv_->getLyXFunc()->dispatch(LFUN_MATH_DELIM, ost.str().c_str(), false); lv_->getLyXFunc()->
dispatch(FuncRequest(LFUN_MATH_DELIM, ost.str().c_str()), false);
} }
bool FormMathsDelim::input(FL_OBJECT *, long) bool FormMathsDelim::input(FL_OBJECT *, long)
{ {
int left = int(dialog_->radio_left->u_ldata); int left = int(dialog_->radio_left->u_ldata);

View File

@ -23,6 +23,7 @@
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
#include "Lsstream.h" #include "Lsstream.h"
#include "lyxfunc.h" #include "lyxfunc.h"
#include "funcrequest.h"
#include "support/LAssert.h" #include "support/LAssert.h"
#include "support/lyxalgo.h" // lyx::count #include "support/lyxalgo.h" // lyx::count
#include FORMS_H_LOCATION #include FORMS_H_LOCATION
@ -99,9 +100,11 @@ void FormMathsMatrix::apply()
ostringstream ost; ostringstream ost;
ost << nx << ' ' << ny << ' ' << c << ' ' << sh; ost << nx << ' ' << ny << ' ' << c << ' ' << sh;
lv_->getLyXFunc()->dispatch(LFUN_INSERT_MATRIX, ost.str().c_str(), false); lv_->getLyXFunc()->
dispatch(FuncRequest(LFUN_INSERT_MATRIX, ost.str().c_str()));
} }
bool FormMathsMatrix::input(FL_OBJECT * ob, long) bool FormMathsMatrix::input(FL_OBJECT * ob, long)
{ {
if (ob == dialog_->choice_valign || if (ob == dialog_->choice_valign ||
@ -123,9 +126,9 @@ int FormMathsMatrix::AlignFilter(char const * cur, int c)
{ {
size_t len = strlen(cur); size_t len = strlen(cur);
int const n = int(fl_get_slider_value(dialog_->slider_columns) + 0.5) - int const n = int(fl_get_slider_value(dialog_->slider_columns) + 0.5)
int(len) + - int(len)
int(lyx::count(cur, cur + len, '|')); + int(lyx::count(cur, cur + len, '|'));
if (n < 0) if (n < 0)
return FL_INVALID; return FL_INVALID;

View File

@ -22,6 +22,7 @@
#include "MathsSymbols.h" #include "MathsSymbols.h"
#include "debug.h" #include "debug.h"
#include "lyxfunc.h" #include "lyxfunc.h"
#include "funcrequest.h"
#include "forms/form_maths_deco.h" #include "forms/form_maths_deco.h"
#include "forms/form_maths_delim.h" #include "forms/form_maths_delim.h"
@ -381,9 +382,9 @@ bool FormMathsPanel::input(FL_OBJECT *, long data)
void FormMathsPanel::insertSymbol(string const & sym, bool bs) const void FormMathsPanel::insertSymbol(string const & sym, bool bs) const
{ {
if (bs) if (bs)
lv_->getLyXFunc()->dispatch(LFUN_INSERT_MATH, '\\' + sym); lv_->getLyXFunc()->dispatch(FuncRequest(LFUN_INSERT_MATH, '\\' + sym));
else else
lv_->getLyXFunc()->dispatch(LFUN_INSERT_MATH, sym); lv_->getLyXFunc()->dispatch(FuncRequest(LFUN_INSERT_MATH, sym));
} }

View File

@ -27,6 +27,7 @@
#include "lyxrc.h" #include "lyxrc.h"
#include "LColor.h" #include "LColor.h"
#include "Lsstream.h" #include "Lsstream.h"
#include "funcrequest.h"
#include "combox.h" #include "combox.h"
#include "Color.h" #include "Color.h"
@ -436,7 +437,7 @@ void FormPreferences::Colors::apply()
string const s = lcolor.getLyXName(lc) + string(" ") + string const s = lcolor.getLyXName(lc) + string(" ") +
hexname; hexname;
parent_.lv_->getLyXFunc()->dispatch(LFUN_SET_COLOR, s); parent_.lv_->getLyXFunc()->dispatch(FuncRequest(LFUN_SET_COLOR, s));
} }
} }
} }
@ -488,6 +489,7 @@ void FormPreferences::Colors::build()
setPrehandler(dialog_->radio_hsv); setPrehandler(dialog_->radio_hsv);
} }
string const string const
FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
{ {
@ -682,7 +684,8 @@ void FormPreferences::Colors::InputRGB()
void FormPreferences::Colors::LoadBrowserLyX() void FormPreferences::Colors::LoadBrowserLyX()
{ {
if (!dialog_->browser_lyx_objs->visible) return; if (!dialog_->browser_lyx_objs->visible)
return;
// First, define the modifiable xforms colors // First, define the modifiable xforms colors
xformsColorDB.clear(); xformsColorDB.clear();
@ -742,7 +745,7 @@ void FormPreferences::Colors::LoadBrowserLyX()
string const arg = lcolor.getLyXName(lc) + " black"; string const arg = lcolor.getLyXName(lc) + " black";
parent_.lv_->getLyXFunc()-> parent_.lv_->getLyXFunc()->
dispatch(LFUN_SET_COLOR, arg); dispatch(FuncRequest(LFUN_SET_COLOR, arg));
continue; continue;
} }

View File

@ -23,13 +23,14 @@
#include "FuncStatus.h" #include "FuncStatus.h"
#include "BufferView.h" #include "BufferView.h"
#include "buffer.h" #include "buffer.h"
#include "LyXAction.h" #include "funcrequest.h"
#include "MathsSymbols.h" #include "MathsSymbols.h"
#include "gettext.h" #include "gettext.h"
#include "Tooltips.h" #include "Tooltips.h"
#include FORMS_H_LOCATION #include FORMS_H_LOCATION
#include "combox.h" #include "combox.h"
#include "ToolbarDefaults.h" #include "ToolbarDefaults.h"
#include "LyXAction.h"
#include "support/LAssert.h" #include "support/LAssert.h"
#include "support/filetools.h" #include "support/filetools.h"
@ -155,9 +156,7 @@ void Toolbar::Pimpl::update()
// this one is not "C" because combox callbacks are really C++ %-| // this one is not "C" because combox callbacks are really C++ %-|
void Toolbar::Pimpl::layoutSelectedCB(int, void * arg, Combox *) void Toolbar::Pimpl::layoutSelectedCB(int, void * arg, Combox *)
{ {
Toolbar::Pimpl * tb = reinterpret_cast<Toolbar::Pimpl *>(arg); reinterpret_cast<Toolbar::Pimpl *>(arg)->layoutSelected();
tb->layoutSelected();
} }
@ -171,7 +170,7 @@ void Toolbar::Pimpl::layoutSelected()
for (LyXTextClass::const_iterator cit = tc.begin(); for (LyXTextClass::const_iterator cit = tc.begin();
cit != end; ++cit) { cit != end; ++cit) {
if (_((*cit)->name()) == layoutguiname) { if (_((*cit)->name()) == layoutguiname) {
owner_->getLyXFunc()->dispatch(LFUN_LAYOUT, (*cit)->name()); owner_->getLyXFunc()->dispatch(FuncRequest(LFUN_LAYOUT, (*cit)->name()));
return; return;
} }
} }

30
src/funcrequest.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef FUNCREQUEST_H
#define FUNCREQUEST_H
#include "commandtags.h"
#include "LString.h"
/** This class encapsulates LyX action and arguemnt
* in order to passs it around easily.
*/
struct FuncRequest {
///
FuncRequest()
: action(LFUN_UNKNOWN_ACTION)
{}
///
FuncRequest(kb_action act)
: action(act)
{}
///
FuncRequest(kb_action act, string const & arg)
: action(act), argument(arg)
{}
///
kb_action action;
///
string argument;
};
#endif

View File

@ -1,3 +1,14 @@
2002-08-07 André Pönitz <poenitz@gmx.net>
* inset.[Ch]:
* insetcollapsable.[Ch]:
* insetert.[Ch]:
* insetparent.[Ch]:
* insetref.[Ch]:
* insettabular.[Ch]:
* insettext.[Ch]: change (kb_action, arg) pair into a FuncRequest
2002-08-06 John Levon <levon@movementarian.org> 2002-08-06 John Levon <levon@movementarian.org>
* inset.h: * inset.h:

View File

@ -20,7 +20,7 @@
#include "support/lstrings.h" #include "support/lstrings.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include "frontends/mouse_state.h" #include "frontends/mouse_state.h"
#include "commandtags.h" #include "funcrequest.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "gettext.h" #include "gettext.h"
#include "lyxfont.h" #include "lyxfont.h"
@ -301,15 +301,14 @@ void UpdatableInset::scroll(BufferView * bv, int offset) const
/// An updatable inset could handle lyx editing commands /// An updatable inset could handle lyx editing commands
UpdatableInset::RESULT UpdatableInset::RESULT
UpdatableInset::localDispatch(BufferView * bv, UpdatableInset::localDispatch(BufferView * bv, FuncRequest const & ev)
kb_action action, string const & arg)
{ {
if (!arg.empty() && (action==LFUN_SCROLL_INSET)) { if (!ev.argument.empty() && ev.action == LFUN_SCROLL_INSET) {
if (arg.find('.') != arg.npos) { if (ev.argument.find('.') != ev.argument.npos) {
float const xx = static_cast<float>(strToDbl(arg)); float const xx = static_cast<float>(strToDbl(ev.argument));
scroll(bv, xx); scroll(bv, xx);
} else { } else {
int const xx = strToInt(arg); int const xx = strToInt(ev.argument);
scroll(bv, xx); scroll(bv, xx);
} }
bv->updateInset(this, false); bv->updateInset(this, false);

View File

@ -17,10 +17,9 @@
#include <vector> #include <vector>
#include "LString.h" #include "LString.h"
#include "commandtags.h" #include "LColor.h"
#include "frontends/mouse_state.h" #include "frontends/mouse_state.h"
#include "WordLangTuple.h" #include "WordLangTuple.h"
#include "LColor.h"
class LyXFont; class LyXFont;
class BufferView; class BufferView;
@ -30,6 +29,7 @@ class LyXText;
class LyXLex; class LyXLex;
class Paragraph; class Paragraph;
class LyXCursor; class LyXCursor;
class FuncRequest;
struct LaTeXFeatures; struct LaTeXFeatures;
@ -512,7 +512,7 @@ public:
bool /*lr*/ = false) bool /*lr*/ = false)
{ return false; } { return false; }
/// An updatable inset could handle lyx editing commands /// An updatable inset could handle lyx editing commands
virtual RESULT localDispatch(BufferView *, kb_action, string const &); virtual RESULT localDispatch(BufferView *, FuncRequest const & ev);
/// ///
bool isCursorVisible() const { return cursor_visible_; } bool isCursorVisible() const { return cursor_visible_; }
/// ///

View File

@ -437,10 +437,9 @@ void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
UpdatableInset::RESULT UpdatableInset::RESULT
InsetCollapsable::localDispatch(BufferView * bv, kb_action action, InsetCollapsable::localDispatch(BufferView * bv, FuncRequest const & ev)
string const & arg)
{ {
UpdatableInset::RESULT result = inset.localDispatch(bv, action, arg); UpdatableInset::RESULT result = inset.localDispatch(bv, ev);
if (result >= FINISHED) if (result >= FINISHED)
bv->unlockInset(this); bv->unlockInset(this);
first_after_edit = false; first_after_edit = false;

View File

@ -95,8 +95,7 @@ public:
/// ///
void insetMotionNotify(BufferView *, int, int, mouse_button::state); void insetMotionNotify(BufferView *, int, int, mouse_button::state);
/// ///
UpdatableInset::RESULT localDispatch(BufferView *, kb_action, UpdatableInset::RESULT localDispatch(BufferView *, FuncRequest const &);
string const &);
/// ///
int latex(Buffer const *, std::ostream &, int latex(Buffer const *, std::ostream &,
bool fragile, bool free_spc) const; bool fragile, bool free_spc) const;

View File

@ -21,6 +21,7 @@
#include "BufferView.h" #include "BufferView.h"
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
#include "lyxtext.h" #include "lyxtext.h"
#include "funcrequest.h"
#include "debug.h" #include "debug.h"
#include "lyxrow.h" #include "lyxrow.h"
#include "lyxlex.h" #include "lyxlex.h"
@ -444,7 +445,7 @@ int InsetERT::docbook(Buffer const *, ostream & os, bool) const
UpdatableInset::RESULT UpdatableInset::RESULT
InsetERT::localDispatch(BufferView * bv, kb_action action, string const & arg) InsetERT::localDispatch(BufferView * bv, FuncRequest const & ev)
{ {
UpdatableInset::RESULT result = DISPATCHED_NOUPDATE; UpdatableInset::RESULT result = DISPATCHED_NOUPDATE;
@ -452,14 +453,14 @@ InsetERT::localDispatch(BufferView * bv, kb_action action, string const & arg)
set_latex_font(bv); set_latex_font(bv);
} }
switch (action) { switch (ev.action) {
case LFUN_LAYOUT: case LFUN_LAYOUT:
bv->owner()->setLayout(inset.paragraph()->layout()->name()); bv->owner()->setLayout(inset.paragraph()->layout()->name());
break; break;
default: default:
result = InsetCollapsable::localDispatch(bv, action, arg); result = InsetCollapsable::localDispatch(bv, ev);
} }
switch (action) { switch (ev.action) {
case LFUN_BREAKPARAGRAPH: case LFUN_BREAKPARAGRAPH:
case LFUN_BREAKPARAGRAPHKEEPLAYOUT: case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
case LFUN_BACKSPACE: case LFUN_BACKSPACE:

View File

@ -94,8 +94,7 @@ public:
/// ///
void validate(LaTeXFeatures &) const {} void validate(LaTeXFeatures &) const {}
/// ///
UpdatableInset::RESULT localDispatch(BufferView *, kb_action, UpdatableInset::RESULT localDispatch(BufferView *, FuncRequest const &);
string const &);
/// ///
bool checkInsertChar(LyXFont &); bool checkInsertChar(LyXFont &);
/// ///

View File

@ -22,7 +22,7 @@
#include "BufferView.h" #include "BufferView.h"
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
#include "support/LOstream.h" #include "support/LOstream.h"
#include "commandtags.h" #include "funcrequest.h"
#include "buffer.h" #include "buffer.h"
#include "gettext.h" #include "gettext.h"
#include "lyxfunc.h" #include "lyxfunc.h"
@ -47,7 +47,7 @@ string const InsetParent::getScreenLabel(Buffer const *) const
void InsetParent::edit(BufferView * bv, int, int, mouse_button::state) void InsetParent::edit(BufferView * bv, int, int, mouse_button::state)
{ {
bv->owner()->getLyXFunc()-> bv->owner()->getLyXFunc()->
dispatch(LFUN_CHILDOPEN, getContents()); dispatch(FuncRequest(LFUN_CHILDOPEN, getContents()));
} }

View File

@ -6,7 +6,7 @@
#include "insetref.h" #include "insetref.h"
#include "buffer.h" #include "buffer.h"
#include "commandtags.h" #include "funcrequest.h"
#include "debug.h" #include "debug.h"
#include "gettext.h" #include "gettext.h"
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
@ -22,20 +22,20 @@ InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf, bool)
: InsetCommand(p), isLatex(buf.isLatex()) : InsetCommand(p), isLatex(buf.isLatex())
{} {}
void InsetRef::edit(BufferView * bv, int, int, mouse_button::state button) void InsetRef::edit(BufferView * bv, int, int, mouse_button::state button)
{ {
// Eventually trigger dialog with button 3 not 1 // FuncRequestually trigger dialog with button 3 not 1
if (button == mouse_button::button3) if (button == mouse_button::button3)
bv->owner()->getLyXFunc()-> bv->owner()->getLyXFunc()->
dispatch(LFUN_REF_GOTO, getContents()); dispatch(FuncRequest(LFUN_REF_GOTO, getContents()));
else if (button == mouse_button::button1) else if (button == mouse_button::button1)
bv->owner()->getDialogs()->showRef(this); bv->owner()->getDialogs()->showRef(this);
} }
void InsetRef::edit(BufferView *, bool) void InsetRef::edit(BufferView *, bool)
{ {}
}
string const InsetRef::getScreenLabel(Buffer const *) const string const InsetRef::getScreenLabel(Buffer const *) const

View File

@ -35,6 +35,7 @@
#include "lyxlength.h" #include "lyxlength.h"
#include "ParagraphParameters.h" #include "ParagraphParameters.h"
#include "lyxlex.h" #include "lyxlex.h"
#include "funcrequest.h"
#include "frontends/Dialogs.h" #include "frontends/Dialogs.h"
#include "frontends/Alert.h" #include "frontends/Alert.h"
@ -820,7 +821,7 @@ void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, mouse_button:
the_locking_inset = 0; the_locking_inset = 0;
} }
if (button == mouse_button::button2) { if (button == mouse_button::button2) {
localDispatch(bv, LFUN_PASTESELECTION, "paragraph"); localDispatch(bv, FuncRequest(LFUN_PASTESELECTION, "paragraph"));
return; return;
} }
if (inset_hit && bv->theLockingInset()) { if (inset_hit && bv->theLockingInset()) {
@ -877,20 +878,19 @@ void InsetTabular::insetMotionNotify(BufferView * bv, int x, int y, mouse_button
UpdatableInset::RESULT UpdatableInset::RESULT
InsetTabular::localDispatch(BufferView * bv, kb_action action, InsetTabular::localDispatch(BufferView * bv, FuncRequest const & ev)
string const & arg)
{ {
// We need to save the value of the_locking_inset as the call to // We need to save the value of the_locking_inset as the call to
// the_locking_inset->LocalDispatch might unlock it. // the_locking_inset->LocalDispatch might unlock it.
old_locking_inset = the_locking_inset; old_locking_inset = the_locking_inset;
UpdatableInset::RESULT result = UpdatableInset::RESULT result =
UpdatableInset::localDispatch(bv, action, arg); UpdatableInset::localDispatch(bv, ev);
if (result == DISPATCHED || result == DISPATCHED_NOUPDATE) { if (result == DISPATCHED || result == DISPATCHED_NOUPDATE) {
resetPos(bv); resetPos(bv);
return result; return result;
} }
if ((action < 0) && arg.empty()) if (ev.action < 0 && ev.argument.empty())
return FINISHED; return FINISHED;
bool hs = hasSelection(); bool hs = hasSelection();
@ -899,12 +899,12 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action,
// this one have priority over the locked InsetText, if we're not already // this one have priority over the locked InsetText, if we're not already
// inside another tabular then that one get's priority! // inside another tabular then that one get's priority!
if (getFirstLockingInsetOfType(Inset::TABULAR_CODE) == this) { if (getFirstLockingInsetOfType(Inset::TABULAR_CODE) == this) {
switch (action) { switch (ev.action) {
case LFUN_SHIFT_TAB: case LFUN_SHIFT_TAB:
case LFUN_TAB: case LFUN_TAB:
hideInsetCursor(bv); hideInsetCursor(bv);
unlockInsetInInset(bv, the_locking_inset); unlockInsetInInset(bv, the_locking_inset);
if (action == LFUN_TAB) if (ev.action == LFUN_TAB)
moveNextCell(bv, old_locking_inset != 0); moveNextCell(bv, old_locking_inset != 0);
else else
movePrevCell(bv, old_locking_inset != 0); movePrevCell(bv, old_locking_inset != 0);
@ -922,8 +922,10 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action,
} }
} }
kb_action action = ev.action;
string arg = ev.argument;
if (the_locking_inset) { if (the_locking_inset) {
result = the_locking_inset->localDispatch(bv, action, arg); result = the_locking_inset->localDispatch(bv, ev);
if (result == DISPATCHED_NOUPDATE) { if (result == DISPATCHED_NOUPDATE) {
int sc = scroll(); int sc = scroll();
resetPos(bv); resetPos(bv);
@ -1248,7 +1250,7 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action,
case LFUN_DEFAULT: case LFUN_DEFAULT:
case LFUN_UNDERLINE: case LFUN_UNDERLINE:
case LFUN_FONT_SIZE: case LFUN_FONT_SIZE:
if (bv->dispatch(action, arg)) if (bv->dispatch(FuncRequest(action, arg)))
result = DISPATCHED; result = DISPATCHED;
break; break;
default: default:
@ -1263,7 +1265,7 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action,
if (activateCellInset(bv)) { if (activateCellInset(bv)) {
// reset need_update setted in above function! // reset need_update setted in above function!
need_update = NONE; need_update = NONE;
result = the_locking_inset->localDispatch(bv, action, arg); result = the_locking_inset->localDispatch(bv, FuncRequest(action, arg));
if ((result == UNDISPATCHED) || (result >= FINISHED)) { if ((result == UNDISPATCHED) || (result >= FINISHED)) {
unlockInsetInInset(bv, the_locking_inset); unlockInsetInInset(bv, the_locking_inset);
nodraw(false); nodraw(false);

View File

@ -142,8 +142,7 @@ public:
/// ///
void insetMotionNotify(BufferView *, int, int, mouse_button::state); void insetMotionNotify(BufferView *, int, int, mouse_button::state);
/// ///
UpdatableInset::RESULT localDispatch(BufferView *, kb_action, UpdatableInset::RESULT localDispatch(BufferView *, FuncRequest const &);
string const &);
/// ///
int latex(Buffer const *, std::ostream &, bool, bool) const; int latex(Buffer const *, std::ostream &, bool, bool) const;
/// ///

View File

@ -19,7 +19,6 @@
#include "lyxlex.h" #include "lyxlex.h"
#include "debug.h" #include "debug.h"
#include "lyxfont.h" #include "lyxfont.h"
#include "commandtags.h"
#include "buffer.h" #include "buffer.h"
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
#include "BufferView.h" #include "BufferView.h"
@ -40,6 +39,7 @@
#include "ParagraphParameters.h" #include "ParagraphParameters.h"
#include "undo_funcs.h" #include "undo_funcs.h"
#include "lyxfind.h" #include "lyxfind.h"
#include "funcrequest.h"
#include "frontends/Alert.h" #include "frontends/Alert.h"
#include "frontends/Dialogs.h" #include "frontends/Dialogs.h"
@ -1043,7 +1043,7 @@ void InsetText::insetButtonPress(BufferView * bv,
if (bv->theLockingInset()) { if (bv->theLockingInset()) {
if (isHighlyEditableInset(inset)) { if (isHighlyEditableInset(inset)) {
// We just have to lock the inset before calling a // We just have to lock the inset before calling a
// PressEvent on it! // PressFuncRequest on it!
UpdatableInset * uinset = static_cast<UpdatableInset*>(inset); UpdatableInset * uinset = static_cast<UpdatableInset*>(inset);
if (!bv->lockInset(uinset)) { if (!bv->lockInset(uinset)) {
lyxerr[Debug::INSETS] << "Cannot lock inset" << endl; lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
@ -1057,7 +1057,7 @@ void InsetText::insetButtonPress(BufferView * bv,
if (!inset) { // && (button == mouse_button::button2)) { if (!inset) { // && (button == mouse_button::button2)) {
bool paste_internally = false; bool paste_internally = false;
if ((button == mouse_button::button2) && getLyXText(bv)->selection.set()) { if ((button == mouse_button::button2) && getLyXText(bv)->selection.set()) {
localDispatch(bv, LFUN_COPY, ""); localDispatch(bv, FuncRequest(LFUN_COPY));
paste_internally = true; paste_internally = true;
} }
bool clear = false; bool clear = false;
@ -1096,10 +1096,9 @@ void InsetText::insetButtonPress(BufferView * bv,
// insert this // insert this
if (button == mouse_button::button2) { if (button == mouse_button::button2) {
if (paste_internally) if (paste_internally)
localDispatch(bv, LFUN_PASTE, ""); localDispatch(bv, FuncRequest(LFUN_PASTE));
else else
localDispatch(bv, LFUN_PASTESELECTION, localDispatch(bv, FuncRequest(LFUN_PASTESELECTION, "paragraph"));
"paragraph");
} }
} else { } else {
getLyXText(bv)->clearSelection(); getLyXText(bv)->clearSelection();
@ -1177,23 +1176,21 @@ void InsetText::insetMotionNotify(BufferView * bv, int x, int y, mouse_button::s
UpdatableInset::RESULT UpdatableInset::RESULT
InsetText::localDispatch(BufferView * bv, InsetText::localDispatch(BufferView * bv, FuncRequest const & ev)
kb_action action, string const & arg)
{ {
bool was_empty = par->size() == 0 && !par->next(); bool was_empty = par->size() == 0 && !par->next();
no_selection = false; no_selection = false;
UpdatableInset::RESULT UpdatableInset::RESULT
result= UpdatableInset::localDispatch(bv, action, arg); result= UpdatableInset::localDispatch(bv, ev);
if (result != UNDISPATCHED) { if (result != UNDISPATCHED)
return DISPATCHED; return DISPATCHED;
}
result = DISPATCHED; result = DISPATCHED;
if ((action < 0) && arg.empty()) if (ev.action < 0 && ev.argument.empty())
return FINISHED; return FINISHED;
if (the_locking_inset) { if (the_locking_inset) {
result = the_locking_inset->localDispatch(bv, action, arg); result = the_locking_inset->localDispatch(bv, ev);
if (result == DISPATCHED_NOUPDATE) if (result == DISPATCHED_NOUPDATE)
return result; return result;
else if (result == DISPATCHED) { else if (result == DISPATCHED) {
@ -1244,14 +1241,14 @@ InsetText::localDispatch(BufferView * bv,
} }
int updwhat = 0; int updwhat = 0;
int updflag = false; int updflag = false;
switch (action) { switch (ev.action) {
// Normal chars // Normal chars
case LFUN_SELFINSERT: case LFUN_SELFINSERT:
if (bv->buffer()->isReadonly()) { if (bv->buffer()->isReadonly()) {
// setErrorMessage(N_("Document is read only")); // setErrorMessage(N_("Document is read only"));
break; break;
} }
if (!arg.empty()) { if (!ev.argument.empty()) {
/* Automatically delete the currently selected /* Automatically delete the currently selected
* text and replace it with what is being * text and replace it with what is being
* typed in now. Depends on lyxrc settings * typed in now. Depends on lyxrc settings
@ -1267,9 +1264,9 @@ InsetText::localDispatch(BufferView * bv,
} }
} }
lt->clearSelection(); lt->clearSelection();
for (string::size_type i = 0; i < arg.length(); ++i) { for (string::size_type i = 0; i < ev.argument.length(); ++i) {
bv->owner()->getIntl()->getTransManager(). bv->owner()->getIntl()->getTransManager().
TranslateAndInsert(arg[i], lt); TranslateAndInsert(ev.argument[i], lt);
} }
} }
lt->selection.cursor = lt->cursor; lt->selection.cursor = lt->cursor;
@ -1376,7 +1373,7 @@ InsetText::localDispatch(BufferView * bv,
if (clip.empty()) if (clip.empty())
break; break;
if (arg == "paragraph") { if (ev.argument == "paragraph") {
lt->insertStringAsParagraphs(bv, clip); lt->insertStringAsParagraphs(bv, clip);
} else { } else {
lt->insertStringAsLines(bv, clip); lt->insertStringAsLines(bv, clip);
@ -1449,7 +1446,7 @@ InsetText::localDispatch(BufferView * bv,
// and current buffer's textclass (number). */ // and current buffer's textclass (number). */
LyXTextClass const & tclass = LyXTextClass const & tclass =
bv->buffer()->params.getLyXTextClass(); bv->buffer()->params.getLyXTextClass();
string layout = arg; string layout = ev.argument;
bool hasLayout = tclass.hasLayout(layout); bool hasLayout = tclass.hasLayout(layout);
// If the entry is obsolete, use the new one instead. // If the entry is obsolete, use the new one instead.
@ -1462,8 +1459,8 @@ InsetText::localDispatch(BufferView * bv,
// see if we found the layout number: // see if we found the layout number:
if (!hasLayout) { if (!hasLayout) {
string const msg = string(N_("Layout ")) + arg + N_(" not known"); FuncRequest lf(LFUN_MESSAGE, N_("Layout ") + ev.argument + N_(" not known"));
bv->owner()->getLyXFunc()->dispatch(LFUN_MESSAGE, msg); bv->owner()->getLyXFunc()->dispatch(lf);
break; break;
} }
@ -1491,7 +1488,7 @@ InsetText::localDispatch(BufferView * bv,
cur_value = par->params().spacing().getValue(); cur_value = par->params().spacing().getValue();
} }
istringstream istr(arg.c_str()); istringstream istr(ev.argument.c_str());
string tmp; string tmp;
istr >> tmp; istr >> tmp;
Spacing::Space new_spacing = cur_spacing; Spacing::Space new_spacing = cur_spacing;
@ -1516,7 +1513,7 @@ InsetText::localDispatch(BufferView * bv,
new_spacing = Spacing::Default; new_spacing = Spacing::Default;
} else { } else {
lyxerr << _("Unknown spacing argument: ") lyxerr << _("Unknown spacing argument: ")
<< arg << endl; << ev.argument << endl;
} }
if (cur_spacing != new_spacing || cur_value != new_value) { if (cur_spacing != new_spacing || cur_value != new_value) {
par->params().spacing(Spacing(new_spacing, new_value)); par->params().spacing(Spacing(new_spacing, new_value));
@ -1527,7 +1524,7 @@ InsetText::localDispatch(BufferView * bv,
break; break;
default: default:
if (!bv->dispatch(action, arg)) if (!bv->dispatch(ev))
result = UNDISPATCHED; result = UNDISPATCHED;
break; break;
} }

View File

@ -129,8 +129,7 @@ public:
/// ///
void insetMotionNotify(BufferView *, int, int, mouse_button::state); void insetMotionNotify(BufferView *, int, int, mouse_button::state);
/// ///
UpdatableInset::RESULT localDispatch(BufferView *, UpdatableInset::RESULT localDispatch(BufferView *, FuncRequest const &);
kb_action, string const &);
/// ///
int latex(Buffer const *, std::ostream &, int latex(Buffer const *, std::ostream &,
bool fragile, bool free_spc) const; bool fragile, bool free_spc) const;

View File

@ -190,7 +190,7 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym,
<< endl; << endl;
} }
// Do nothing if we have nothing (JMarc) // Do nothing if we have nothing (JMarc)
if ( ! keysym->isOK() ) { if (!keysym->isOK()) {
lyxerr[Debug::KEY] << "Empty kbd action (probably composing)" lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
<< endl; << endl;
return; return;
@ -264,7 +264,7 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym,
if (c != 0) if (c != 0)
argument = c; argument = c;
dispatch(LFUN_SELFINSERT, argument); dispatch(FuncRequest(LFUN_SELFINSERT, argument));
lyxerr[Debug::KEY] << "SelfInsert arg[`" lyxerr[Debug::KEY] << "SelfInsert arg[`"
<< argument << "']" << endl; << argument << "']" << endl;
} else { } else {
@ -275,25 +275,23 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym,
FuncStatus LyXFunc::getStatus(int ac) const FuncStatus LyXFunc::getStatus(int ac) const
{ {
kb_action action;
string argument; string argument;
action = lyxaction.retrieveActionArg(ac, argument); kb_action action = lyxaction.retrieveActionArg(ac, argument);
return getStatus(action, argument); return getStatus(FuncRequest(action, argument));
} }
FuncStatus LyXFunc::getStatus(kb_action action, FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
string const & argument) const
{ {
FuncStatus flag; FuncStatus flag;
Buffer * buf = owner->buffer(); Buffer * buf = owner->buffer();
if (action == LFUN_NOACTION) { if (ev.action == LFUN_NOACTION) {
setStatusMessage(N_("Nothing to do")); setStatusMessage(N_("Nothing to do"));
return flag.disabled(true); return flag.disabled(true);
} }
if (action == LFUN_UNKNOWN_ACTION) { if (ev.action == LFUN_UNKNOWN_ACTION) {
setStatusMessage(N_("Unknown action")); setStatusMessage(N_("Unknown action"));
return flag.unknown(true); return flag.unknown(true);
} }
@ -302,13 +300,13 @@ FuncStatus LyXFunc::getStatus(kb_action action,
setStatusMessage(N_("Command disabled")); setStatusMessage(N_("Command disabled"));
// Check whether we need a buffer // Check whether we need a buffer
if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) { if (!lyxaction.funcHasFlag(ev.action, LyXAction::NoBuffer)) {
// Yes we need a buffer, do we have one? // Yes we need a buffer, do we have one?
if (buf) { if (buf) {
// yes // yes
// Can we use a readonly buffer? // Can we use a readonly buffer?
if (buf->isReadonly() && if (buf->isReadonly() &&
!lyxaction.funcHasFlag(action, !lyxaction.funcHasFlag(ev.action,
LyXAction::ReadOnly)) { LyXAction::ReadOnly)) {
// no // no
setStatusMessage(N_("Document is read-only")); setStatusMessage(N_("Document is read-only"));
@ -327,14 +325,14 @@ FuncStatus LyXFunc::getStatus(kb_action action,
// I would really like to avoid having this switch and rather try to // I would really like to avoid having this switch and rather try to
// encode this in the function itself. // encode this in the function itself.
bool disable = false; bool disable = false;
switch (action) { switch (ev.action) {
case LFUN_MENUPRINT: case LFUN_MENUPRINT:
disable = !Exporter::IsExportable(buf, "dvi") disable = !Exporter::IsExportable(buf, "dvi")
|| lyxrc.print_command == "none"; || lyxrc.print_command == "none";
break; break;
case LFUN_EXPORT: case LFUN_EXPORT:
disable = argument == "fax" && disable = ev.argument == "fax" &&
!Exporter::IsExportable(buf, argument); !Exporter::IsExportable(buf, ev.argument);
break; break;
case LFUN_UNDO: case LFUN_UNDO:
disable = buf->undostack.empty(); disable = buf->undostack.empty();
@ -378,11 +376,11 @@ FuncStatus LyXFunc::getStatus(kb_action action,
//ret.disabled(true); //ret.disabled(true);
if (tli->lyxCode() == Inset::TABULAR_CODE) { if (tli->lyxCode() == Inset::TABULAR_CODE) {
ret = static_cast<InsetTabular *>(tli) ret = static_cast<InsetTabular *>(tli)
->getStatus(argument); ->getStatus(ev.argument);
} else if (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) { } else if (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
ret = static_cast<InsetTabular *> ret = static_cast<InsetTabular *>
(tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE))
->getStatus(argument); ->getStatus(ev.argument);
} }
flag |= ret; flag |= ret;
disable = false; disable = false;
@ -391,7 +389,7 @@ FuncStatus LyXFunc::getStatus(kb_action action,
FuncStatus ret; FuncStatus ret;
disable = true; disable = true;
ret = inset.getStatus(argument); ret = inset.getStatus(ev.argument);
if (ret.onoff(true) || ret.onoff(false)) if (ret.onoff(true) || ret.onoff(false))
flag.setOnOff(false); flag.setOnOff(false);
} }
@ -413,7 +411,7 @@ FuncStatus LyXFunc::getStatus(kb_action action,
break; break;
case LFUN_BOOKMARK_GOTO: case LFUN_BOOKMARK_GOTO:
disable = !owner->view()-> disable = !owner->view()->
isSavedPosition(strToUnsignedInt(argument)); isSavedPosition(strToUnsignedInt(ev.argument));
break; break;
case LFUN_INSET_TOGGLE: { case LFUN_INSET_TOGGLE: {
LyXText * lt = owner->view()->getLyXText(); LyXText * lt = owner->view()->getLyXText();
@ -433,15 +431,15 @@ FuncStatus LyXFunc::getStatus(kb_action action,
disable = true; disable = true;
break; break;
} }
if (argument.empty()) { if (ev.argument.empty()) {
flag.clear(); flag.clear();
break; break;
} }
if (!contains("tcb", argument[0])) { if (!contains("tcb", ev.argument[0])) {
disable = true; disable = true;
break; break;
} }
flag.setOnOff(argument[0] == align); flag.setOnOff(ev.argument[0] == align);
} else } else
disable = true; disable = true;
break; break;
@ -453,22 +451,22 @@ FuncStatus LyXFunc::getStatus(kb_action action,
disable = true; disable = true;
break; break;
} }
if (argument.empty()) { if (ev.argument.empty()) {
flag.clear(); flag.clear();
break; break;
} }
if (!contains("lcr", argument[0])) { if (!contains("lcr", ev.argument[0])) {
disable = true; disable = true;
break; break;
} }
flag.setOnOff(argument[0] == align); flag.setOnOff(ev.argument[0] == align);
} else } else
disable = true; disable = true;
break; break;
case LFUN_MATH_MUTATE: case LFUN_MATH_MUTATE:
if (tli && (tli->lyxCode() == Inset::MATH_CODE)) if (tli && (tli->lyxCode() == Inset::MATH_CODE))
flag.setOnOff(mathcursor->formula()->hullType() == argument); flag.setOnOff(mathcursor->formula()->hullType() == ev.argument);
else else
disable = true; disable = true;
break; break;
@ -498,7 +496,7 @@ FuncStatus LyXFunc::getStatus(kb_action action,
// the functions which insert insets // the functions which insert insets
Inset::Code code = Inset::NO_CODE; Inset::Code code = Inset::NO_CODE;
switch (action) { switch (ev.action) {
case LFUN_INSET_ERT: case LFUN_INSET_ERT:
code = Inset::ERT_CODE; code = Inset::ERT_CODE;
break; break;
@ -602,7 +600,7 @@ FuncStatus LyXFunc::getStatus(kb_action action,
flag.disabled(true); flag.disabled(true);
// A few general toggles // A few general toggles
switch (action) { switch (ev.action) {
case LFUN_TOOLTIPS_TOGGLE: case LFUN_TOOLTIPS_TOGGLE:
flag.setOnOff(owner->getDialogs()->tooltipsEnabled()); flag.setOnOff(owner->getDialogs()->tooltipsEnabled());
break; break;
@ -616,7 +614,7 @@ FuncStatus LyXFunc::getStatus(kb_action action,
case LFUN_SWITCHBUFFER: case LFUN_SWITCHBUFFER:
// toggle on the current buffer, but do not toggle off // toggle on the current buffer, but do not toggle off
// the other ones (is that a good idea?) // the other ones (is that a good idea?)
if (argument == buf->fileName()) if (ev.argument == buf->fileName())
flag.setOnOff(true); flag.setOnOff(true);
break; break;
default: default:
@ -626,7 +624,7 @@ FuncStatus LyXFunc::getStatus(kb_action action,
// the font related toggles // the font related toggles
if (!mathcursor) { if (!mathcursor) {
LyXFont const & font = TEXT(false)->real_current_font; LyXFont const & font = TEXT(false)->real_current_font;
switch (action) { switch (ev.action) {
case LFUN_EMPH: case LFUN_EMPH:
flag.setOnOff(font.emph() == LyXFont::ON); flag.setOnOff(font.emph() == LyXFont::ON);
break; break;
@ -650,7 +648,7 @@ FuncStatus LyXFunc::getStatus(kb_action action,
} }
} else { } else {
string tc = mathcursor->getLastCode(); string tc = mathcursor->getLastCode();
switch (action) { switch (ev.action) {
case LFUN_BOLD: case LFUN_BOLD:
flag.setOnOff(tc == "mathbf"); flag.setOnOff(tc == "mathbf");
break; break;
@ -679,10 +677,9 @@ FuncStatus LyXFunc::getStatus(kb_action action,
// this one is difficult to get right. As a half-baked // this one is difficult to get right. As a half-baked
// solution, we consider only the first action of the sequence // solution, we consider only the first action of the sequence
if (action == LFUN_SEQUENCE) { if (ev.action == LFUN_SEQUENCE) {
// argument contains ';'-terminated commands // argument contains ';'-terminated commands
const int ac = lyxaction.LookupFunc(token(argument, ';', 0)); flag = getStatus(lyxaction.LookupFunc(token(ev.argument, ';', 0)));
flag = getStatus(ac);
} }
return flag; return flag;
@ -708,15 +705,15 @@ void LyXFunc::dispatch(int ac, bool verbose)
{ {
string argument; string argument;
kb_action const action = lyxaction.retrieveActionArg(ac, argument); kb_action const action = lyxaction.retrieveActionArg(ac, argument);
dispatch(action, argument, verbose); dispatch(FuncRequest(action, argument), verbose);
} }
void LyXFunc::dispatch(kb_action action, string argument, bool verbose) void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
{ {
lyxerr[Debug::ACTION] << "LyXFunc::dispatch: action[" << action lyxerr[Debug::ACTION] << "LyXFunc::dispatch: action[" << ev.action
<<"] arg[" << argument << "]" << endl; <<"] arg[" << ev.argument << "]" << endl;
// we have not done anything wrong yet. // we have not done anything wrong yet.
errorstat = false; errorstat = false;
@ -734,8 +731,11 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
if (owner->view()->available()) if (owner->view()->available())
owner->view()->hideCursor(); owner->view()->hideCursor();
string argument = ev.argument;
kb_action action = ev.action;
// We cannot use this function here // We cannot use this function here
if (getStatus(action, argument).disabled()) { if (getStatus(ev).disabled()) {
lyxerr[Debug::ACTION] << "LyXFunc::dispatch: " lyxerr[Debug::ACTION] << "LyXFunc::dispatch: "
<< lyxaction.getActionName(action) << lyxaction.getActionName(action)
<< " [" << action << "] is disabled at this location" << " [" << action << "] is disabled at this location"
@ -768,7 +768,7 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
goto exit_with_message; goto exit_with_message;
} else if (((result=inset-> } else if (((result=inset->
// Hand-over to inset's own dispatch: // Hand-over to inset's own dispatch:
localDispatch(owner->view().get(), action, argument)) == localDispatch(owner->view().get(), FuncRequest(action, argument))) ==
UpdatableInset::DISPATCHED) || UpdatableInset::DISPATCHED) ||
(result == UpdatableInset::DISPATCHED_NOUPDATE)) (result == UpdatableInset::DISPATCHED_NOUPDATE))
goto exit_with_message; goto exit_with_message;
@ -1336,10 +1336,10 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
// passthrough hat and underscore outside mathed: // passthrough hat and underscore outside mathed:
case LFUN_SUBSCRIPT: case LFUN_SUBSCRIPT:
dispatch(LFUN_SELFINSERT, "_", false); dispatch(FuncRequest(LFUN_SELFINSERT, "_"));
break; break;
case LFUN_SUPERSCRIPT: case LFUN_SUPERSCRIPT:
dispatch(LFUN_SELFINSERT, "^", false); dispatch(FuncRequest(LFUN_SELFINSERT, "^"));
break; break;
case LFUN_MATH_PANEL: case LFUN_MATH_PANEL:
@ -1361,7 +1361,7 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
} else { } else {
p.setContents(argument); p.setContents(argument);
} }
dispatch(LFUN_CITATION_INSERT, p.getAsString()); dispatch(FuncRequest(LFUN_CITATION_INSERT, p.getAsString()));
} else } else
owner->getDialogs()->createCitation(p.getAsString()); owner->getDialogs()->createCitation(p.getAsString());
} }
@ -1507,48 +1507,47 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
default: default:
// Then if it was none of the above // Then if it was none of the above
// Trying the BufferView::pimpl dispatch: // Trying the BufferView::pimpl dispatch:
if (!owner->view()->dispatch(action, argument)) if (!owner->view()->dispatch(ev))
lyxerr << "A truly unknown func [" lyxerr << "A truly unknown func ["
<< lyxaction.getActionName(action) << "]!" << lyxaction.getActionName(ev.action) << "]!"
<< endl; << endl;
break; break;
} // end of switch } // end of switch
exit_with_message: exit_with_message:
string const & msg = getMessage(); sendDispatchMessage(getMessage(), ev, verbose);
sendDispatchMessage(msg, action, argument, verbose);
} }
void LyXFunc::sendDispatchMessage(string const & msg, kb_action action, string const & arg, bool verbose) void LyXFunc::sendDispatchMessage(string const & msg, FuncRequest const & ev, bool verbose)
{ {
owner->updateMenubar(); owner->updateMenubar();
owner->updateToolbar(); owner->updateToolbar();
if (action == LFUN_SELFINSERT || !verbose) { if (ev.action == LFUN_SELFINSERT || !verbose) {
lyxerr[Debug::ACTION] << "dispatch msg is " << msg << endl; lyxerr[Debug::ACTION] << "dispatch msg is " << msg << endl;
if (!msg.empty()) if (!msg.empty())
owner->message(msg); owner->message(msg);
return; return;
} }
string dispatch_msg(msg); string dispatch_msg = msg;
if (!dispatch_msg.empty()) if (!dispatch_msg.empty())
dispatch_msg += " "; dispatch_msg += " ";
string comname = lyxaction.getActionName(action); string comname = lyxaction.getActionName(ev.action);
int pseudoaction = action; int pseudoaction = ev.action;
bool argsadded = false; bool argsadded = false;
if (!arg.empty()) { if (!ev.argument.empty()) {
// the pseudoaction is useful for the bindings // the pseudoaction is useful for the bindings
pseudoaction = lyxaction.searchActionArg(action, arg); pseudoaction = lyxaction.searchActionArg(ev.action, ev.argument);
if (pseudoaction == LFUN_UNKNOWN_ACTION) { if (pseudoaction == LFUN_UNKNOWN_ACTION) {
pseudoaction = action; pseudoaction = ev.action;
} else { } else {
comname += " " + arg; comname += " " + ev.argument;
argsadded = true; argsadded = true;
} }
} }
@ -1557,8 +1556,8 @@ void LyXFunc::sendDispatchMessage(string const & msg, kb_action action, string c
if (!shortcuts.empty()) { if (!shortcuts.empty()) {
comname += ": " + shortcuts; comname += ": " + shortcuts;
} else if (!argsadded && !arg.empty()) { } else if (!argsadded && !ev.argument.empty()) {
comname += " " + arg; comname += " " + ev.argument;
} }
if (!comname.empty()) { if (!comname.empty()) {

View File

@ -7,15 +7,16 @@
#endif #endif
#include "commandtags.h" // for kb_action enum
#include "FuncStatus.h" #include "FuncStatus.h"
#include "kbsequence.h" #include "kbsequence.h"
#include "commandtags.h"
#include "LString.h" #include "LString.h"
#include <boost/signals/trackable.hpp> #include <boost/signals/trackable.hpp>
class LyXView; class LyXView;
class LyXText; class LyXText;
class FuncRequest;
/** This class encapsulates all the LyX command operations. /** This class encapsulates all the LyX command operations.
@ -31,7 +32,7 @@ public:
LyXFunc(LyXView *); LyXFunc(LyXView *);
/// LyX dispatcher, executes lyx actions. /// LyX dispatcher, executes lyx actions.
void dispatch(kb_action ac, string argument = string(), bool verbose = false); void dispatch(FuncRequest const &, bool verbose = false);
/// Dispatch via a string argument /// Dispatch via a string argument
void dispatch(string const & s, bool verbose = false); void dispatch(string const & s, bool verbose = false);
@ -49,8 +50,7 @@ public:
/// can contain the string argument. /// can contain the string argument.
FuncStatus getStatus(int ac) const; FuncStatus getStatus(int ac) const;
/// ///
FuncStatus getStatus(kb_action action, FuncStatus getStatus(FuncRequest const & action) const;
string const & argument = string()) const;
/// The last key was meta /// The last key was meta
bool wasMetaKey() const; bool wasMetaKey() const;
@ -101,7 +101,7 @@ private:
mutable string status_buffer; mutable string status_buffer;
/// send a post-dispatch status message /// send a post-dispatch status message
void sendDispatchMessage(string const & msg, kb_action ac, string const & arg, bool verbose); void sendDispatchMessage(string const & msg, FuncRequest const & ev, bool verbose);
// I think the following should be moved to BufferView. (Asger) // I think the following should be moved to BufferView. (Asger)

View File

@ -726,7 +726,7 @@ int LyXRC::read(string const & filename)
break; break;
} }
if ((action = lyxaction.LookupFunc(cmd))>= 0) { if ((action = lyxaction.LookupFunc(cmd)) >= 0) {
if (lyxerr.debugging(Debug::LYXRC)) { if (lyxerr.debugging(Debug::LYXRC)) {
lyxerr << "RC_BIND: Sequence `" lyxerr << "RC_BIND: Sequence `"
<< seq << "' Command `" << seq << "' Command `"

View File

@ -20,7 +20,6 @@
#include <config.h> #include <config.h>
#include "formula.h" #include "formula.h"
#include "commandtags.h"
#include "math_cursor.h" #include "math_cursor.h"
#include "math_parser.h" #include "math_parser.h"
#include "math_charinset.h" #include "math_charinset.h"
@ -37,6 +36,7 @@
#include "gettext.h" #include "gettext.h"
#include "debug.h" #include "debug.h"
#include "lyxrc.h" #include "lyxrc.h"
#include "funcrequest.h"
#include "support/LOstream.h" #include "support/LOstream.h"
#include "support/LAssert.h" #include "support/LAssert.h"
@ -252,12 +252,11 @@ vector<string> const InsetFormula::getLabelList() const
UpdatableInset::RESULT UpdatableInset::RESULT
InsetFormula::localDispatch(BufferView * bv, kb_action action, InsetFormula::localDispatch(BufferView * bv, FuncRequest const & ev)
string const & arg)
{ {
RESULT result = DISPATCHED; RESULT result = DISPATCHED;
switch (action) { switch (ev.action) {
case LFUN_BREAKLINE: case LFUN_BREAKLINE:
bv->lockedInsetStoreUndo(Undo::INSERT); bv->lockedInsetStoreUndo(Undo::INSERT);
@ -305,7 +304,7 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action,
MathCursor::row_type row = mathcursor->hullRow(); MathCursor::row_type row = mathcursor->hullRow();
string old_label = hull()->label(row); string old_label = hull()->label(row);
string new_label = arg; string new_label = ev.argument;
if (new_label.empty()) { if (new_label.empty()) {
string const default_label = string const default_label =
@ -343,7 +342,7 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action,
int x; int x;
int y; int y;
mathcursor->getPos(x, y); mathcursor->getPos(x, y);
mutate(arg); mutate(ev.argument);
mathcursor->setPos(x, y); mathcursor->setPos(x, y);
mathcursor->normalize(); mathcursor->normalize();
updateLocal(bv, true); updateLocal(bv, true);
@ -354,7 +353,7 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action,
{ {
bv->lockedInsetStoreUndo(Undo::EDIT); bv->lockedInsetStoreUndo(Undo::EDIT);
if (mathcursor) if (mathcursor)
mathcursor->handleExtern(arg); mathcursor->handleExtern(ev.argument);
// re-compute inset dimension // re-compute inset dimension
metrics(bv); metrics(bv);
updateLocal(bv, true); updateLocal(bv, true);
@ -379,13 +378,13 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action,
case LFUN_PASTESELECTION: case LFUN_PASTESELECTION:
{ {
string const clip = bv->getClipboard(); string const clip = bv->getClipboard();
if (!clip.empty()) if (!clip.empty())
mathed_parse_normal(par_, clip); mathed_parse_normal(par_, clip);
break; break;
} }
default: default:
result = InsetFormulaBase::localDispatch(bv, action, arg); result = InsetFormulaBase::localDispatch(bv, ev);
} }
return result; return result;

View File

@ -72,7 +72,7 @@ public:
/// ///
bool insetAllowed(Inset::Code code) const; bool insetAllowed(Inset::Code code) const;
/// ///
virtual RESULT localDispatch(BufferView *, kb_action, string const &); virtual RESULT localDispatch(BufferView *, FuncRequest const &);
/// ///
std::vector<string> const getLabelList() const; std::vector<string> const getLabelList() const;
/// ///

View File

@ -25,7 +25,7 @@
#include "formula.h" #include "formula.h"
#include "formulamacro.h" #include "formulamacro.h"
#include "lyxrc.h" #include "lyxrc.h"
#include "commandtags.h" #include "funcrequest.h"
#include "BufferView.h" #include "BufferView.h"
#include "lyxtext.h" #include "lyxtext.h"
#include "lyxfunc.h" #include "lyxfunc.h"
@ -397,8 +397,7 @@ void InsetFormulaBase::insetMotionNotify(BufferView * bv,
UpdatableInset::RESULT UpdatableInset::RESULT
InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, InsetFormulaBase::localDispatch(BufferView * bv, FuncRequest const & ev)
string const & arg)
{ {
//lyxerr << "InsetFormulaBase::localDispatch: act: " << action //lyxerr << "InsetFormulaBase::localDispatch: act: " << action
// << " arg: '" << arg // << " arg: '" << arg
@ -406,8 +405,8 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
if (!mathcursor) if (!mathcursor)
return UNDISPATCHED; return UNDISPATCHED;
string argument = arg;
string argument = ev.argument;
RESULT result = DISPATCHED; RESULT result = DISPATCHED;
bool sel = false; bool sel = false;
bool was_macro = mathcursor->inMacroMode(); bool was_macro = mathcursor->inMacroMode();
@ -418,7 +417,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
mathcursor->normalize(); mathcursor->normalize();
mathcursor->touch(); mathcursor->touch();
switch (action) { switch (ev.action) {
case LFUN_WORDRIGHTSEL: case LFUN_WORDRIGHTSEL:
case LFUN_RIGHTSEL: case LFUN_RIGHTSEL:
@ -524,7 +523,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
lyxerr << "LFUN_SETXY broken!\n"; lyxerr << "LFUN_SETXY broken!\n";
int x = 0; int x = 0;
int y = 0; int y = 0;
istringstream is(arg.c_str()); istringstream is(ev.argument.c_str());
is >> x >> y; is >> x >> y;
mathcursor->setPos(x, y); mathcursor->setPos(x, y);
updateLocal(bv, false); updateLocal(bv, false);
@ -553,7 +552,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
// Special casing for superscript in case of LyX handling // Special casing for superscript in case of LyX handling
// dead-keys: // dead-keys:
case LFUN_CIRCUMFLEX: case LFUN_CIRCUMFLEX:
if (arg.empty()) { if (ev.argument.empty()) {
// do superscript if LyX handles // do superscript if LyX handles
// deadkeys // deadkeys
bv->lockedInsetStoreUndo(Undo::EDIT); bv->lockedInsetStoreUndo(Undo::EDIT);
@ -579,27 +578,27 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
break; break;
// Math fonts // Math fonts
case LFUN_GREEK_TOGGLE: handleFont(bv, arg, "lyxgreek"); break; case LFUN_GREEK_TOGGLE: handleFont(bv, ev.argument, "lyxgreek"); break;
case LFUN_BOLD: handleFont(bv, arg, "textbf"); break; case LFUN_BOLD: handleFont(bv, ev.argument, "textbf"); break;
case LFUN_SANS: handleFont(bv, arg, "textsf"); break; case LFUN_SANS: handleFont(bv, ev.argument, "textsf"); break;
case LFUN_EMPH: handleFont(bv, arg, "mathcal"); break; case LFUN_EMPH: handleFont(bv, ev.argument, "mathcal"); break;
case LFUN_ROMAN: handleFont(bv, arg, "mathrm"); break; case LFUN_ROMAN: handleFont(bv, ev.argument, "mathrm"); break;
case LFUN_CODE: handleFont(bv, arg, "texttt"); break; case LFUN_CODE: handleFont(bv, ev.argument, "texttt"); break;
case LFUN_FRAK: handleFont(bv, arg, "mathfrak"); break; case LFUN_FRAK: handleFont(bv, ev.argument, "mathfrak"); break;
case LFUN_ITAL: handleFont(bv, arg, "mathit"); break; case LFUN_ITAL: handleFont(bv, ev.argument, "mathit"); break;
case LFUN_NOUN: handleFont(bv, arg, "mathbb"); break; case LFUN_NOUN: handleFont(bv, ev.argument, "mathbb"); break;
case LFUN_DEFAULT: handleFont(bv, arg, "textnormal"); break; case LFUN_DEFAULT: handleFont(bv, ev.argument, "textnormal"); break;
case LFUN_FREE: handleFont(bv, arg, "textrm"); break; case LFUN_FREE: handleFont(bv, ev.argument, "textrm"); break;
case LFUN_GREEK: case LFUN_GREEK:
handleFont(bv, arg, "lyxgreek1"); handleFont(bv, ev.argument, "lyxgreek1");
if (arg.size()) if (ev.argument.size())
mathcursor->interpret(arg); mathcursor->interpret(ev.argument);
break; break;
case LFUN_MATH_MODE: case LFUN_MATH_MODE:
if (mathcursor->currentMode()) { if (mathcursor->currentMode()) {
handleFont(bv, arg, "textrm"); handleFont(bv, ev.argument, "textrm");
} else { } else {
mathcursor->niceInsert(MathAtom(new MathHullInset("simple"))); mathcursor->niceInsert(MathAtom(new MathHullInset("simple")));
updateLocal(bv, true); updateLocal(bv, true);
@ -624,9 +623,9 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
break; break;
case LFUN_INSERT_MATRIX: case LFUN_INSERT_MATRIX:
if (!arg.empty()) { if (!ev.argument.empty()) {
bv->lockedInsetStoreUndo(Undo::EDIT); bv->lockedInsetStoreUndo(Undo::EDIT);
mathcursor->interpret("matrix " + arg); mathcursor->interpret("matrix " + ev.argument);
updateLocal(bv, true); updateLocal(bv, true);
} }
break; break;
@ -635,7 +634,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
case LFUN_SUBSCRIPT: case LFUN_SUBSCRIPT:
{ {
bv->lockedInsetStoreUndo(Undo::EDIT); bv->lockedInsetStoreUndo(Undo::EDIT);
mathcursor->script(action == LFUN_SUPERSCRIPT); mathcursor->script(ev.action == LFUN_SUPERSCRIPT);
updateLocal(bv, true); updateLocal(bv, true);
break; break;
} }
@ -644,7 +643,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
{ {
//lyxerr << "formulabase::LFUN_MATH_DELIM, arg: '" << arg << "'\n"; //lyxerr << "formulabase::LFUN_MATH_DELIM, arg: '" << arg << "'\n";
string ls; string ls;
string rs = split(arg, ls, ' '); string rs = split(ev.argument, ls, ' ');
// Reasonable default values // Reasonable default values
if (ls.empty()) if (ls.empty())
ls = '('; ls = '(';
@ -681,8 +680,8 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
if (p) { if (p) {
mathcursor->popToEnclosingGrid(); mathcursor->popToEnclosingGrid();
bv->lockedInsetStoreUndo(Undo::EDIT); bv->lockedInsetStoreUndo(Undo::EDIT);
char align = arg.size() ? arg[0] : 'c'; char align = ev.argument.size() ? ev.argument[0] : 'c';
switch (action) { switch (ev.action) {
case LFUN_MATH_HALIGN: p->halign(align, p->col(idx)); break; case LFUN_MATH_HALIGN: p->halign(align, p->col(idx)); break;
case LFUN_MATH_VALIGN: p->valign(align); break; case LFUN_MATH_VALIGN: p->valign(align); break;
case LFUN_MATH_ROW_INSERT: p->addRow(p->row(idx)); break; case LFUN_MATH_ROW_INSERT: p->addRow(p->row(idx)); break;
@ -757,13 +756,13 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
// updateInset(inset, true); // updateInset(inset, true);
//} //}
// //
if (arg.empty()) { if (ev.argument.empty()) {
InsetCommandParams p("ref"); InsetCommandParams p("ref");
bv->owner()->getDialogs()->createRef(p.getAsString()); bv->owner()->getDialogs()->createRef(p.getAsString());
} else { } else {
//mathcursor->handleNest(new InsetRef2); //mathcursor->handleNest(new InsetRef2);
//mathcursor->insert(arg); //mathcursor->insert(arg);
mathcursor->insert(MathAtom(new RefInset(arg))); mathcursor->insert(MathAtom(new RefInset(ev.argument)));
} }
updateLocal(bv, true); updateLocal(bv, true);
break; break;
@ -941,8 +940,8 @@ void mathDispatchCreation(BufferView * bv, string const & arg, bool display)
// always changing to mathrm when opening an inlined inset // always changing to mathrm when opening an inlined inset
// -- I really hate "LyXfunc overloading"... // -- I really hate "LyXfunc overloading"...
if (display) if (display)
f->localDispatch(bv, LFUN_MATH_DISPLAY, string()); f->localDispatch(bv, FuncRequest(LFUN_MATH_DISPLAY));
f->localDispatch(bv, LFUN_INSERT_MATH, arg); f->localDispatch(bv, FuncRequest(LFUN_INSERT_MATH, arg));
} }
} else { } else {
// create a macro if we see "\\newcommand" somewhere, and an ordinary // create a macro if we see "\\newcommand" somewhere, and an ordinary
@ -1000,7 +999,7 @@ void mathDispatchMathDelim(BufferView * bv, string const & arg)
InsetFormula * f = new InsetFormula(bv); InsetFormula * f = new InsetFormula(bv);
if (openNewInset(bv, f)) { if (openNewInset(bv, f)) {
f->mutate("simple"); f->mutate("simple");
bv->theLockingInset()->localDispatch(bv, LFUN_MATH_DELIM, arg); bv->theLockingInset()->localDispatch(bv, FuncRequest(LFUN_MATH_DELIM, arg));
} }
} }
@ -1012,7 +1011,7 @@ void mathDispatchInsertMatrix(BufferView * bv, string const & arg)
InsetFormula * f = new InsetFormula(bv); InsetFormula * f = new InsetFormula(bv);
if (openNewInset(bv, f)) { if (openNewInset(bv, f)) {
f->mutate("simple"); f->mutate("simple");
bv->theLockingInset()->localDispatch(bv, LFUN_INSERT_MATRIX, arg); bv->theLockingInset()->localDispatch(bv, FuncRequest(LFUN_INSERT_MATRIX, arg));
} }
} }
@ -1024,7 +1023,7 @@ void mathDispatchInsertMath(BufferView * bv, string const & arg)
InsetFormula * f = new InsetFormula(bv); InsetFormula * f = new InsetFormula(bv);
if (openNewInset(bv, f)) { if (openNewInset(bv, f)) {
f->mutate("simple"); f->mutate("simple");
bv->theLockingInset()->localDispatch(bv, LFUN_INSERT_MATH, arg); bv->theLockingInset()->localDispatch(bv, FuncRequest(LFUN_INSERT_MATH, arg));
} }
} }
@ -1036,7 +1035,7 @@ void mathDispatchGreek(BufferView * bv, string const & arg)
InsetFormula * f = new InsetFormula(bv); InsetFormula * f = new InsetFormula(bv);
if (openNewInset(bv, f)) { if (openNewInset(bv, f)) {
f->mutate("simple"); f->mutate("simple");
bv->theLockingInset()->localDispatch(bv, LFUN_GREEK, arg); bv->theLockingInset()->localDispatch(bv, FuncRequest(LFUN_GREEK, arg));
bv->unlockInset(f); bv->unlockInset(f);
} }
} }

View File

@ -24,7 +24,6 @@
#include "lyxfont.h" #include "lyxfont.h"
#include <boost/weak_ptr.hpp> #include <boost/weak_ptr.hpp>
#include <iosfwd> #include <iosfwd>
class Buffer; class Buffer;
@ -90,7 +89,7 @@ public:
virtual void insetUnlock(BufferView *); virtual void insetUnlock(BufferView *);
/// To allow transparent use of math editing functions /// To allow transparent use of math editing functions
virtual RESULT localDispatch(BufferView *, kb_action, string const &); virtual RESULT localDispatch(BufferView *, FuncRequest const &);
/// ///
virtual std::vector<string> const getLabelList() const; virtual std::vector<string> const getLabelList() const;
@ -165,7 +164,7 @@ void mathDispatchGreek(BufferView *, string const &);
// //
void mathDispatchMathImportSelection(BufferView *, string const &); void mathDispatchMathImportSelection(BufferView *, string const &);
// //
void mathDispatch(BufferView *, kb_action, string const &); void mathDispatch(BufferView *, FuncRequest const &);
// //
void mathDispatch(BufferView *, string const &); void mathDispatch(BufferView *, string const &);

View File

@ -524,7 +524,7 @@ LyXFont::FONT_SERIES const inh_series = LyXFont::INHERIT_SERIES;
LyXFont::FONT_SHAPE const inh_shape = LyXFont::INHERIT_SHAPE; LyXFont::FONT_SHAPE const inh_shape = LyXFont::INHERIT_SHAPE;
// mathnormal should be the first, otherwise the fallback fuerther down // mathnormal should be the first, otherwise the fallback further down
// does not work // does not work
fontinfo fontinfos[] = { fontinfo fontinfos[] = {
{"mathnormal", {"mathnormal",

View File

@ -2,7 +2,7 @@
#include "ref_inset.h" #include "ref_inset.h"
#include "math_cursor.h" #include "math_cursor.h"
#include "commandtags.h" #include "funcrequest.h"
#include "formulabase.h" #include "formulabase.h"
#include "BufferView.h" #include "BufferView.h"
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
@ -41,13 +41,13 @@ int RefInset::dispatch(string const & cmd, idx_type, pos_type)
if (cmd == "mouse-3-release") { if (cmd == "mouse-3-release") {
lyxerr << "trying to goto ref" << cell(0) << "\n"; lyxerr << "trying to goto ref" << cell(0) << "\n";
mathcursor->formula()->view()->owner()->getLyXFunc()-> mathcursor->formula()->view()->owner()->getLyXFunc()->
dispatch(LFUN_REF_GOTO, asString(cell(0))); dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
return 1; // dispatched return 1; // dispatched
} }
if (cmd == "mouse-1-release") { if (cmd == "mouse-1-release") {
lyxerr << "trying to open ref" << cell(0) << "\n"; lyxerr << "trying to open ref" << cell(0) << "\n";
// Eventually trigger dialog with button 3 not 1 // FuncRequestually trigger dialog with button 3 not 1
// mathcursor->formula()->view()->owner()->getDialogs() // mathcursor->formula()->view()->owner()->getDialogs()
// ->showRef(this); // ->showRef(this);
return 1; // dispatched return 1; // dispatched

View File

@ -48,7 +48,7 @@ string const TocItem::asString() const
void TocItem::goTo(LyXView & lv_) const void TocItem::goTo(LyXView & lv_) const
{ {
string const tmp = tostr(par->id()); string const tmp = tostr(par->id());
lv_.getLyXFunc()->dispatch(LFUN_GOTO_PARAGRAPH, tmp, false); lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_GOTO_PARAGRAPH, tmp));
} }