}
-bool BufferView::dispatch(kb_action action, string const & argument)
+bool BufferView::dispatch(FuncRequest const & ev)
{
- return pimpl_->dispatch(action, argument);
+ return pimpl_->dispatch(ev);
}
#include "LString.h"
#include "undo.h"
-#include "commandtags.h"
#include "insets/inset.h"
#include "WordLangTuple.h"
///
void stuffClipboard(string const &) const;
///
- bool dispatch(kb_action action, string const & argument);
+ bool dispatch(FuncRequest const & argument);
private:
///
struct Pimpl;
#include "gettext.h"
#include "ParagraphParameters.h"
#include "undo_funcs.h"
+#include "funcrequest.h"
#include "insets/insetbib.h"
#include "insets/insettext.h"
if (paste_internally)
owner_->getLyXFunc()->dispatch(LFUN_PASTE);
else
- owner_->getLyXFunc()->dispatch(LFUN_PASTESELECTION,
- string("paragraph"));
+ owner_->getLyXFunc()->dispatch(FuncRequest(LFUN_PASTESELECTION, "paragraph"));
selection_possible = false;
return;
}
// We are in inset locking mode.
/* 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. */
bv_->theLockingInset()->
insetButtonRelease(bv_, x, y, button);
}
-bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
+bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
{
lyxerr[Debug::ACTION] << "BufferView::Pimpl::Dispatch: action["
- << action <<"] arg[" << argument << "]" << endl;
+ << ev.action <<"] arg[" << ev.argument << "]" << endl;
LyXTextClass const & tclass = buffer_->params.getLyXTextClass();
- switch (action) {
+ switch (ev.action) {
// --- Misc -------------------------------------------
case LFUN_APPENDIX:
{
break;
case LFUN_PASTESELECTION:
- {
- bool asPara = false;
- if (argument == "paragraph")
- asPara = true;
- pasteClipboard(asPara);
- }
- break;
+ pasteClipboard(ev.argument == "paragraph");
+ break;
case LFUN_CUT:
bv_->cut();
break;
case LFUN_FILE_INSERT:
- MenuInsertLyXFile(argument);
+ MenuInsertLyXFile(ev.argument);
break;
case LFUN_FILE_INSERT_ASCII_PARA:
- InsertAsciiFile(bv_, argument, true);
+ InsertAsciiFile(bv_, ev.argument, true);
break;
case LFUN_FILE_INSERT_ASCII:
- InsertAsciiFile(bv_, argument, false);
+ InsertAsciiFile(bv_, ev.argument, false);
break;
case LFUN_LAYOUT:
{
lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
- << argument << endl;
+ << ev.argument << endl;
// This is not the good solution to the empty argument
// problem, but it will hopefully suffice for 1.2.0.
// The correct solution would be to augument the
// function list/array with information about what
// functions needs arguments and their type.
- if (argument.empty()) {
+ if (ev.argument.empty()) {
owner_->getLyXFunc()->setErrorMessage(
_("LyX function 'layout' needs an argument."));
break;
// Derive layout number from given argument (string)
// and current buffer's textclass (number). */
- bool hasLayout = tclass.hasLayout(argument);
- string layout = argument;
+ bool hasLayout = tclass.hasLayout(ev.argument);
+ string layout = ev.argument;
// If the entry is obsolete, use the new one instead.
if (hasLayout) {
if (!hasLayout) {
owner_->getLyXFunc()->setErrorMessage(
- string(N_("Layout ")) + argument +
+ string(N_("Layout ")) + ev.argument +
N_(" not known"));
break;
}
break;
case LFUN_LANGUAGE:
- lang(bv_, argument);
+ lang(bv_, ev.argument);
switchKeyMap();
owner_->view_state_changed();
break;
break;
case LFUN_FONT_SIZE:
- fontSize(bv_, argument);
+ fontSize(bv_, ev.argument);
owner_->view_state_changed();
break;
case LFUN_INSERT_LABEL:
- MenuInsertLabel(bv_, argument);
+ MenuInsertLabel(bv_, ev.argument);
break;
case LFUN_REF_INSERT:
- if (argument.empty()) {
+ if (ev.argument.empty()) {
InsetCommandParams p("ref");
owner_->getDialogs()->createRef(p.getAsString());
} else {
InsetCommandParams p;
- p.setFromString(argument);
+ p.setFromString(ev.argument);
InsetRef * inset = new InsetRef(p, *buffer_);
if (!insertInset(inset))
break;
case LFUN_BOOKMARK_SAVE:
- savePosition(strToUnsignedInt(argument));
+ savePosition(strToUnsignedInt(ev.argument));
break;
case LFUN_BOOKMARK_GOTO:
- restorePosition(strToUnsignedInt(argument));
+ restorePosition(strToUnsignedInt(ev.argument));
break;
case LFUN_REF_GOTO:
{
- string label(argument);
+ string label = ev.argument;
if (label.empty()) {
InsetRef * inset =
static_cast<InsetRef*>(getInsetByCode(Inset::REF_CODE));
cur_value = par->params().spacing().getValue();
}
- istringstream istr(argument.c_str());
+ istringstream istr(ev.argument.c_str());
string tmp;
istr >> tmp;
new_spacing = Spacing::Default;
} else {
lyxerr << _("Unknown spacing argument: ")
- << argument << endl;
+ << ev.argument << endl;
}
if (cur_spacing != new_spacing || cur_value != new_value) {
par->params().spacing(Spacing(new_spacing, new_value));
case LFUN_URL:
{
InsetCommandParams p;
- if (action == LFUN_HTMLURL)
+ if (ev.action == LFUN_HTMLURL)
p.setCmdName("htmlurl");
else
p.setCmdName("url");
case LFUN_INSERT_URL:
{
InsetCommandParams p;
- p.setFromString(argument);
+ p.setFromString(ev.argument);
InsetUrl * inset = new InsetUrl(p);
if (!insertInset(inset))
case LFUN_INSET_FLOAT:
// check if the float type exist
- if (floatList.typeExist(argument)) {
+ if (floatList.typeExist(ev.argument)) {
insertAndEditInset(new InsetFloat(buffer_->params,
- argument));
+ ev.argument));
} else {
lyxerr << "Non-existent float type: "
- << argument << endl;
+ << ev.argument << endl;
}
break;
case LFUN_INSET_WIDE_FLOAT:
// check if the float type exist
- if (floatList.typeExist(argument)) {
+ if (floatList.typeExist(ev.argument)) {
InsetFloat * new_inset =
- new InsetFloat(buffer_->params, argument);
+ new InsetFloat(buffer_->params, ev.argument);
new_inset->wide(true);
insertAndEditInset(new_inset);
} else {
lyxerr << "Non-existent float type: "
- << argument << endl;
+ << ev.argument << endl;
}
break;
case LFUN_TABULAR_INSERT:
{
- if (argument.empty()) {
+ if (ev.argument.empty()) {
owner_->getDialogs()->showTabularCreate();
break;
}
int r = 2;
int c = 2;
- ::sscanf(argument.c_str(),"%d%d", &r, &c);
+ ::sscanf(ev.argument.c_str(),"%d%d", &r, &c);
InsetTabular * new_inset =
new InsetTabular(*buffer_, r, c);
bool const rtl =
{
int x = 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 '"
- << argument << std::endl;
+ << ev.argument << std::endl;
}
bv_->getLyXText()->setCursorFromCoordinates(bv_, x, y);
}
case LFUN_HUNG_UMLAUT:
case LFUN_CIRCLE:
case LFUN_OGONEK:
- if (argument.empty()) {
+ if (ev.argument.empty()) {
// As always...
- owner_->getLyXFunc()->handleKeyFunc(action);
+ owner_->getLyXFunc()->handleKeyFunc(ev.action);
} else {
- owner_->getLyXFunc()->handleKeyFunc(action);
+ owner_->getLyXFunc()->handleKeyFunc(ev.action);
owner_->getIntl()->getTransManager()
- .TranslateAndInsert(argument[0], bv_->getLyXText());
+ .TranslateAndInsert(ev.argument[0], bv_->getLyXText());
update(bv_->getLyXText(),
BufferView::SELECT
| BufferView::FITCUR
break;
case LFUN_MATH:
- mathDispatch(bv_, argument);
+ mathDispatch(bv_, ev.argument);
break;
case LFUN_MATH_MACRO:
- mathDispatchMathMacro(bv_, argument);
+ mathDispatchMathMacro(bv_, ev.argument);
break;
case LFUN_MATH_DELIM:
- mathDispatchMathDelim(bv_, argument);
+ mathDispatchMathDelim(bv_, ev.argument);
break;
case LFUN_INSERT_MATRIX:
- mathDispatchInsertMatrix(bv_, argument);
+ mathDispatchInsertMatrix(bv_, ev.argument);
break;
case LFUN_INSERT_MATH:
- mathDispatchInsertMath(bv_, argument);
+ mathDispatchInsertMath(bv_, ev.argument);
break;
case LFUN_MATH_IMPORT_SELECTION: // Imports LaTeX from the X selection
- mathDispatchMathImportSelection(bv_, argument);
+ mathDispatchMathImportSelection(bv_, ev.argument);
break;
case LFUN_MATH_DISPLAY: // Open or create a displayed math inset
- mathDispatchMathDisplay(bv_, argument);
+ mathDispatchMathDisplay(bv_, ev.argument);
break;
case LFUN_MATH_MODE: // Open or create an inlined math inset
- mathDispatchMathMode(bv_, argument);
+ mathDispatchMathMode(bv_, ev.argument);
break;
case LFUN_GREEK: // Insert a single greek letter
- mathDispatchGreek(bv_, argument);
+ mathDispatchGreek(bv_, ev.argument);
break;
case LFUN_CITATION_INSERT:
{
InsetCommandParams p;
- p.setFromString(argument);
+ p.setFromString(ev.argument);
InsetCitation * inset = new InsetCitation(p);
if (!insertInset(inset))
// ale970405+lasgoutt970425
// The argument can be up to two tokens separated
// by a space. The first one is the bibstyle.
- string const db = token(argument, ' ', 0);
- string const bibstyle = token(argument, ' ', 1);
+ string const db = token(ev.argument, ' ', 0);
+ string const bibstyle = token(ev.argument, ' ', 1);
InsetCommandParams p("BibTeX", db, bibstyle);
InsetBibtex * inset = new InsetBibtex(p);
if (insertInset(inset)) {
- if (argument.empty())
+ if (ev.argument.empty())
inset->edit(bv_);
} else
delete inset;
InsetBibtex * inset =
static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
if (inset) {
- inset->addDatabase(argument);
+ inset->addDatabase(ev.argument);
}
}
break;
InsetBibtex * inset =
static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
if (inset) {
- inset->delDatabase(argument);
+ inset->delDatabase(ev.argument);
}
}
break;
InsetBibtex * inset =
static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
if (inset) {
- inset->setOptions(argument);
+ inset->setOptions(ev.argument);
}
}
break;
case LFUN_INDEX_INSERT:
{
- string entry = argument;
+ string entry = ev.argument;
if (entry.empty()) {
entry = bv_->getLyXText()->getStringToIndex(bv_);
}
case LFUN_PARENTINSERT:
{
- InsetCommandParams p("lyxparent", argument);
+ InsetCommandParams p("lyxparent", ev.argument);
Inset * inset = new InsetParent(p, *buffer_);
if (!insertInset(inset, tclass.defaultLayoutName()))
delete inset;
case LFUN_CHILD_INSERT:
{
InsetInclude::Params p;
- p.cparams.setFromString(argument);
+ p.cparams.setFromString(ev.argument);
p.masterFilename_ = buffer_->fileName();
InsetInclude * inset = new InsetInclude(p);
break;
case LFUN_FLOAT_LIST:
- if (floatList.typeExist(argument)) {
- Inset * inset = new InsetFloatList(argument);
+ if (floatList.typeExist(ev.argument)) {
+ Inset * inset = new InsetFloatList(ev.argument);
if (!insertInset(inset, tclass.defaultLayoutName()))
delete inset;
} else {
lyxerr << "Non-existent float type: "
- << argument << endl;
+ << ev.argument << endl;
}
break;
case LFUN_THESAURUS_ENTRY:
{
- string arg = argument;
+ string arg = ev.argument;
if (arg.empty()) {
arg = bv_->getLyXText()->selectionAsString(buffer_,
case LFUN_SELFINSERT:
{
- if (argument.empty()) break;
+ if (ev.argument.empty()) break;
/* Automatically delete the currently selected
* text and replace it with what is being
beforeChange(lt);
LyXFont const old_font(lt->real_current_font);
- string::const_iterator cit = argument.begin();
- string::const_iterator end = argument.end();
+ string::const_iterator cit = ev.argument.begin();
+ string::const_iterator end = ev.argument.end();
for (; cit != end; ++cit) {
owner_->getIntl()->getTransManager().
TranslateAndInsert(*cit, lt);
struct tm * now_tm = localtime(&now_time_t);
setlocale(LC_TIME, "");
string arg;
- if (!argument.empty())
- arg = argument;
+ if (!ev.argument.empty())
+ arg = ev.argument;
else
arg = lyxrc.date_insert_format;
char datetmp[32];
if (style->pass_thru ||
(!insertInset(new InsetQuotes(c, bv_->buffer()->params))))
- bv_->owner()->getLyXFunc()->dispatch(LFUN_SELFINSERT, string("\""));
+ bv_->owner()->getLyXFunc()
+ ->dispatch(FuncRequest(LFUN_SELFINSERT, "\""));
}
#define BUFFERVIEW_PIMPL_H
#include "BufferView.h"
-#include "commandtags.h"
#include "frontends/Timeout.h"
#include "frontends/key_state.h"
#include "frontends/mouse_state.h"
///
void updateInset(Inset * inset, bool mark_dirty);
///
- bool dispatch(kb_action action, string const & argument);
+ bool dispatch(FuncRequest const & ev);
private:
/**
* Return the on-screen dimensions of the inset at the cursor.
+
+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>
* BufferView_pimpl.C (redoCurrentBuffer): fix screen update when
#include "gettext.h"
#include "lyxfunc.h"
#include "debug.h"
+#include "funcrequest.h"
#include "support/filetools.h"
#include "support/FileInfo.h"
#include "support/lstrings.h"
if (lfun) {
ostringstream str;
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()();
// no checks for now
lyxerr[Debug::LATEX] << "Running MakeIndex." << endl;
if (lfun) {
- lfun->dispatch(LFUN_MESSAGE, _("Running MakeIndex."), false);
+ lfun->dispatch(FuncRequest(LFUN_MESSAGE, _("Running MakeIndex.")));
}
rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx")));
// no checks for now
lyxerr[Debug::LATEX] << "Running BibTeX." << endl;
if (lfun) {
- lfun->dispatch(LFUN_MESSAGE, _("Running BibTeX."), false);
+ lfun->dispatch(FuncRequest(LFUN_MESSAGE, _("Running BibTeX.")));
}
updateBibtexDependencies(head, bibtex_info);
ostringstream str;
str << _("LaTeX run number") << ' ' << count;
// 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()();
// no checks for now
lyxerr[Debug::LATEX] << "Running MakeIndex." << endl;
if (lfun) {
- lfun->dispatch(LFUN_MESSAGE, _("Running MakeIndex."), false);
+ lfun->dispatch(FuncRequest(LFUN_MESSAGE, _("Running MakeIndex.")));
}
rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx")));
if (lfun) {
ostringstream str;
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()();
static bool init;
if (init) return;
- struct lfun_item {
+ struct ev_item {
kb_action action;
char const * name;
char const * helpText;
unsigned int attrib;
};
- lfun_item items[] = {
+ ev_item items[] = {
{ LFUN_ACUTE, "accent-acute", "", Noop },
{ LFUN_BREVE, "accent-breve", "", Noop },
{ LFUN_CARON, "accent-caron", "", Noop },
static unsigned int pseudo_counter = LFUN_LASTACTION;
// Create new pseudo action.
- pseudo_func tmp_p;
- tmp_p.action = action;
- tmp_p.arg = arg;
- lyx_pseudo_map[++pseudo_counter] = tmp_p;
+ lyx_pseudo_map[++pseudo_counter] = FuncRequest(action, arg);
// First ensure that the action is in lyx_arg_map;
lyx_arg_map[action];
if (pit != lyx_pseudo_map.end()) {
lyxerr[Debug::ACTION] << "Found the pseudoaction: ["
<< pit->second.action << '|'
- << pit->second.arg << "]\n";
- arg = pit->second.arg;
+ << pit->second.argument << "]\n";
+ arg = pit->second.argument;
return pit->second.action;
} else {
lyxerr << "Lyx Error: Unrecognized pseudo-action "
#include <map>
-#include "commandtags.h"
-#include "LString.h"
+#include "funcrequest.h"
#include <boost/utility.hpp>
/** This class encapsulates LyX action and user command operations.
*/
+
class LyXAction : boost::noncopyable {
private:
///
string helpText;
};
- ///
- struct pseudo_func {
- ///
- kb_action action;
- ///
- string arg;
- };
public:
///
typedef std::map<string, kb_action> func_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;
///
*/
class WordLangTuple {
public:
- WordLangTuple() {};
+ WordLangTuple() {}
WordLangTuple(string const & w, string const & c)
- : word_(w), code_(c) {}
+ : word_(w), code_(c)
+ {}
/// return the word
string const word() const {
* This is basically the Communicator class from the lyx cvs module 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 (when
* most systems can support those required features).
*
elaborate. This is basically the Communicator class from the lyx cvs module
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.
See the "dialogbase" branch of lyx-devel cvs module for xtl implementation.
*/
void resetAutosaveTimer();
protected:
- /// view of a buffer. Eventually there will be several.
+ /// view of a buffer. FuncRequestually there will be several.
boost::shared_ptr<BufferView> bufferview_;
/// view's menubar
#include "frontends/LyXView.h"
#include "lyxfunc.h"
#include "BufferView.h"
+#include "funcrequest.h"
+
ControlCommand::ControlCommand(LyXView & lv, Dialogs & d, kb_action ac)
: ControlInset<InsetCommand, InsetCommandParams>(lv, d),
void ControlCommand::applyParamsNoInset()
{
- if (action_ == LFUN_NOACTION) return;
- lv_.getLyXFunc()->dispatch(action_, params().getAsString());
+ if (action_ == LFUN_NOACTION)
+ return;
+ lv_.getLyXFunc()->dispatch(FuncRequest(action_, params().getAsString()));
}
#include "BufferView.h"
#include "frontends/LyXView.h"
#include "lyxfunc.h"
+#include "funcrequest.h"
#include "support/forkedcontr.h"
#include "support/lstrings.h"
for (vector<string>::const_iterator it = pids_.begin();
it != pids_.end(); ++it) {
- lv_.getLyXFunc()->dispatch(LFUN_FORKS_KILL, *it);
+ lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_FORKS_KILL, *it));
}
pids_.clear();
#include "gettext.h"
#include "helper_funcs.h"
#include "lyxrc.h"
+#include "funcrequest.h"
#include "support/filetools.h"
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)
{
- 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, "/"))
Alert::alert(_("Warning!"),
return true;
else
- Alert::alert(_("Warning!"),
- _("Specified file doesn't exist"));
+ Alert::alert(_("Warning!"), _("Specified file doesn't exist"));
return false;
}
#include "ControlRef.h"
#include "lyxfunc.h"
#include "bufferlist.h"
+#include "funcrequest.h"
#include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
void ControlRef::gotoRef(string const & ref) const
{
- lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_SAVE, "0", false);
- lv_.getLyXFunc()->dispatch(LFUN_REF_GOTO, ref);
+ lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"), false);
+ lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_REF_GOTO, ref));
}
void ControlRef::gotoBookmark() const
{
- lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_GOTO, "0", false);
+ lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"), false);
}
#include "ButtonControllerBase.h"
#include "BufferView.h"
#include "lyxfunc.h"
+#include "funcrequest.h"
#include "frontends/LyXView.h"
ControlTabularCreate::rowsCols & ControlTabularCreate::params()
{
- return params_;
+ return params_;
}
view().apply();
- string const val(tostr(params().first) + " " + tostr(params().second));
-
- lv_.getLyXFunc()->dispatch(LFUN_TABULAR_INSERT, val);
+ string const val = tostr(params().first) + " " + tostr(params().second);
+ lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_TABULAR_INSERT, val));
}
#include "QtLyXView.h"
#include "debug.h"
+#include "funcrequest.h"
#include "FileDialog_private.h"
-LyXFileDialog::LyXFileDialog(LyXView * lv, kb_action a, string const & p, string const & m, string const & t)
- : QFileDialog(p.c_str(), m.c_str(), qApp->mainWidget(), t.c_str(), a == LFUN_SELECT_FILE_SYNC),
- lv_(lv), action_(a)
+LyXFileDialog::LyXFileDialog(LyXView * lv, kb_action a,
+ string const & p, string const & m, string const & t)
+ : 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());
}
if (action_ == LFUN_SELECT_FILE_SYNC) {
QDialog::done(what);
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;
}
for (LyXTextClass::const_iterator cit = tc.begin();
cit != end; ++cit) {
if (_((*cit)->name()) == sel) {
- owner_->getLyXFunc()->dispatch(LFUN_LAYOUT, (*cit)->name());
+ owner_->getLyXFunc()->dispatch(FuncRequest(LFUN_LAYOUT, (*cit)->name()));
return;
}
}
#include "debug.h"
#include "support/lstrings.h"
#include "lyxfunc.h"
+#include "funcrequest.h"
#include FORMS_H_LOCATION
#include "delim.xbm"
static int const delim_rversion[] = {
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[] = {
"(", ")", "lceil", "rceil", "uparrow", "Uparrow",
ostringstream ost;
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)
{
int left = int(dialog_->radio_left->u_ldata);
#include "frontends/LyXView.h"
#include "Lsstream.h"
#include "lyxfunc.h"
+#include "funcrequest.h"
#include "support/LAssert.h"
#include "support/lyxalgo.h" // lyx::count
#include FORMS_H_LOCATION
ostringstream ost;
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)
{
if (ob == dialog_->choice_valign ||
{
size_t len = strlen(cur);
- int const n = int(fl_get_slider_value(dialog_->slider_columns) + 0.5) -
- int(len) +
- int(lyx::count(cur, cur + len, '|'));
+ int const n = int(fl_get_slider_value(dialog_->slider_columns) + 0.5)
+ - int(len)
+ + int(lyx::count(cur, cur + len, '|'));
if (n < 0)
return FL_INVALID;
#include "MathsSymbols.h"
#include "debug.h"
#include "lyxfunc.h"
+#include "funcrequest.h"
#include "forms/form_maths_deco.h"
#include "forms/form_maths_delim.h"
void FormMathsPanel::insertSymbol(string const & sym, bool bs) const
{
if (bs)
- lv_->getLyXFunc()->dispatch(LFUN_INSERT_MATH, '\\' + sym);
+ lv_->getLyXFunc()->dispatch(FuncRequest(LFUN_INSERT_MATH, '\\' + sym));
else
- lv_->getLyXFunc()->dispatch(LFUN_INSERT_MATH, sym);
+ lv_->getLyXFunc()->dispatch(FuncRequest(LFUN_INSERT_MATH, sym));
}
#include "lyxrc.h"
#include "LColor.h"
#include "Lsstream.h"
+#include "funcrequest.h"
#include "combox.h"
#include "Color.h"
string const s = lcolor.getLyXName(lc) + string(" ") +
hexname;
- parent_.lv_->getLyXFunc()->dispatch(LFUN_SET_COLOR, s);
+ parent_.lv_->getLyXFunc()->dispatch(FuncRequest(LFUN_SET_COLOR, s));
}
}
}
setPrehandler(dialog_->radio_hsv);
}
+
string const
FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
{
void FormPreferences::Colors::LoadBrowserLyX()
{
- if (!dialog_->browser_lyx_objs->visible) return;
+ if (!dialog_->browser_lyx_objs->visible)
+ return;
// First, define the modifiable xforms colors
xformsColorDB.clear();
string const arg = lcolor.getLyXName(lc) + " black";
parent_.lv_->getLyXFunc()->
- dispatch(LFUN_SET_COLOR, arg);
+ dispatch(FuncRequest(LFUN_SET_COLOR, arg));
continue;
}
#include "FuncStatus.h"
#include "BufferView.h"
#include "buffer.h"
-#include "LyXAction.h"
+#include "funcrequest.h"
#include "MathsSymbols.h"
#include "gettext.h"
#include "Tooltips.h"
#include FORMS_H_LOCATION
#include "combox.h"
#include "ToolbarDefaults.h"
+#include "LyXAction.h"
#include "support/LAssert.h"
#include "support/filetools.h"
// this one is not "C" because combox callbacks are really C++ %-|
void Toolbar::Pimpl::layoutSelectedCB(int, void * arg, Combox *)
{
- Toolbar::Pimpl * tb = reinterpret_cast<Toolbar::Pimpl *>(arg);
-
- tb->layoutSelected();
+ reinterpret_cast<Toolbar::Pimpl *>(arg)->layoutSelected();
}
for (LyXTextClass::const_iterator cit = tc.begin();
cit != end; ++cit) {
if (_((*cit)->name()) == layoutguiname) {
- owner_->getLyXFunc()->dispatch(LFUN_LAYOUT, (*cit)->name());
+ owner_->getLyXFunc()->dispatch(FuncRequest(LFUN_LAYOUT, (*cit)->name()));
return;
}
}
--- /dev/null
+#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
+
+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>
* inset.h:
#include "support/lstrings.h"
#include "frontends/Painter.h"
#include "frontends/mouse_state.h"
-#include "commandtags.h"
+#include "funcrequest.h"
#include "support/lstrings.h"
#include "gettext.h"
#include "lyxfont.h"
/// An updatable inset could handle lyx editing commands
UpdatableInset::RESULT
-UpdatableInset::localDispatch(BufferView * bv,
- kb_action action, string const & arg)
+UpdatableInset::localDispatch(BufferView * bv, FuncRequest const & ev)
{
- if (!arg.empty() && (action==LFUN_SCROLL_INSET)) {
- if (arg.find('.') != arg.npos) {
- float const xx = static_cast<float>(strToDbl(arg));
+ if (!ev.argument.empty() && ev.action == LFUN_SCROLL_INSET) {
+ if (ev.argument.find('.') != ev.argument.npos) {
+ float const xx = static_cast<float>(strToDbl(ev.argument));
scroll(bv, xx);
} else {
- int const xx = strToInt(arg);
+ int const xx = strToInt(ev.argument);
scroll(bv, xx);
}
bv->updateInset(this, false);
#include <vector>
#include "LString.h"
-#include "commandtags.h"
+#include "LColor.h"
#include "frontends/mouse_state.h"
#include "WordLangTuple.h"
-#include "LColor.h"
class LyXFont;
class BufferView;
class LyXLex;
class Paragraph;
class LyXCursor;
+class FuncRequest;
struct LaTeXFeatures;
bool /*lr*/ = false)
{ return false; }
/// 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_; }
///
UpdatableInset::RESULT
-InsetCollapsable::localDispatch(BufferView * bv, kb_action action,
- string const & arg)
+InsetCollapsable::localDispatch(BufferView * bv, FuncRequest const & ev)
{
- UpdatableInset::RESULT result = inset.localDispatch(bv, action, arg);
+ UpdatableInset::RESULT result = inset.localDispatch(bv, ev);
if (result >= FINISHED)
bv->unlockInset(this);
first_after_edit = false;
///
void insetMotionNotify(BufferView *, int, int, mouse_button::state);
///
- UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
- string const &);
+ UpdatableInset::RESULT localDispatch(BufferView *, FuncRequest const &);
///
int latex(Buffer const *, std::ostream &,
bool fragile, bool free_spc) const;
#include "BufferView.h"
#include "frontends/LyXView.h"
#include "lyxtext.h"
+#include "funcrequest.h"
#include "debug.h"
#include "lyxrow.h"
#include "lyxlex.h"
UpdatableInset::RESULT
-InsetERT::localDispatch(BufferView * bv, kb_action action, string const & arg)
+InsetERT::localDispatch(BufferView * bv, FuncRequest const & ev)
{
UpdatableInset::RESULT result = DISPATCHED_NOUPDATE;
set_latex_font(bv);
}
- switch (action) {
+ switch (ev.action) {
case LFUN_LAYOUT:
bv->owner()->setLayout(inset.paragraph()->layout()->name());
break;
default:
- result = InsetCollapsable::localDispatch(bv, action, arg);
+ result = InsetCollapsable::localDispatch(bv, ev);
}
- switch (action) {
+ switch (ev.action) {
case LFUN_BREAKPARAGRAPH:
case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
case LFUN_BACKSPACE:
///
void validate(LaTeXFeatures &) const {}
///
- UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
- string const &);
+ UpdatableInset::RESULT localDispatch(BufferView *, FuncRequest const &);
///
bool checkInsertChar(LyXFont &);
///
#include "BufferView.h"
#include "frontends/LyXView.h"
#include "support/LOstream.h"
-#include "commandtags.h"
+#include "funcrequest.h"
#include "buffer.h"
#include "gettext.h"
#include "lyxfunc.h"
void InsetParent::edit(BufferView * bv, int, int, mouse_button::state)
{
bv->owner()->getLyXFunc()->
- dispatch(LFUN_CHILDOPEN, getContents());
+ dispatch(FuncRequest(LFUN_CHILDOPEN, getContents()));
}
#include "insetref.h"
#include "buffer.h"
-#include "commandtags.h"
+#include "funcrequest.h"
#include "debug.h"
#include "gettext.h"
#include "LaTeXFeatures.h"
: InsetCommand(p), isLatex(buf.isLatex())
{}
+
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)
bv->owner()->getLyXFunc()->
- dispatch(LFUN_REF_GOTO, getContents());
+ dispatch(FuncRequest(LFUN_REF_GOTO, getContents()));
else if (button == mouse_button::button1)
bv->owner()->getDialogs()->showRef(this);
}
void InsetRef::edit(BufferView *, bool)
-{
-}
+{}
string const InsetRef::getScreenLabel(Buffer const *) const
#include "lyxlength.h"
#include "ParagraphParameters.h"
#include "lyxlex.h"
+#include "funcrequest.h"
#include "frontends/Dialogs.h"
#include "frontends/Alert.h"
the_locking_inset = 0;
}
if (button == mouse_button::button2) {
- localDispatch(bv, LFUN_PASTESELECTION, "paragraph");
+ localDispatch(bv, FuncRequest(LFUN_PASTESELECTION, "paragraph"));
return;
}
if (inset_hit && bv->theLockingInset()) {
UpdatableInset::RESULT
-InsetTabular::localDispatch(BufferView * bv, kb_action action,
- string const & arg)
+InsetTabular::localDispatch(BufferView * bv, FuncRequest const & ev)
{
// We need to save the value of the_locking_inset as the call to
// the_locking_inset->LocalDispatch might unlock it.
old_locking_inset = the_locking_inset;
UpdatableInset::RESULT result =
- UpdatableInset::localDispatch(bv, action, arg);
+ UpdatableInset::localDispatch(bv, ev);
if (result == DISPATCHED || result == DISPATCHED_NOUPDATE) {
resetPos(bv);
return result;
}
- if ((action < 0) && arg.empty())
+ if (ev.action < 0 && ev.argument.empty())
return FINISHED;
bool hs = hasSelection();
// this one have priority over the locked InsetText, if we're not already
// inside another tabular then that one get's priority!
if (getFirstLockingInsetOfType(Inset::TABULAR_CODE) == this) {
- switch (action) {
+ switch (ev.action) {
case LFUN_SHIFT_TAB:
case LFUN_TAB:
hideInsetCursor(bv);
unlockInsetInInset(bv, the_locking_inset);
- if (action == LFUN_TAB)
+ if (ev.action == LFUN_TAB)
moveNextCell(bv, old_locking_inset != 0);
else
movePrevCell(bv, old_locking_inset != 0);
}
}
+ kb_action action = ev.action;
+ string arg = ev.argument;
if (the_locking_inset) {
- result = the_locking_inset->localDispatch(bv, action, arg);
+ result = the_locking_inset->localDispatch(bv, ev);
if (result == DISPATCHED_NOUPDATE) {
int sc = scroll();
resetPos(bv);
case LFUN_DEFAULT:
case LFUN_UNDERLINE:
case LFUN_FONT_SIZE:
- if (bv->dispatch(action, arg))
+ if (bv->dispatch(FuncRequest(action, arg)))
result = DISPATCHED;
break;
default:
if (activateCellInset(bv)) {
// reset need_update setted in above function!
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)) {
unlockInsetInInset(bv, the_locking_inset);
nodraw(false);
///
void insetMotionNotify(BufferView *, int, int, mouse_button::state);
///
- UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
- string const &);
+ UpdatableInset::RESULT localDispatch(BufferView *, FuncRequest const &);
///
int latex(Buffer const *, std::ostream &, bool, bool) const;
///
#include "lyxlex.h"
#include "debug.h"
#include "lyxfont.h"
-#include "commandtags.h"
#include "buffer.h"
#include "frontends/LyXView.h"
#include "BufferView.h"
#include "ParagraphParameters.h"
#include "undo_funcs.h"
#include "lyxfind.h"
+#include "funcrequest.h"
#include "frontends/Alert.h"
#include "frontends/Dialogs.h"
if (bv->theLockingInset()) {
if (isHighlyEditableInset(inset)) {
// We just have to lock the inset before calling a
- // PressEvent on it!
+ // PressFuncRequest on it!
UpdatableInset * uinset = static_cast<UpdatableInset*>(inset);
if (!bv->lockInset(uinset)) {
lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
if (!inset) { // && (button == mouse_button::button2)) {
bool paste_internally = false;
if ((button == mouse_button::button2) && getLyXText(bv)->selection.set()) {
- localDispatch(bv, LFUN_COPY, "");
+ localDispatch(bv, FuncRequest(LFUN_COPY));
paste_internally = true;
}
bool clear = false;
// insert this
if (button == mouse_button::button2) {
if (paste_internally)
- localDispatch(bv, LFUN_PASTE, "");
+ localDispatch(bv, FuncRequest(LFUN_PASTE));
else
- localDispatch(bv, LFUN_PASTESELECTION,
- "paragraph");
+ localDispatch(bv, FuncRequest(LFUN_PASTESELECTION, "paragraph"));
}
} else {
getLyXText(bv)->clearSelection();
UpdatableInset::RESULT
-InsetText::localDispatch(BufferView * bv,
- kb_action action, string const & arg)
+InsetText::localDispatch(BufferView * bv, FuncRequest const & ev)
{
bool was_empty = par->size() == 0 && !par->next();
no_selection = false;
UpdatableInset::RESULT
- result= UpdatableInset::localDispatch(bv, action, arg);
- if (result != UNDISPATCHED) {
+ result= UpdatableInset::localDispatch(bv, ev);
+ if (result != UNDISPATCHED)
return DISPATCHED;
- }
result = DISPATCHED;
- if ((action < 0) && arg.empty())
+ if (ev.action < 0 && ev.argument.empty())
return FINISHED;
if (the_locking_inset) {
- result = the_locking_inset->localDispatch(bv, action, arg);
+ result = the_locking_inset->localDispatch(bv, ev);
if (result == DISPATCHED_NOUPDATE)
return result;
else if (result == DISPATCHED) {
}
int updwhat = 0;
int updflag = false;
- switch (action) {
+ switch (ev.action) {
// Normal chars
case LFUN_SELFINSERT:
if (bv->buffer()->isReadonly()) {
// setErrorMessage(N_("Document is read only"));
break;
}
- if (!arg.empty()) {
+ if (!ev.argument.empty()) {
/* Automatically delete the currently selected
* text and replace it with what is being
* typed in now. Depends on lyxrc settings
}
}
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().
- TranslateAndInsert(arg[i], lt);
+ TranslateAndInsert(ev.argument[i], lt);
}
}
lt->selection.cursor = lt->cursor;
if (clip.empty())
break;
- if (arg == "paragraph") {
+ if (ev.argument == "paragraph") {
lt->insertStringAsParagraphs(bv, clip);
} else {
lt->insertStringAsLines(bv, clip);
// and current buffer's textclass (number). */
LyXTextClass const & tclass =
bv->buffer()->params.getLyXTextClass();
- string layout = arg;
+ string layout = ev.argument;
bool hasLayout = tclass.hasLayout(layout);
// If the entry is obsolete, use the new one instead.
// see if we found the layout number:
if (!hasLayout) {
- string const msg = string(N_("Layout ")) + arg + N_(" not known");
- bv->owner()->getLyXFunc()->dispatch(LFUN_MESSAGE, msg);
+ FuncRequest lf(LFUN_MESSAGE, N_("Layout ") + ev.argument + N_(" not known"));
+ bv->owner()->getLyXFunc()->dispatch(lf);
break;
}
cur_value = par->params().spacing().getValue();
}
- istringstream istr(arg.c_str());
+ istringstream istr(ev.argument.c_str());
string tmp;
istr >> tmp;
Spacing::Space new_spacing = cur_spacing;
new_spacing = Spacing::Default;
} else {
lyxerr << _("Unknown spacing argument: ")
- << arg << endl;
+ << ev.argument << endl;
}
if (cur_spacing != new_spacing || cur_value != new_value) {
par->params().spacing(Spacing(new_spacing, new_value));
break;
default:
- if (!bv->dispatch(action, arg))
+ if (!bv->dispatch(ev))
result = UNDISPATCHED;
break;
}
///
void insetMotionNotify(BufferView *, int, int, mouse_button::state);
///
- UpdatableInset::RESULT localDispatch(BufferView *,
- kb_action, string const &);
+ UpdatableInset::RESULT localDispatch(BufferView *, FuncRequest const &);
///
int latex(Buffer const *, std::ostream &,
bool fragile, bool free_spc) const;
<< endl;
}
// Do nothing if we have nothing (JMarc)
- if ( ! keysym->isOK() ) {
+ if (!keysym->isOK()) {
lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
<< endl;
return;
if (c != 0)
argument = c;
- dispatch(LFUN_SELFINSERT, argument);
+ dispatch(FuncRequest(LFUN_SELFINSERT, argument));
lyxerr[Debug::KEY] << "SelfInsert arg[`"
<< argument << "']" << endl;
} else {
FuncStatus LyXFunc::getStatus(int ac) const
{
- kb_action action;
string argument;
- action = lyxaction.retrieveActionArg(ac, argument);
- return getStatus(action, argument);
+ kb_action action = lyxaction.retrieveActionArg(ac, argument);
+ return getStatus(FuncRequest(action, argument));
}
-FuncStatus LyXFunc::getStatus(kb_action action,
- string const & argument) const
+FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
{
FuncStatus flag;
Buffer * buf = owner->buffer();
- if (action == LFUN_NOACTION) {
+ if (ev.action == LFUN_NOACTION) {
setStatusMessage(N_("Nothing to do"));
return flag.disabled(true);
}
- if (action == LFUN_UNKNOWN_ACTION) {
+ if (ev.action == LFUN_UNKNOWN_ACTION) {
setStatusMessage(N_("Unknown action"));
return flag.unknown(true);
}
setStatusMessage(N_("Command disabled"));
// 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?
if (buf) {
// yes
// Can we use a readonly buffer?
if (buf->isReadonly() &&
- !lyxaction.funcHasFlag(action,
+ !lyxaction.funcHasFlag(ev.action,
LyXAction::ReadOnly)) {
// no
setStatusMessage(N_("Document is read-only"));
// I would really like to avoid having this switch and rather try to
// encode this in the function itself.
bool disable = false;
- switch (action) {
+ switch (ev.action) {
case LFUN_MENUPRINT:
disable = !Exporter::IsExportable(buf, "dvi")
|| lyxrc.print_command == "none";
break;
case LFUN_EXPORT:
- disable = argument == "fax" &&
- !Exporter::IsExportable(buf, argument);
+ disable = ev.argument == "fax" &&
+ !Exporter::IsExportable(buf, ev.argument);
break;
case LFUN_UNDO:
disable = buf->undostack.empty();
//ret.disabled(true);
if (tli->lyxCode() == Inset::TABULAR_CODE) {
ret = static_cast<InsetTabular *>(tli)
- ->getStatus(argument);
+ ->getStatus(ev.argument);
} else if (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
ret = static_cast<InsetTabular *>
(tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE))
- ->getStatus(argument);
+ ->getStatus(ev.argument);
}
flag |= ret;
disable = false;
FuncStatus ret;
disable = true;
- ret = inset.getStatus(argument);
+ ret = inset.getStatus(ev.argument);
if (ret.onoff(true) || ret.onoff(false))
flag.setOnOff(false);
}
break;
case LFUN_BOOKMARK_GOTO:
disable = !owner->view()->
- isSavedPosition(strToUnsignedInt(argument));
+ isSavedPosition(strToUnsignedInt(ev.argument));
break;
case LFUN_INSET_TOGGLE: {
LyXText * lt = owner->view()->getLyXText();
disable = true;
break;
}
- if (argument.empty()) {
+ if (ev.argument.empty()) {
flag.clear();
break;
}
- if (!contains("tcb", argument[0])) {
+ if (!contains("tcb", ev.argument[0])) {
disable = true;
break;
}
- flag.setOnOff(argument[0] == align);
+ flag.setOnOff(ev.argument[0] == align);
} else
disable = true;
break;
disable = true;
break;
}
- if (argument.empty()) {
+ if (ev.argument.empty()) {
flag.clear();
break;
}
- if (!contains("lcr", argument[0])) {
+ if (!contains("lcr", ev.argument[0])) {
disable = true;
break;
}
- flag.setOnOff(argument[0] == align);
+ flag.setOnOff(ev.argument[0] == align);
} else
disable = true;
break;
case LFUN_MATH_MUTATE:
if (tli && (tli->lyxCode() == Inset::MATH_CODE))
- flag.setOnOff(mathcursor->formula()->hullType() == argument);
+ flag.setOnOff(mathcursor->formula()->hullType() == ev.argument);
else
disable = true;
break;
// the functions which insert insets
Inset::Code code = Inset::NO_CODE;
- switch (action) {
+ switch (ev.action) {
case LFUN_INSET_ERT:
code = Inset::ERT_CODE;
break;
flag.disabled(true);
// A few general toggles
- switch (action) {
+ switch (ev.action) {
case LFUN_TOOLTIPS_TOGGLE:
flag.setOnOff(owner->getDialogs()->tooltipsEnabled());
break;
case LFUN_SWITCHBUFFER:
// toggle on the current buffer, but do not toggle off
// the other ones (is that a good idea?)
- if (argument == buf->fileName())
+ if (ev.argument == buf->fileName())
flag.setOnOff(true);
break;
default:
// the font related toggles
if (!mathcursor) {
LyXFont const & font = TEXT(false)->real_current_font;
- switch (action) {
+ switch (ev.action) {
case LFUN_EMPH:
flag.setOnOff(font.emph() == LyXFont::ON);
break;
}
} else {
string tc = mathcursor->getLastCode();
- switch (action) {
+ switch (ev.action) {
case LFUN_BOLD:
flag.setOnOff(tc == "mathbf");
break;
// this one is difficult to get right. As a half-baked
// solution, we consider only the first action of the sequence
- if (action == LFUN_SEQUENCE) {
+ if (ev.action == LFUN_SEQUENCE) {
// argument contains ';'-terminated commands
- const int ac = lyxaction.LookupFunc(token(argument, ';', 0));
- flag = getStatus(ac);
+ flag = getStatus(lyxaction.LookupFunc(token(ev.argument, ';', 0)));
}
return flag;
{
string 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
- <<"] arg[" << argument << "]" << endl;
+ lyxerr[Debug::ACTION] << "LyXFunc::dispatch: action[" << ev.action
+ <<"] arg[" << ev.argument << "]" << endl;
// we have not done anything wrong yet.
errorstat = false;
if (owner->view()->available())
owner->view()->hideCursor();
+ string argument = ev.argument;
+ kb_action action = ev.action;
+
// We cannot use this function here
- if (getStatus(action, argument).disabled()) {
+ if (getStatus(ev).disabled()) {
lyxerr[Debug::ACTION] << "LyXFunc::dispatch: "
<< lyxaction.getActionName(action)
<< " [" << action << "] is disabled at this location"
goto exit_with_message;
} else if (((result=inset->
// Hand-over to inset's own dispatch:
- localDispatch(owner->view().get(), action, argument)) ==
+ localDispatch(owner->view().get(), FuncRequest(action, argument))) ==
UpdatableInset::DISPATCHED) ||
(result == UpdatableInset::DISPATCHED_NOUPDATE))
goto exit_with_message;
// passthrough hat and underscore outside mathed:
case LFUN_SUBSCRIPT:
- dispatch(LFUN_SELFINSERT, "_", false);
+ dispatch(FuncRequest(LFUN_SELFINSERT, "_"));
break;
case LFUN_SUPERSCRIPT:
- dispatch(LFUN_SELFINSERT, "^", false);
+ dispatch(FuncRequest(LFUN_SELFINSERT, "^"));
break;
case LFUN_MATH_PANEL:
} else {
p.setContents(argument);
}
- dispatch(LFUN_CITATION_INSERT, p.getAsString());
+ dispatch(FuncRequest(LFUN_CITATION_INSERT, p.getAsString()));
} else
owner->getDialogs()->createCitation(p.getAsString());
}
default:
// Then if it was none of the above
// Trying the BufferView::pimpl dispatch:
- if (!owner->view()->dispatch(action, argument))
+ if (!owner->view()->dispatch(ev))
lyxerr << "A truly unknown func ["
- << lyxaction.getActionName(action) << "]!"
+ << lyxaction.getActionName(ev.action) << "]!"
<< endl;
break;
} // end of switch
exit_with_message:
- string const & msg = getMessage();
- sendDispatchMessage(msg, action, argument, verbose);
+ sendDispatchMessage(getMessage(), ev, 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->updateToolbar();
- if (action == LFUN_SELFINSERT || !verbose) {
+ if (ev.action == LFUN_SELFINSERT || !verbose) {
lyxerr[Debug::ACTION] << "dispatch msg is " << msg << endl;
if (!msg.empty())
owner->message(msg);
return;
}
- string dispatch_msg(msg);
+ string dispatch_msg = msg;
if (!dispatch_msg.empty())
dispatch_msg += " ";
- string comname = lyxaction.getActionName(action);
+ string comname = lyxaction.getActionName(ev.action);
- int pseudoaction = action;
+ int pseudoaction = ev.action;
bool argsadded = false;
- if (!arg.empty()) {
+ if (!ev.argument.empty()) {
// the pseudoaction is useful for the bindings
- pseudoaction = lyxaction.searchActionArg(action, arg);
+ pseudoaction = lyxaction.searchActionArg(ev.action, ev.argument);
if (pseudoaction == LFUN_UNKNOWN_ACTION) {
- pseudoaction = action;
+ pseudoaction = ev.action;
} else {
- comname += " " + arg;
+ comname += " " + ev.argument;
argsadded = true;
}
}
if (!shortcuts.empty()) {
comname += ": " + shortcuts;
- } else if (!argsadded && !arg.empty()) {
- comname += " " + arg;
+ } else if (!argsadded && !ev.argument.empty()) {
+ comname += " " + ev.argument;
}
if (!comname.empty()) {
#endif
-#include "commandtags.h" // for kb_action enum
#include "FuncStatus.h"
#include "kbsequence.h"
+#include "commandtags.h"
#include "LString.h"
#include <boost/signals/trackable.hpp>
class LyXView;
class LyXText;
+class FuncRequest;
/** This class encapsulates all the LyX command operations.
LyXFunc(LyXView *);
/// 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
void dispatch(string const & s, bool verbose = false);
/// can contain the string argument.
FuncStatus getStatus(int ac) const;
///
- FuncStatus getStatus(kb_action action,
- string const & argument = string()) const;
+ FuncStatus getStatus(FuncRequest const & action) const;
/// The last key was meta
bool wasMetaKey() const;
mutable string status_buffer;
/// 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)
break;
}
- if ((action = lyxaction.LookupFunc(cmd))>= 0) {
+ if ((action = lyxaction.LookupFunc(cmd)) >= 0) {
if (lyxerr.debugging(Debug::LYXRC)) {
lyxerr << "RC_BIND: Sequence `"
<< seq << "' Command `"
#include <config.h>
#include "formula.h"
-#include "commandtags.h"
#include "math_cursor.h"
#include "math_parser.h"
#include "math_charinset.h"
#include "gettext.h"
#include "debug.h"
#include "lyxrc.h"
+#include "funcrequest.h"
#include "support/LOstream.h"
#include "support/LAssert.h"
UpdatableInset::RESULT
-InsetFormula::localDispatch(BufferView * bv, kb_action action,
- string const & arg)
+InsetFormula::localDispatch(BufferView * bv, FuncRequest const & ev)
{
RESULT result = DISPATCHED;
- switch (action) {
+ switch (ev.action) {
case LFUN_BREAKLINE:
bv->lockedInsetStoreUndo(Undo::INSERT);
MathCursor::row_type row = mathcursor->hullRow();
string old_label = hull()->label(row);
- string new_label = arg;
+ string new_label = ev.argument;
if (new_label.empty()) {
string const default_label =
int x;
int y;
mathcursor->getPos(x, y);
- mutate(arg);
+ mutate(ev.argument);
mathcursor->setPos(x, y);
mathcursor->normalize();
updateLocal(bv, true);
{
bv->lockedInsetStoreUndo(Undo::EDIT);
if (mathcursor)
- mathcursor->handleExtern(arg);
+ mathcursor->handleExtern(ev.argument);
// re-compute inset dimension
metrics(bv);
updateLocal(bv, true);
case LFUN_PASTESELECTION:
{
string const clip = bv->getClipboard();
- if (!clip.empty())
+ if (!clip.empty())
mathed_parse_normal(par_, clip);
break;
}
default:
- result = InsetFormulaBase::localDispatch(bv, action, arg);
+ result = InsetFormulaBase::localDispatch(bv, ev);
}
return result;
///
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;
///
#include "formula.h"
#include "formulamacro.h"
#include "lyxrc.h"
-#include "commandtags.h"
+#include "funcrequest.h"
#include "BufferView.h"
#include "lyxtext.h"
#include "lyxfunc.h"
UpdatableInset::RESULT
-InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
- string const & arg)
+InsetFormulaBase::localDispatch(BufferView * bv, FuncRequest const & ev)
{
//lyxerr << "InsetFormulaBase::localDispatch: act: " << action
// << " arg: '" << arg
if (!mathcursor)
return UNDISPATCHED;
- string argument = arg;
+ string argument = ev.argument;
RESULT result = DISPATCHED;
bool sel = false;
bool was_macro = mathcursor->inMacroMode();
mathcursor->normalize();
mathcursor->touch();
- switch (action) {
+ switch (ev.action) {
case LFUN_WORDRIGHTSEL:
case LFUN_RIGHTSEL:
lyxerr << "LFUN_SETXY broken!\n";
int x = 0;
int y = 0;
- istringstream is(arg.c_str());
+ istringstream is(ev.argument.c_str());
is >> x >> y;
mathcursor->setPos(x, y);
updateLocal(bv, false);
// Special casing for superscript in case of LyX handling
// dead-keys:
case LFUN_CIRCUMFLEX:
- if (arg.empty()) {
+ if (ev.argument.empty()) {
// do superscript if LyX handles
// deadkeys
bv->lockedInsetStoreUndo(Undo::EDIT);
break;
// Math fonts
- case LFUN_GREEK_TOGGLE: handleFont(bv, arg, "lyxgreek"); break;
- case LFUN_BOLD: handleFont(bv, arg, "textbf"); break;
- case LFUN_SANS: handleFont(bv, arg, "textsf"); break;
- case LFUN_EMPH: handleFont(bv, arg, "mathcal"); break;
- case LFUN_ROMAN: handleFont(bv, arg, "mathrm"); break;
- case LFUN_CODE: handleFont(bv, arg, "texttt"); break;
- case LFUN_FRAK: handleFont(bv, arg, "mathfrak"); break;
- case LFUN_ITAL: handleFont(bv, arg, "mathit"); break;
- case LFUN_NOUN: handleFont(bv, arg, "mathbb"); break;
- case LFUN_DEFAULT: handleFont(bv, arg, "textnormal"); break;
- case LFUN_FREE: handleFont(bv, arg, "textrm"); break;
+ case LFUN_GREEK_TOGGLE: handleFont(bv, ev.argument, "lyxgreek"); break;
+ case LFUN_BOLD: handleFont(bv, ev.argument, "textbf"); break;
+ case LFUN_SANS: handleFont(bv, ev.argument, "textsf"); break;
+ case LFUN_EMPH: handleFont(bv, ev.argument, "mathcal"); break;
+ case LFUN_ROMAN: handleFont(bv, ev.argument, "mathrm"); break;
+ case LFUN_CODE: handleFont(bv, ev.argument, "texttt"); break;
+ case LFUN_FRAK: handleFont(bv, ev.argument, "mathfrak"); break;
+ case LFUN_ITAL: handleFont(bv, ev.argument, "mathit"); break;
+ case LFUN_NOUN: handleFont(bv, ev.argument, "mathbb"); break;
+ case LFUN_DEFAULT: handleFont(bv, ev.argument, "textnormal"); break;
+ case LFUN_FREE: handleFont(bv, ev.argument, "textrm"); break;
case LFUN_GREEK:
- handleFont(bv, arg, "lyxgreek1");
- if (arg.size())
- mathcursor->interpret(arg);
+ handleFont(bv, ev.argument, "lyxgreek1");
+ if (ev.argument.size())
+ mathcursor->interpret(ev.argument);
break;
case LFUN_MATH_MODE:
if (mathcursor->currentMode()) {
- handleFont(bv, arg, "textrm");
+ handleFont(bv, ev.argument, "textrm");
} else {
mathcursor->niceInsert(MathAtom(new MathHullInset("simple")));
updateLocal(bv, true);
break;
case LFUN_INSERT_MATRIX:
- if (!arg.empty()) {
+ if (!ev.argument.empty()) {
bv->lockedInsetStoreUndo(Undo::EDIT);
- mathcursor->interpret("matrix " + arg);
+ mathcursor->interpret("matrix " + ev.argument);
updateLocal(bv, true);
}
break;
case LFUN_SUBSCRIPT:
{
bv->lockedInsetStoreUndo(Undo::EDIT);
- mathcursor->script(action == LFUN_SUPERSCRIPT);
+ mathcursor->script(ev.action == LFUN_SUPERSCRIPT);
updateLocal(bv, true);
break;
}
{
//lyxerr << "formulabase::LFUN_MATH_DELIM, arg: '" << arg << "'\n";
string ls;
- string rs = split(arg, ls, ' ');
+ string rs = split(ev.argument, ls, ' ');
// Reasonable default values
if (ls.empty())
ls = '(';
if (p) {
mathcursor->popToEnclosingGrid();
bv->lockedInsetStoreUndo(Undo::EDIT);
- char align = arg.size() ? arg[0] : 'c';
- switch (action) {
+ char align = ev.argument.size() ? ev.argument[0] : 'c';
+ switch (ev.action) {
case LFUN_MATH_HALIGN: p->halign(align, p->col(idx)); break;
case LFUN_MATH_VALIGN: p->valign(align); break;
case LFUN_MATH_ROW_INSERT: p->addRow(p->row(idx)); break;
// updateInset(inset, true);
//}
//
- if (arg.empty()) {
+ if (ev.argument.empty()) {
InsetCommandParams p("ref");
bv->owner()->getDialogs()->createRef(p.getAsString());
} else {
//mathcursor->handleNest(new InsetRef2);
//mathcursor->insert(arg);
- mathcursor->insert(MathAtom(new RefInset(arg)));
+ mathcursor->insert(MathAtom(new RefInset(ev.argument)));
}
updateLocal(bv, true);
break;
// always changing to mathrm when opening an inlined inset
// -- I really hate "LyXfunc overloading"...
if (display)
- f->localDispatch(bv, LFUN_MATH_DISPLAY, string());
- f->localDispatch(bv, LFUN_INSERT_MATH, arg);
+ f->localDispatch(bv, FuncRequest(LFUN_MATH_DISPLAY));
+ f->localDispatch(bv, FuncRequest(LFUN_INSERT_MATH, arg));
}
} else {
// create a macro if we see "\\newcommand" somewhere, and an ordinary
InsetFormula * f = new InsetFormula(bv);
if (openNewInset(bv, f)) {
f->mutate("simple");
- bv->theLockingInset()->localDispatch(bv, LFUN_MATH_DELIM, arg);
+ bv->theLockingInset()->localDispatch(bv, FuncRequest(LFUN_MATH_DELIM, arg));
}
}
InsetFormula * f = new InsetFormula(bv);
if (openNewInset(bv, f)) {
f->mutate("simple");
- bv->theLockingInset()->localDispatch(bv, LFUN_INSERT_MATRIX, arg);
+ bv->theLockingInset()->localDispatch(bv, FuncRequest(LFUN_INSERT_MATRIX, arg));
}
}
InsetFormula * f = new InsetFormula(bv);
if (openNewInset(bv, f)) {
f->mutate("simple");
- bv->theLockingInset()->localDispatch(bv, LFUN_INSERT_MATH, arg);
+ bv->theLockingInset()->localDispatch(bv, FuncRequest(LFUN_INSERT_MATH, arg));
}
}
InsetFormula * f = new InsetFormula(bv);
if (openNewInset(bv, f)) {
f->mutate("simple");
- bv->theLockingInset()->localDispatch(bv, LFUN_GREEK, arg);
+ bv->theLockingInset()->localDispatch(bv, FuncRequest(LFUN_GREEK, arg));
bv->unlockInset(f);
}
}
#include "lyxfont.h"
#include <boost/weak_ptr.hpp>
-
#include <iosfwd>
class Buffer;
virtual void insetUnlock(BufferView *);
/// 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;
//
void mathDispatchMathImportSelection(BufferView *, string const &);
//
-void mathDispatch(BufferView *, kb_action, string const &);
+void mathDispatch(BufferView *, FuncRequest const &);
//
void mathDispatch(BufferView *, string const &);
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
fontinfo fontinfos[] = {
{"mathnormal",
#include "ref_inset.h"
#include "math_cursor.h"
-#include "commandtags.h"
+#include "funcrequest.h"
#include "formulabase.h"
#include "BufferView.h"
#include "frontends/LyXView.h"
if (cmd == "mouse-3-release") {
lyxerr << "trying to goto ref" << cell(0) << "\n";
mathcursor->formula()->view()->owner()->getLyXFunc()->
- dispatch(LFUN_REF_GOTO, asString(cell(0)));
+ dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
return 1; // dispatched
}
if (cmd == "mouse-1-release") {
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()
// ->showRef(this);
return 1; // dispatched
void TocItem::goTo(LyXView & lv_) const
{
string const tmp = tostr(par->id());
- lv_.getLyXFunc()->dispatch(LFUN_GOTO_PARAGRAPH, tmp, false);
+ lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_GOTO_PARAGRAPH, tmp));
}