* Remove LFUN_REF_INSERT.

* Add LFUN_DIALOG_SHOW_NEW_INSET to LyXFunc::getStatus' switch.
* Add a new LFUN_INSET_DIALOG_UPDATE to replace those nasty dynamic casts
in LyXFunc::dispatch.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6377 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2003-03-07 15:58:02 +00:00
parent a5fe7ae80e
commit be16393a7b
11 changed files with 157 additions and 68 deletions

View File

@ -1,3 +1,17 @@
2003-03-05 Angus Leeming <leeming@lyx.org>
* commandtags.h:
* LyXAction.C (init):
* lyxfunc.C (getStatus): remove LFUN_REF_INSERT.
* lyxfunc.C (getStatus): add LFUN_DIALOG_SHOW_NEW_INSET to switch.
* commandtags.h:
* LyXAction.C: add LFUN_INSET_DIALOG_UPDATE.
* lyxfunc (dispatch): on LFUN_DIALOG_UPDATE, pass the 'open' inset's
localDispatch method LFUN_INSET_DIALOG_UPDATE.
2003-03-07 Angus Leeming <leeming@lyx.org> 2003-03-07 Angus Leeming <leeming@lyx.org>
* lyxfunc.C (dispatch): add "include" to LFUN_SHOW_NEW_INSET and * lyxfunc.C (dispatch): add "include" to LFUN_SHOW_NEW_INSET and

View File

@ -320,8 +320,6 @@ void LyXAction::init()
N_("Reconfigure"), NoBuffer }, N_("Reconfigure"), NoBuffer },
{ LFUN_REDO, "redo", N_("Redo"), Noop }, { LFUN_REDO, "redo", N_("Redo"), Noop },
{ LFUN_REF_GOTO, "reference-goto", "", ReadOnly }, { LFUN_REF_GOTO, "reference-goto", "", ReadOnly },
{ LFUN_REF_INSERT, "reference-insert",
N_("Insert cross reference"), ReadOnly },
{ LFUN_REFERENCE_GOTO, "reference-next", "", ReadOnly }, { LFUN_REFERENCE_GOTO, "reference-next", "", ReadOnly },
{ LFUN_NEXT, "screen-down", "", ReadOnly }, { LFUN_NEXT, "screen-down", "", ReadOnly },
{ LFUN_NEXTSEL, "screen-down-select", "", ReadOnly }, { LFUN_NEXTSEL, "screen-down-select", "", ReadOnly },
@ -418,6 +416,7 @@ void LyXAction::init()
N_("Disconnect the dialog from the current inset"), Noop }, N_("Disconnect the dialog from the current inset"), Noop },
{ LFUN_INSET_APPLY, "inset-apply", "", Noop }, { LFUN_INSET_APPLY, "inset-apply", "", Noop },
{ LFUN_INSET_MODIFY, "", "internal only", Noop }, { LFUN_INSET_MODIFY, "", "internal only", Noop },
{ LFUN_INSET_DIALOG_UPDATE, "", "internal only", Noop },
{ LFUN_NOACTION, "", "", Noop } { LFUN_NOACTION, "", "", Noop }
}; };

View File

@ -167,7 +167,6 @@ enum kb_action {
LFUN_LOWCASE_WORD, LFUN_LOWCASE_WORD,
LFUN_CAPITALIZE_WORD, LFUN_CAPITALIZE_WORD,
LFUN_INSERT_LABEL, LFUN_INSERT_LABEL,
LFUN_REF_INSERT,
LFUN_DEPTH_MIN, // 150 // RVDK_PATCH_5 LFUN_DEPTH_MIN, // 150 // RVDK_PATCH_5
LFUN_DEPTH_PLUS, // RVDK_PATCH_5 LFUN_DEPTH_PLUS, // RVDK_PATCH_5
LFUN_MENU_OPEN_BY_NAME, // RVDK_PATCH_5 LFUN_MENU_OPEN_BY_NAME, // RVDK_PATCH_5
@ -295,6 +294,7 @@ enum kb_action {
LFUN_DIALOG_DISCONNECT_INSET, LFUN_DIALOG_DISCONNECT_INSET,
LFUN_INSET_APPLY, LFUN_INSET_APPLY,
LFUN_INSET_MODIFY, LFUN_INSET_MODIFY,
LFUN_INSET_DIALOG_UPDATE,
LFUN_LASTACTION /* this marks the end of the table */ LFUN_LASTACTION /* this marks the end of the table */
}; };

