mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
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:
parent
658ab90d1c
commit
b8198905dc
@ -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);
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
#include "LString.h"
|
||||
#include "undo.h"
|
||||
#include "commandtags.h"
|
||||
|
||||
#include "insets/inset.h"
|
||||
#include "WordLangTuple.h"
|
||||
@ -203,7 +202,7 @@ public:
|
||||
///
|
||||
void stuffClipboard(string const &) const;
|
||||
///
|
||||
bool dispatch(kb_action action, string const & argument);
|
||||
bool dispatch(FuncRequest const & argument);
|
||||
private:
|
||||
///
|
||||
struct Pimpl;
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "gettext.h"
|
||||
#include "ParagraphParameters.h"
|
||||
#include "undo_funcs.h"
|
||||
#include "funcrequest.h"
|
||||
|
||||
#include "insets/insetbib.h"
|
||||
#include "insets/insettext.h"
|
||||
@ -617,8 +618,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
|
||||
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;
|
||||
}
|
||||
@ -734,7 +734,7 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
|
||||
// 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);
|
||||
@ -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["
|
||||
<< 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:
|
||||
{
|
||||
@ -1542,13 +1542,8 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
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();
|
||||
@ -1621,28 +1616,28 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
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;
|
||||
@ -1650,8 +1645,8 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
|
||||
// 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) {
|
||||
@ -1662,7 +1657,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
|
||||
if (!hasLayout) {
|
||||
owner_->getLyXFunc()->setErrorMessage(
|
||||
string(N_("Layout ")) + argument +
|
||||
string(N_("Layout ")) + ev.argument +
|
||||
N_(" not known"));
|
||||
break;
|
||||
}
|
||||
@ -1699,7 +1694,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
break;
|
||||
|
||||
case LFUN_LANGUAGE:
|
||||
lang(bv_, argument);
|
||||
lang(bv_, ev.argument);
|
||||
switchKeyMap();
|
||||
owner_->view_state_changed();
|
||||
break;
|
||||
@ -1745,7 +1740,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
break;
|
||||
|
||||
case LFUN_FONT_SIZE:
|
||||
fontSize(bv_, argument);
|
||||
fontSize(bv_, ev.argument);
|
||||
owner_->view_state_changed();
|
||||
break;
|
||||
|
||||
@ -1817,16 +1812,16 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
|
||||
|
||||
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))
|
||||
@ -1837,16 +1832,16 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
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));
|
||||
@ -2657,7 +2652,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
cur_value = par->params().spacing().getValue();
|
||||
}
|
||||
|
||||
istringstream istr(argument.c_str());
|
||||
istringstream istr(ev.argument.c_str());
|
||||
|
||||
string tmp;
|
||||
istr >> tmp;
|
||||
@ -2683,7 +2678,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
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));
|
||||
@ -2716,7 +2711,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
case LFUN_URL:
|
||||
{
|
||||
InsetCommandParams p;
|
||||
if (action == LFUN_HTMLURL)
|
||||
if (ev.action == LFUN_HTMLURL)
|
||||
p.setCmdName("htmlurl");
|
||||
else
|
||||
p.setCmdName("url");
|
||||
@ -2727,7 +2722,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
case LFUN_INSERT_URL:
|
||||
{
|
||||
InsetCommandParams p;
|
||||
p.setFromString(argument);
|
||||
p.setFromString(ev.argument);
|
||||
|
||||
InsetUrl * inset = new InsetUrl(p);
|
||||
if (!insertInset(inset))
|
||||
@ -2763,25 +2758,25 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
|
||||
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;
|
||||
|
||||
@ -2817,14 +2812,14 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
|
||||
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 =
|
||||
@ -2857,9 +2852,9 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -2901,13 +2896,13 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
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
|
||||
@ -2916,45 +2911,45 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
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))
|
||||
@ -2969,14 +2964,14 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
// 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;
|
||||
@ -2989,7 +2984,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
InsetBibtex * inset =
|
||||
static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
|
||||
if (inset) {
|
||||
inset->addDatabase(argument);
|
||||
inset->addDatabase(ev.argument);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -2999,7 +2994,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
InsetBibtex * inset =
|
||||
static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
|
||||
if (inset) {
|
||||
inset->delDatabase(argument);
|
||||
inset->delDatabase(ev.argument);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -3009,14 +3004,14 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
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_);
|
||||
}
|
||||
@ -3047,7 +3042,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
|
||||
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;
|
||||
@ -3058,7 +3053,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
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);
|
||||
@ -3072,19 +3067,19 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
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_,
|
||||
@ -3105,7 +3100,7 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
|
||||
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
|
||||
@ -3129,8 +3124,8 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
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);
|
||||
@ -3158,8 +3153,8 @@ bool BufferView::Pimpl::dispatch(kb_action action, string const & argument)
|
||||
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];
|
||||
@ -3265,7 +3260,8 @@ void BufferView::Pimpl::smartQuote()
|
||||
|
||||
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, "\""));
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
#define BUFFERVIEW_PIMPL_H
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "commandtags.h"
|
||||
#include "frontends/Timeout.h"
|
||||
#include "frontends/key_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);
|
||||
///
|
||||
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.
|
||||
|
@ -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>
|
||||
|
||||
* BufferView_pimpl.C (redoCurrentBuffer): fix screen update when
|
||||
|
13
src/LaTeX.C
13
src/LaTeX.C
@ -22,6 +22,7 @@
|
||||
#include "gettext.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "debug.h"
|
||||
#include "funcrequest.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/FileInfo.h"
|
||||
#include "support/lstrings.h"
|
||||
@ -197,7 +198,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
|
||||
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()();
|
||||
@ -233,7 +234,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
|
||||
// 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")));
|
||||
@ -248,7 +249,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
|
||||
// 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);
|
||||
@ -283,7 +284,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
|
||||
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()();
|
||||
@ -313,7 +314,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
|
||||
// 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")));
|
||||
@ -339,7 +340,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
|
||||
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()();
|
||||
|
@ -74,14 +74,14 @@ void LyXAction::init()
|
||||
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 },
|
||||
@ -483,10 +483,7 @@ int LyXAction::getPseudoAction(kb_action action, string const & arg) const
|
||||
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];
|
||||
@ -517,8 +514,8 @@ kb_action LyXAction::retrieveActionArg(int pseudo, string & arg) const
|
||||
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 "
|
||||
|
@ -8,12 +8,12 @@
|
||||
|
||||
#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:
|
||||
///
|
||||
@ -26,20 +26,13 @@ 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;
|
||||
///
|
||||
|
@ -18,10 +18,11 @@
|
||||
*/
|
||||
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 {
|
||||
|
@ -5,7 +5,7 @@
|
||||
* 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).
|
||||
*
|
||||
@ -42,7 +42,7 @@ class BufferParams;
|
||||
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.
|
||||
*/
|
||||
|
@ -123,7 +123,7 @@ public:
|
||||
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
|
||||
|
@ -25,6 +25,8 @@
|
||||
#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),
|
||||
@ -55,6 +57,7 @@ void ControlCommand::applyParamsToInset()
|
||||
|
||||
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()));
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "BufferView.h"
|
||||
#include "frontends/LyXView.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "funcrequest.h"
|
||||
|
||||
#include "support/forkedcontr.h"
|
||||
#include "support/lstrings.h"
|
||||
@ -65,7 +66,7 @@ void ControlForks::apply()
|
||||
|
||||
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();
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "gettext.h"
|
||||
#include "helper_funcs.h"
|
||||
#include "lyxrc.h"
|
||||
#include "funcrequest.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)
|
||||
{
|
||||
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!"),
|
||||
@ -92,7 +94,6 @@ bool ControlInclude::fileExists(string const & file)
|
||||
return true;
|
||||
|
||||
else
|
||||
Alert::alert(_("Warning!"),
|
||||
_("Specified file doesn't exist"));
|
||||
Alert::alert(_("Warning!"), _("Specified file doesn't exist"));
|
||||
return false;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "ControlRef.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "bufferlist.h"
|
||||
#include "funcrequest.h"
|
||||
|
||||
#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
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "ButtonControllerBase.h"
|
||||
#include "BufferView.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "funcrequest.h"
|
||||
|
||||
#include "frontends/LyXView.h"
|
||||
|
||||
@ -34,7 +35,7 @@ ControlTabularCreate::ControlTabularCreate(LyXView & lv, Dialogs & d)
|
||||
|
||||
ControlTabularCreate::rowsCols & ControlTabularCreate::params()
|
||||
{
|
||||
return params_;
|
||||
return params_;
|
||||
}
|
||||
|
||||
|
||||
@ -51,7 +52,6 @@ void ControlTabularCreate::apply()
|
||||
|
||||
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));
|
||||
}
|
||||
|
@ -15,12 +15,15 @@
|
||||
|
||||
#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());
|
||||
}
|
||||
@ -33,9 +36,10 @@ void LyXFileDialog::done(int what)
|
||||
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;
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ void Toolbar::Pimpl::changed_layout(string const & sel)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "debug.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "funcrequest.h"
|
||||
#include FORMS_H_LOCATION
|
||||
|
||||
#include "delim.xbm"
|
||||
@ -31,7 +32,8 @@
|
||||
|
||||
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",
|
||||
@ -91,9 +93,11 @@ void FormMathsDelim::apply()
|
||||
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);
|
||||
|
@ -23,6 +23,7 @@
|
||||
#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
|
||||
@ -99,9 +100,11 @@ void FormMathsMatrix::apply()
|
||||
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 ||
|
||||
@ -123,9 +126,9 @@ int FormMathsMatrix::AlignFilter(char const * cur, int c)
|
||||
{
|
||||
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;
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "MathsSymbols.h"
|
||||
#include "debug.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "funcrequest.h"
|
||||
|
||||
#include "forms/form_maths_deco.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
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "lyxrc.h"
|
||||
#include "LColor.h"
|
||||
#include "Lsstream.h"
|
||||
#include "funcrequest.h"
|
||||
|
||||
#include "combox.h"
|
||||
#include "Color.h"
|
||||
@ -436,7 +437,7 @@ void FormPreferences::Colors::apply()
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -488,6 +489,7 @@ void FormPreferences::Colors::build()
|
||||
setPrehandler(dialog_->radio_hsv);
|
||||
}
|
||||
|
||||
|
||||
string const
|
||||
FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
|
||||
{
|
||||
@ -682,7 +684,8 @@ void FormPreferences::Colors::InputRGB()
|
||||
|
||||
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();
|
||||
@ -742,7 +745,7 @@ void FormPreferences::Colors::LoadBrowserLyX()
|
||||
|
||||
string const arg = lcolor.getLyXName(lc) + " black";
|
||||
parent_.lv_->getLyXFunc()->
|
||||
dispatch(LFUN_SET_COLOR, arg);
|
||||
dispatch(FuncRequest(LFUN_SET_COLOR, arg));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -23,13 +23,14 @@
|
||||
#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"
|
||||
@ -155,9 +156,7 @@ void Toolbar::Pimpl::update()
|
||||
// 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();
|
||||
}
|
||||
|
||||
|
||||
@ -171,7 +170,7 @@ void Toolbar::Pimpl::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;
|
||||
}
|
||||
}
|
||||
|
30
src/funcrequest.h
Normal file
30
src/funcrequest.h
Normal 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
|
@ -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>
|
||||
|
||||
* inset.h:
|
||||
|
@ -20,7 +20,7 @@
|
||||
#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"
|
||||
@ -301,15 +301,14 @@ void UpdatableInset::scroll(BufferView * bv, int offset) const
|
||||
|
||||
/// 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);
|
||||
|
@ -17,10 +17,9 @@
|
||||
|
||||
#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;
|
||||
@ -30,6 +29,7 @@ class LyXText;
|
||||
class LyXLex;
|
||||
class Paragraph;
|
||||
class LyXCursor;
|
||||
class FuncRequest;
|
||||
|
||||
struct LaTeXFeatures;
|
||||
|
||||
@ -512,7 +512,7 @@ public:
|
||||
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_; }
|
||||
///
|
||||
|
@ -437,10 +437,9 @@ void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
|
||||
|
||||
|
||||
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;
|
||||
|
@ -95,8 +95,7 @@ public:
|
||||
///
|
||||
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;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "BufferView.h"
|
||||
#include "frontends/LyXView.h"
|
||||
#include "lyxtext.h"
|
||||
#include "funcrequest.h"
|
||||
#include "debug.h"
|
||||
#include "lyxrow.h"
|
||||
#include "lyxlex.h"
|
||||
@ -444,7 +445,7 @@ int InsetERT::docbook(Buffer const *, ostream & os, bool) const
|
||||
|
||||
|
||||
UpdatableInset::RESULT
|
||||
InsetERT::localDispatch(BufferView * bv, kb_action action, string const & arg)
|
||||
InsetERT::localDispatch(BufferView * bv, FuncRequest const & ev)
|
||||
{
|
||||
UpdatableInset::RESULT result = DISPATCHED_NOUPDATE;
|
||||
|
||||
@ -452,14 +453,14 @@ InsetERT::localDispatch(BufferView * bv, kb_action action, string const & arg)
|
||||
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:
|
||||
|
@ -94,8 +94,7 @@ public:
|
||||
///
|
||||
void validate(LaTeXFeatures &) const {}
|
||||
///
|
||||
UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
|
||||
string const &);
|
||||
UpdatableInset::RESULT localDispatch(BufferView *, FuncRequest const &);
|
||||
///
|
||||
bool checkInsertChar(LyXFont &);
|
||||
///
|
||||
|
@ -22,7 +22,7 @@
|
||||
#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"
|
||||
@ -47,7 +47,7 @@ string const InsetParent::getScreenLabel(Buffer const *) const
|
||||
void InsetParent::edit(BufferView * bv, int, int, mouse_button::state)
|
||||
{
|
||||
bv->owner()->getLyXFunc()->
|
||||
dispatch(LFUN_CHILDOPEN, getContents());
|
||||
dispatch(FuncRequest(LFUN_CHILDOPEN, getContents()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "insetref.h"
|
||||
#include "buffer.h"
|
||||
#include "commandtags.h"
|
||||
#include "funcrequest.h"
|
||||
#include "debug.h"
|
||||
#include "gettext.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
@ -22,20 +22,20 @@ InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf, bool)
|
||||
: 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
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "lyxlength.h"
|
||||
#include "ParagraphParameters.h"
|
||||
#include "lyxlex.h"
|
||||
#include "funcrequest.h"
|
||||
|
||||
#include "frontends/Dialogs.h"
|
||||
#include "frontends/Alert.h"
|
||||
@ -820,7 +821,7 @@ void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, mouse_button:
|
||||
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()) {
|
||||
@ -877,20 +878,19 @@ void InsetTabular::insetMotionNotify(BufferView * bv, int x, int y, mouse_button
|
||||
|
||||
|
||||
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();
|
||||
@ -899,12 +899,12 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action,
|
||||
// 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);
|
||||
@ -922,8 +922,10 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action,
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
@ -1248,7 +1250,7 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action,
|
||||
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:
|
||||
@ -1263,7 +1265,7 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action,
|
||||
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);
|
||||
|
@ -142,8 +142,7 @@ public:
|
||||
///
|
||||
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;
|
||||
///
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "lyxlex.h"
|
||||
#include "debug.h"
|
||||
#include "lyxfont.h"
|
||||
#include "commandtags.h"
|
||||
#include "buffer.h"
|
||||
#include "frontends/LyXView.h"
|
||||
#include "BufferView.h"
|
||||
@ -40,6 +39,7 @@
|
||||
#include "ParagraphParameters.h"
|
||||
#include "undo_funcs.h"
|
||||
#include "lyxfind.h"
|
||||
#include "funcrequest.h"
|
||||
|
||||
#include "frontends/Alert.h"
|
||||
#include "frontends/Dialogs.h"
|
||||
@ -1043,7 +1043,7 @@ void InsetText::insetButtonPress(BufferView * bv,
|
||||
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;
|
||||
@ -1057,7 +1057,7 @@ void InsetText::insetButtonPress(BufferView * bv,
|
||||
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;
|
||||
@ -1096,10 +1096,9 @@ void InsetText::insetButtonPress(BufferView * bv,
|
||||
// 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();
|
||||
@ -1177,23 +1176,21 @@ void InsetText::insetMotionNotify(BufferView * bv, int x, int y, mouse_button::s
|
||||
|
||||
|
||||
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) {
|
||||
@ -1244,14 +1241,14 @@ InsetText::localDispatch(BufferView * bv,
|
||||
}
|
||||
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
|
||||
@ -1267,9 +1264,9 @@ InsetText::localDispatch(BufferView * bv,
|
||||
}
|
||||
}
|
||||
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;
|
||||
@ -1376,7 +1373,7 @@ InsetText::localDispatch(BufferView * bv,
|
||||
|
||||
if (clip.empty())
|
||||
break;
|
||||
if (arg == "paragraph") {
|
||||
if (ev.argument == "paragraph") {
|
||||
lt->insertStringAsParagraphs(bv, clip);
|
||||
} else {
|
||||
lt->insertStringAsLines(bv, clip);
|
||||
@ -1449,7 +1446,7 @@ InsetText::localDispatch(BufferView * bv,
|
||||
// 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.
|
||||
@ -1462,8 +1459,8 @@ InsetText::localDispatch(BufferView * bv,
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -1491,7 +1488,7 @@ InsetText::localDispatch(BufferView * bv,
|
||||
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;
|
||||
@ -1516,7 +1513,7 @@ InsetText::localDispatch(BufferView * bv,
|
||||
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));
|
||||
@ -1527,7 +1524,7 @@ InsetText::localDispatch(BufferView * bv,
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!bv->dispatch(action, arg))
|
||||
if (!bv->dispatch(ev))
|
||||
result = UNDISPATCHED;
|
||||
break;
|
||||
}
|
||||
|
@ -129,8 +129,7 @@ public:
|
||||
///
|
||||
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;
|
||||
|
113
src/lyxfunc.C
113
src/lyxfunc.C
@ -190,7 +190,7 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym,
|
||||
<< endl;
|
||||
}
|
||||
// Do nothing if we have nothing (JMarc)
|
||||
if ( ! keysym->isOK() ) {
|
||||
if (!keysym->isOK()) {
|
||||
lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
|
||||
<< endl;
|
||||
return;
|
||||
@ -264,7 +264,7 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym,
|
||||
if (c != 0)
|
||||
argument = c;
|
||||
|
||||
dispatch(LFUN_SELFINSERT, argument);
|
||||
dispatch(FuncRequest(LFUN_SELFINSERT, argument));
|
||||
lyxerr[Debug::KEY] << "SelfInsert arg[`"
|
||||
<< argument << "']" << endl;
|
||||
} else {
|
||||
@ -275,25 +275,23 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym,
|
||||
|
||||
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);
|
||||
}
|
||||
@ -302,13 +300,13 @@ FuncStatus LyXFunc::getStatus(kb_action action,
|
||||
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"));
|
||||
@ -327,14 +325,14 @@ FuncStatus LyXFunc::getStatus(kb_action action,
|
||||
// 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();
|
||||
@ -378,11 +376,11 @@ FuncStatus LyXFunc::getStatus(kb_action action,
|
||||
//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;
|
||||
@ -391,7 +389,7 @@ FuncStatus LyXFunc::getStatus(kb_action action,
|
||||
FuncStatus ret;
|
||||
|
||||
disable = true;
|
||||
ret = inset.getStatus(argument);
|
||||
ret = inset.getStatus(ev.argument);
|
||||
if (ret.onoff(true) || ret.onoff(false))
|
||||
flag.setOnOff(false);
|
||||
}
|
||||
@ -413,7 +411,7 @@ FuncStatus LyXFunc::getStatus(kb_action action,
|
||||
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();
|
||||
@ -433,15 +431,15 @@ FuncStatus LyXFunc::getStatus(kb_action action,
|
||||
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;
|
||||
@ -453,22 +451,22 @@ FuncStatus LyXFunc::getStatus(kb_action action,
|
||||
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;
|
||||
@ -498,7 +496,7 @@ FuncStatus LyXFunc::getStatus(kb_action action,
|
||||
|
||||
// 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;
|
||||
@ -602,7 +600,7 @@ FuncStatus LyXFunc::getStatus(kb_action action,
|
||||
flag.disabled(true);
|
||||
|
||||
// A few general toggles
|
||||
switch (action) {
|
||||
switch (ev.action) {
|
||||
case LFUN_TOOLTIPS_TOGGLE:
|
||||
flag.setOnOff(owner->getDialogs()->tooltipsEnabled());
|
||||
break;
|
||||
@ -616,7 +614,7 @@ FuncStatus LyXFunc::getStatus(kb_action action,
|
||||
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:
|
||||
@ -626,7 +624,7 @@ FuncStatus LyXFunc::getStatus(kb_action action,
|
||||
// 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;
|
||||
@ -650,7 +648,7 @@ FuncStatus LyXFunc::getStatus(kb_action action,
|
||||
}
|
||||
} else {
|
||||
string tc = mathcursor->getLastCode();
|
||||
switch (action) {
|
||||
switch (ev.action) {
|
||||
case LFUN_BOLD:
|
||||
flag.setOnOff(tc == "mathbf");
|
||||
break;
|
||||
@ -679,10 +677,9 @@ FuncStatus LyXFunc::getStatus(kb_action action,
|
||||
|
||||
// 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;
|
||||
@ -708,15 +705,15 @@ void LyXFunc::dispatch(int ac, bool verbose)
|
||||
{
|
||||
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;
|
||||
@ -734,8 +731,11 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
|
||||
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"
|
||||
@ -768,7 +768,7 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
|
||||
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;
|
||||
@ -1336,10 +1336,10 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
|
||||
|
||||
// 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:
|
||||
@ -1361,7 +1361,7 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
|
||||
} else {
|
||||
p.setContents(argument);
|
||||
}
|
||||
dispatch(LFUN_CITATION_INSERT, p.getAsString());
|
||||
dispatch(FuncRequest(LFUN_CITATION_INSERT, p.getAsString()));
|
||||
} else
|
||||
owner->getDialogs()->createCitation(p.getAsString());
|
||||
}
|
||||
@ -1507,48 +1507,47 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -1557,8 +1556,8 @@ void LyXFunc::sendDispatchMessage(string const & msg, kb_action action, string c
|
||||
|
||||
if (!shortcuts.empty()) {
|
||||
comname += ": " + shortcuts;
|
||||
} else if (!argsadded && !arg.empty()) {
|
||||
comname += " " + arg;
|
||||
} else if (!argsadded && !ev.argument.empty()) {
|
||||
comname += " " + ev.argument;
|
||||
}
|
||||
|
||||
if (!comname.empty()) {
|
||||
|
@ -7,15 +7,16 @@
|
||||
#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.
|
||||
@ -31,7 +32,7 @@ public:
|
||||
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);
|
||||
@ -49,8 +50,7 @@ public:
|
||||
/// 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;
|
||||
@ -101,7 +101,7 @@ private:
|
||||
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)
|
||||
|
||||
|
@ -726,7 +726,7 @@ int LyXRC::read(string const & filename)
|
||||
break;
|
||||
}
|
||||
|
||||
if ((action = lyxaction.LookupFunc(cmd))>= 0) {
|
||||
if ((action = lyxaction.LookupFunc(cmd)) >= 0) {
|
||||
if (lyxerr.debugging(Debug::LYXRC)) {
|
||||
lyxerr << "RC_BIND: Sequence `"
|
||||
<< seq << "' Command `"
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "formula.h"
|
||||
#include "commandtags.h"
|
||||
#include "math_cursor.h"
|
||||
#include "math_parser.h"
|
||||
#include "math_charinset.h"
|
||||
@ -37,6 +36,7 @@
|
||||
#include "gettext.h"
|
||||
#include "debug.h"
|
||||
#include "lyxrc.h"
|
||||
#include "funcrequest.h"
|
||||
|
||||
#include "support/LOstream.h"
|
||||
#include "support/LAssert.h"
|
||||
@ -252,12 +252,11 @@ vector<string> const InsetFormula::getLabelList() const
|
||||
|
||||
|
||||
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);
|
||||
@ -305,7 +304,7 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action,
|
||||
|
||||
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 =
|
||||
@ -343,7 +342,7 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action,
|
||||
int x;
|
||||
int y;
|
||||
mathcursor->getPos(x, y);
|
||||
mutate(arg);
|
||||
mutate(ev.argument);
|
||||
mathcursor->setPos(x, y);
|
||||
mathcursor->normalize();
|
||||
updateLocal(bv, true);
|
||||
@ -354,7 +353,7 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action,
|
||||
{
|
||||
bv->lockedInsetStoreUndo(Undo::EDIT);
|
||||
if (mathcursor)
|
||||
mathcursor->handleExtern(arg);
|
||||
mathcursor->handleExtern(ev.argument);
|
||||
// re-compute inset dimension
|
||||
metrics(bv);
|
||||
updateLocal(bv, true);
|
||||
@ -379,13 +378,13 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action,
|
||||
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;
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
///
|
||||
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;
|
||||
///
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "formula.h"
|
||||
#include "formulamacro.h"
|
||||
#include "lyxrc.h"
|
||||
#include "commandtags.h"
|
||||
#include "funcrequest.h"
|
||||
#include "BufferView.h"
|
||||
#include "lyxtext.h"
|
||||
#include "lyxfunc.h"
|
||||
@ -397,8 +397,7 @@ void InsetFormulaBase::insetMotionNotify(BufferView * bv,
|
||||
|
||||
|
||||
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
|
||||
@ -406,8 +405,8 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
|
||||
if (!mathcursor)
|
||||
return UNDISPATCHED;
|
||||
string argument = arg;
|
||||
|
||||
string argument = ev.argument;
|
||||
RESULT result = DISPATCHED;
|
||||
bool sel = false;
|
||||
bool was_macro = mathcursor->inMacroMode();
|
||||
@ -418,7 +417,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
mathcursor->normalize();
|
||||
mathcursor->touch();
|
||||
|
||||
switch (action) {
|
||||
switch (ev.action) {
|
||||
|
||||
case LFUN_WORDRIGHTSEL:
|
||||
case LFUN_RIGHTSEL:
|
||||
@ -524,7 +523,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
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);
|
||||
@ -553,7 +552,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
// 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);
|
||||
@ -579,27 +578,27 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
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);
|
||||
@ -624,9 +623,9 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
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;
|
||||
@ -635,7 +634,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
case LFUN_SUBSCRIPT:
|
||||
{
|
||||
bv->lockedInsetStoreUndo(Undo::EDIT);
|
||||
mathcursor->script(action == LFUN_SUPERSCRIPT);
|
||||
mathcursor->script(ev.action == LFUN_SUPERSCRIPT);
|
||||
updateLocal(bv, true);
|
||||
break;
|
||||
}
|
||||
@ -644,7 +643,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
{
|
||||
//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 = '(';
|
||||
@ -681,8 +680,8 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
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;
|
||||
@ -757,13 +756,13 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
// 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;
|
||||
@ -941,8 +940,8 @@ void mathDispatchCreation(BufferView * bv, string const & arg, bool display)
|
||||
// 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
|
||||
@ -1000,7 +999,7 @@ void mathDispatchMathDelim(BufferView * bv, string const & arg)
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1012,7 +1011,7 @@ void mathDispatchInsertMatrix(BufferView * bv, string const & 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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1024,7 +1023,7 @@ void mathDispatchInsertMath(BufferView * bv, string const & 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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1036,7 +1035,7 @@ void mathDispatchGreek(BufferView * bv, string const & 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);
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "lyxfont.h"
|
||||
|
||||
#include <boost/weak_ptr.hpp>
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
class Buffer;
|
||||
@ -90,7 +89,7 @@ public:
|
||||
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;
|
||||
@ -165,7 +164,7 @@ void mathDispatchGreek(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 &);
|
||||
|
||||
|
@ -524,7 +524,7 @@ LyXFont::FONT_SERIES const inh_series = LyXFont::INHERIT_SERIES;
|
||||
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",
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "ref_inset.h"
|
||||
#include "math_cursor.h"
|
||||
#include "commandtags.h"
|
||||
#include "funcrequest.h"
|
||||
#include "formulabase.h"
|
||||
#include "BufferView.h"
|
||||
#include "frontends/LyXView.h"
|
||||
@ -41,13 +41,13 @@ int RefInset::dispatch(string const & cmd, idx_type, pos_type)
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user