View File

@ -1,3 +1,13 @@
2003-03-07 Angus Leeming <leeming@lyx.org>
* insetcommand.C (localDispatch):
* insetexternal.C (localDispatch):
* insetfloat.C (localDispatch):
* insetinclude.C (localDispatch):
* insetminipage.C (localDispatch):
* insetwrap.C (localDispatch):
add LFUN_INSET_DIALOG_UPDATE to the switch.
2003-03-07 Angus Leeming <leeming@lyx.org> 2003-03-07 Angus Leeming <leeming@lyx.org>
* insetcommand.C (string2params): * insetcommand.C (string2params):

View File

@ -67,19 +67,32 @@ int InsetCommand::docbook(Buffer const *, ostream &, bool) const
dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd) dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd)
{ {
if (cmd.action != LFUN_INSET_MODIFY) dispatch_result result = UNDISPATCHED;
return UNDISPATCHED;
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
InsetCommandParams p; InsetCommandParams p;
InsetCommandMailer::string2params(cmd.argument, p); InsetCommandMailer::string2params(cmd.argument, p);
if (p.getCmdName().empty()) if (p.getCmdName().empty())
return UNDISPATCHED; break;
setParams(p); setParams(p);
if (view()) cmd.view()->updateInset(this, true);
view()->updateInset(this, true); result = DISPATCHED;
}
break;
return DISPATCHED; case LFUN_INSET_DIALOG_UPDATE: {
InsetCommandMailer mailer(cmd.argument, *this);
mailer.updateDialog();
}
break;
default:
break;
}
return result;
} }
InsetCommandMailer::InsetCommandMailer(string const & name, InsetCommandMailer::InsetCommandMailer(string const & name,

View File

@ -64,17 +64,32 @@ InsetExternal::Params const & InsetExternal::params() const
dispatch_result InsetExternal::localDispatch(FuncRequest const & cmd) dispatch_result InsetExternal::localDispatch(FuncRequest const & cmd)
{ {
if (cmd.action != LFUN_INSET_MODIFY) dispatch_result result = UNDISPATCHED;
return UNDISPATCHED;
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
InsetExternal::Params p; InsetExternal::Params p;
InsetExternalMailer::string2params(cmd.argument, p); InsetExternalMailer::string2params(cmd.argument, p);
if (p.filename.empty()) if (p.filename.empty())
return UNDISPATCHED; break;
setFromParams(p); setFromParams(p);
cmd.view()->updateInset(this, true); cmd.view()->updateInset(this, true);
return DISPATCHED; result = DISPATCHED;
}
break;
case LFUN_INSET_DIALOG_UPDATE: {
InsetExternalMailer mailer(*this);
mailer.updateDialog();
}
break;
default:
break;
}
return result;
} }

View File

@ -169,6 +169,13 @@ dispatch_result InsetFloat::localDispatch(FuncRequest const & cmd)
result = DISPATCHED; result = DISPATCHED;
} }
break; break;
case LFUN_INSET_DIALOG_UPDATE: {
InsetFloatMailer mailer(*this);
mailer.updateDialog();
}
break;
default: default:
result = InsetCollapsable::localDispatch(cmd); result = InsetCollapsable::localDispatch(cmd);
} }

View File

@ -115,19 +115,34 @@ InsetInclude::~InsetInclude()
dispatch_result InsetInclude::localDispatch(FuncRequest const & cmd) dispatch_result InsetInclude::localDispatch(FuncRequest const & cmd)
{ {
if (cmd.action != LFUN_INSET_MODIFY) dispatch_result result = UNDISPATCHED;
return UNDISPATCHED;
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
InsetInclude::Params p; InsetInclude::Params p;
InsetIncludeMailer::string2params(cmd.argument, p); InsetIncludeMailer::string2params(cmd.argument, p);
if (p.cparams.getCmdName().empty()) if (p.cparams.getCmdName().empty())
return UNDISPATCHED; break;
set(p); set(p);
params_.masterFilename_ = cmd.view()->buffer()->fileName(); params_.masterFilename_ = cmd.view()->buffer()->fileName();
cmd.view()->updateInset(this, true); cmd.view()->updateInset(this, true);
return DISPATCHED; result = DISPATCHED;
}
break;
case LFUN_INSET_DIALOG_UPDATE: {
InsetIncludeMailer mailer(*this);
mailer.updateDialog();
}
break;
default:
break;
}
return result;
} }

View File

@ -121,6 +121,13 @@ dispatch_result InsetMinipage::localDispatch(FuncRequest const & cmd)
result = DISPATCHED; result = DISPATCHED;
} }
break; break;
case LFUN_INSET_DIALOG_UPDATE: {
InsetMinipageMailer mailer(*this);
mailer.updateDialog();
}
break;
default: default:
result = InsetCollapsable::localDispatch(cmd); result = InsetCollapsable::localDispatch(cmd);
} }

View File

@ -99,6 +99,13 @@ dispatch_result InsetWrap::localDispatch(FuncRequest const & cmd)
result = DISPATCHED; result = DISPATCHED;
} }
break; break;
case LFUN_INSET_DIALOG_UPDATE: {
InsetWrapMailer mailer(*this);
mailer.updateDialog();
}
break;
default: default:
result = InsetCollapsable::localDispatch(cmd); result = InsetCollapsable::localDispatch(cmd);
} }

View File

@ -507,6 +507,39 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
// the functions which insert insets // the functions which insert insets
Inset::Code code = Inset::NO_CODE; Inset::Code code = Inset::NO_CODE;
switch (ev.action) { switch (ev.action) {
case LFUN_DIALOG_SHOW_NEW_INSET:
if (ev.argument == "bibitem")
code = Inset::BIBITEM_CODE;
else if (ev.argument == "bibtex")
code = Inset::BIBTEX_CODE;
else if (ev.argument == "citation")
code = Inset::CITE_CODE;
else if (ev.argument == "ert")
code = Inset::ERT_CODE;
else if (ev.argument == "external")
code = Inset::EXTERNAL_CODE;
else if (ev.argument == "float")
code = Inset::FLOAT_CODE;
else if (ev.argument == "graphics")
code = Inset::GRAPHICS_CODE;
else if (ev.argument == "include")
code = Inset::INCLUDE_CODE;
else if (ev.argument == "index")
code = Inset::INDEX_CODE;
else if (ev.argument == "label")
code = Inset::LABEL_CODE;
else if (ev.argument == "minipage")
code = Inset::MINIPAGE_CODE;
else if (ev.argument == "ref")
code = Inset::REF_CODE;
else if (ev.argument == "toc")
code = Inset::TOC_CODE;
else if (ev.argument == "url")
code = Inset::URL_CODE;
else if (ev.argument == "wrap")
code = Inset::WRAP_CODE;
break;
case LFUN_INSET_ERT: case LFUN_INSET_ERT:
code = Inset::ERT_CODE; code = Inset::ERT_CODE;
break; break;
@ -555,9 +588,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
case LFUN_INSET_OPTARG: case LFUN_INSET_OPTARG:
code = Inset::OPTARG_CODE; code = Inset::OPTARG_CODE;
break; break;
case LFUN_REF_INSERT:
code = Inset::REF_CODE;
break;
case LFUN_INDEX_INSERT: case LFUN_INDEX_INSERT:
code = Inset::INDEX_CODE; code = Inset::INDEX_CODE;
break; break;
@ -1372,39 +1402,11 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
case LFUN_DIALOG_UPDATE: { case LFUN_DIALOG_UPDATE: {
string const & name = argument; string const & name = argument;
// Can only update a dialog connected to an existing inset // Can only update a dialog connected to an existing inset
InsetBase * i = owner->getDialogs().getOpenInset(name); InsetBase * inset = owner->getDialogs().getOpenInset(name);
if (!i) if (inset) {
break; FuncRequest fr(view(), LFUN_INSET_DIALOG_UPDATE,
ev.argument);
if (name == "bibitem" || inset->localDispatch(fr);
name == "bibtex" ||
name == "citation" ||
name == "index" ||
name == "ref" ||
name == "toc" ||
name == "url") {
InsetCommand * inset = dynamic_cast<InsetCommand *>(i);
if (!inset)
break;
InsetCommandMailer mailer(name, *inset);
mailer.updateDialog();
} else if (name == "error") {
InsetError * inset = dynamic_cast<InsetError *>(i);
if (!inset)
break;
owner->getDialogs().update("error",
inset->getContents());
} else if (name == "ert") {
InsetERT * inset = dynamic_cast<InsetERT *>(i);
if (!inset)
break;
InsetERTMailer mailer(*inset);
mailer.updateDialog();
} }
} }
break; break;