mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Some context menu work:
* src/BufferView.cpp: * src/FuncCode.h: * src/LyXAction.cpp: - new LFUN_NEXT_INSET_MODIFY * src/insets/InsetBox.{cpp, h}: * src/insets/InsetCommand.{cpp,h}: * src/insets/InsetNote.{cpp,h}: * src/insets/InsetSpace.{cpp,h}: * src/insets/InsetVSpace.{cpp,h}: - implement context menu and access to some changes * lib/ui/stdmenus.ui: - new context menus for Box, Space, VSpace, Note. - extend the context menu for InsetRef. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23920 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2567314e44
commit
e1ac6d4118
@ -546,9 +546,19 @@ Menuset
|
|||||||
Menu "context-ref"
|
Menu "context-ref"
|
||||||
Item "Next Cross-Reference|N" "reference-next"
|
Item "Next Cross-Reference|N" "reference-next"
|
||||||
Item "Go to Label|G" "label-goto"
|
Item "Go to Label|G" "label-goto"
|
||||||
|
Submenu "Change Type|y" "edit_reftype"
|
||||||
Item "Edit...|E" "next-inset-toggle"
|
Item "Edit...|E" "next-inset-toggle"
|
||||||
End
|
End
|
||||||
|
|
||||||
|
Menu "edit_reftype"
|
||||||
|
Item "<reference>|r" "next-inset-modify changetype ref"
|
||||||
|
Item "(<reference>)|e" "next-inset-modify changetype eqref"
|
||||||
|
Item "<page>|p" "next-inset-modify changetype pageref"
|
||||||
|
Item "on page <page>|o" "next-inset-modify changetype vpageref"
|
||||||
|
Item "<reference> on page <page>|f" "next-inset-modify changetype vref"
|
||||||
|
Item "Formatted reference|t" "next-inset-modify changetype prettyref"
|
||||||
|
End
|
||||||
|
|
||||||
#
|
#
|
||||||
# InsetLabel context menu
|
# InsetLabel context menu
|
||||||
#
|
#
|
||||||
@ -566,6 +576,83 @@ Menuset
|
|||||||
Item "Close Inset|C" "inset-toggle close"
|
Item "Close Inset|C" "inset-toggle close"
|
||||||
End
|
End
|
||||||
|
|
||||||
|
#
|
||||||
|
# InsetBox context menu
|
||||||
|
#
|
||||||
|
|
||||||
|
Menu "context-box"
|
||||||
|
Submenu "Change Type|y" "edit_boxtype"
|
||||||
|
Item "Settings...|S" "inset-settings box"
|
||||||
|
End
|
||||||
|
|
||||||
|
Menu "edit_boxtype"
|
||||||
|
Item "Frameless|l" "next-inset-modify changetype Frameless"
|
||||||
|
Item "Simple frame|f" "next-inset-modify changetype Boxed"
|
||||||
|
Item "Simple frame, page breaks|p" "next-inset-modify changetype Framed"
|
||||||
|
Item "Oval, thin|O" "next-inset-modify changetype ovalbox"
|
||||||
|
Item "Oval, thick|v" "next-inset-modify changetype Ovalbox"
|
||||||
|
Item "Drop Shadow|w" "next-inset-modify changetype Shadowbox"
|
||||||
|
Item "Shaded background|b" "next-inset-modify changetype Shaded"
|
||||||
|
Item "Double frame|D" "next-inset-modify changetype Doublebox"
|
||||||
|
End
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# InsetNote context menu
|
||||||
|
#
|
||||||
|
|
||||||
|
Menu "context-note"
|
||||||
|
Submenu "Change Type|y" "edit_notetype"
|
||||||
|
Item "Settings...|S" "inset-settings note"
|
||||||
|
End
|
||||||
|
|
||||||
|
Menu "edit_notetype"
|
||||||
|
Item "LyX Note|N" "next-inset-modify note Note Note"
|
||||||
|
Item "Comment|C" "next-inset-modify note Note Comment"
|
||||||
|
Item "Greyed Out|G" "next-inset-modify note Note Greyedout"
|
||||||
|
End
|
||||||
|
|
||||||
|
#
|
||||||
|
# InsetSpace context menu
|
||||||
|
#
|
||||||
|
Menu "context-space"
|
||||||
|
Submenu "Change Type|y" "edit_spacetype"
|
||||||
|
Item "Edit...|E" "next-inset-toggle"
|
||||||
|
End
|
||||||
|
|
||||||
|
Menu "edit_spacetype"
|
||||||
|
Item "Interword Space|w" "next-inset-modify space \space{}"
|
||||||
|
Item "Protected Space|P" "next-inset-modify space ~"
|
||||||
|
Item "Thin Space|T" "next-inset-modify space \thinspace{}"
|
||||||
|
Item "Quad Space|Q" "next-inset-modify space \quad{}"
|
||||||
|
Item "QQuad Space|u" "next-inset-modify space \qquad{}"
|
||||||
|
Item "Enspace|E" "next-inset-modify space \enspace{}"
|
||||||
|
Item "Enskip|k" "next-inset-modify space \enskip{}"
|
||||||
|
Item "Negative Thin Space|N" "next-inset-modify space \negthinspace{}"
|
||||||
|
Item "Horizontal Fill|F" "next-inset-modify space \hfill{}"
|
||||||
|
Item "Protected Horizontal Fill|i" "next-inset-modify space \hspace*{\fill}"
|
||||||
|
Item "Horizontal Fill (Dots)|D" "next-inset-modify space \dotfill{}"
|
||||||
|
Item "Horizontal Fill (Rule)|R" "next-inset-modify space \hrulefill{}"
|
||||||
|
Item "Custom Length|C" "command-sequence next-inset-modify space \hspace{} \length 1in; next-inset-toggle"
|
||||||
|
End
|
||||||
|
|
||||||
|
#
|
||||||
|
# InsetVSpace context menu
|
||||||
|
#
|
||||||
|
Menu "context-vspace"
|
||||||
|
Submenu "Change Type|y" "edit_vspacetype"
|
||||||
|
Item "Edit...|E" "next-inset-toggle"
|
||||||
|
End
|
||||||
|
|
||||||
|
Menu "edit_vspacetype"
|
||||||
|
Item "DefSkip|D" "next-inset-modify vspace defskip"
|
||||||
|
Item "SmallSkip|S" "next-inset-modify vspace smallskip"
|
||||||
|
Item "MedSkip|M" "next-inset-modify vspace medskip"
|
||||||
|
Item "BigSkip|B" "next-inset-modify vspace bigskip"
|
||||||
|
Item "VFill|F" "next-inset-modify vspace vfill"
|
||||||
|
Item "Custom|C" "command-sequence next-inset-modify vspace 1in; next-inset-toggle"
|
||||||
|
End
|
||||||
|
|
||||||
#
|
#
|
||||||
# Edit context menu
|
# Edit context menu
|
||||||
#
|
#
|
||||||
@ -587,6 +674,10 @@ Menuset
|
|||||||
Item "Fullscreen Mode" "ui-toggle fullscreen"
|
Item "Fullscreen Mode" "ui-toggle fullscreen"
|
||||||
End
|
End
|
||||||
|
|
||||||
|
#
|
||||||
|
# Math Macro context menu
|
||||||
|
#
|
||||||
|
|
||||||
Menu "context-math-macro-definition"
|
Menu "context-math-macro-definition"
|
||||||
Item "Append Parameter" "math-macro-add-param"
|
Item "Append Parameter" "math-macro-add-param"
|
||||||
Item "Remove Last Parameter" "math-macro-remove-param"
|
Item "Remove Last Parameter" "math-macro-remove-param"
|
||||||
@ -601,6 +692,10 @@ Menuset
|
|||||||
Item "Remove Last Parameter Spitting Out To The Right" "math-macro-remove-greedy-param"
|
Item "Remove Last Parameter Spitting Out To The Right" "math-macro-remove-greedy-param"
|
||||||
End
|
End
|
||||||
|
|
||||||
|
#
|
||||||
|
# InsetListing context menu
|
||||||
|
#
|
||||||
|
|
||||||
Menu "context-listings"
|
Menu "context-listings"
|
||||||
Item "Cut" "cut"
|
Item "Cut" "cut"
|
||||||
Item "Copy" "copy"
|
Item "Copy" "copy"
|
||||||
@ -609,7 +704,11 @@ Menuset
|
|||||||
Separator
|
Separator
|
||||||
Item "Settings...|S" "inset-settings listings"
|
Item "Settings...|S" "inset-settings listings"
|
||||||
End
|
End
|
||||||
|
|
||||||
|
#
|
||||||
|
# InsetGraphics context menu
|
||||||
|
#
|
||||||
|
|
||||||
Menu "context-graphics"
|
Menu "context-graphics"
|
||||||
Item "Edit...|E" "graphics-edit"
|
Item "Edit...|E" "graphics-edit"
|
||||||
Separator
|
Separator
|
||||||
|
@ -866,6 +866,29 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
|
|||||||
flag.enabled(true);
|
flag.enabled(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LFUN_NEXT_INSET_MODIFY: {
|
||||||
|
// this is the real function we want to invoke
|
||||||
|
FuncRequest tmpcmd = FuncRequest(LFUN_INSET_MODIFY, cmd.argument());
|
||||||
|
// if there is an inset at cursor, see whether it
|
||||||
|
// can be modified.
|
||||||
|
Inset * inset = cur.nextInset();
|
||||||
|
if (inset) {
|
||||||
|
inset->getStatus(cur, tmpcmd, flag);
|
||||||
|
return flag;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// if it did not work, try the underlying inset.
|
||||||
|
inset = &cur.inset();
|
||||||
|
if (inset) {
|
||||||
|
inset->getStatus(cur, tmpcmd, flag);
|
||||||
|
return flag;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// else disable
|
||||||
|
flag.enabled(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case LFUN_LABEL_GOTO: {
|
case LFUN_LABEL_GOTO: {
|
||||||
flag.enabled(!cmd.argument().empty()
|
flag.enabled(!cmd.argument().empty()
|
||||||
|| getInsetByCode<InsetRef>(cur, REF_CODE));
|
|| getInsetByCode<InsetRef>(cur, REF_CODE));
|
||||||
@ -1312,6 +1335,25 @@ bool BufferView::dispatch(FuncRequest const & cmd)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case LFUN_NEXT_INSET_MODIFY: {
|
||||||
|
// this is the real function we want to invoke
|
||||||
|
FuncRequest tmpcmd = FuncRequest(LFUN_INSET_MODIFY, cmd.argument());
|
||||||
|
// if there is an inset at cursor, see whether it
|
||||||
|
// can be modified.
|
||||||
|
Inset * inset = cur.nextInset();
|
||||||
|
if (inset)
|
||||||
|
inset->dispatch(cur, tmpcmd);
|
||||||
|
// if it did not work, try the underlying inset.
|
||||||
|
else if (&cur.inset())
|
||||||
|
cur.inset().dispatch(cur, tmpcmd);
|
||||||
|
else
|
||||||
|
// It did not work too; no action needed.
|
||||||
|
break;
|
||||||
|
cur.clearSelection();
|
||||||
|
processUpdateFlags(Update::Force | Update::FitCursor);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case LFUN_SCREEN_UP:
|
case LFUN_SCREEN_UP:
|
||||||
case LFUN_SCREEN_DOWN: {
|
case LFUN_SCREEN_DOWN: {
|
||||||
Point p = getPos(cur, cur.boundary());
|
Point p = getPos(cur, cur.boundary());
|
||||||
|
@ -416,6 +416,7 @@ enum FuncCode
|
|||||||
// 320
|
// 320
|
||||||
LFUN_COMPLETION_INLINE,
|
LFUN_COMPLETION_INLINE,
|
||||||
LFUN_COMPLETION_COMPLETE,
|
LFUN_COMPLETION_COMPLETE,
|
||||||
|
LFUN_NEXT_INSET_MODIFY, // JSpitzm 20080323
|
||||||
LFUN_LASTACTION // end of the table
|
LFUN_LASTACTION // end of the table
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1068,13 +1068,25 @@ void LyXAction::init()
|
|||||||
* \var lyx::FuncCode lyx::LFUN_INSET_MODIFY
|
* \var lyx::FuncCode lyx::LFUN_INSET_MODIFY
|
||||||
* \li Action: Modify existing inset.
|
* \li Action: Modify existing inset.
|
||||||
* \li Notion: Used for label, floats, listings, box, branch, external, wrap
|
* \li Notion: Used for label, floats, listings, box, branch, external, wrap
|
||||||
bibtex, ert, command, grahocs, note, vspace, tabular, bibitem,
|
bibtex, ert, command, graphics, note, space, vspace, tabular,
|
||||||
inlude, ref insets.
|
bibitem, inlude, ref insets.
|
||||||
* \li Syntax: inset-modify <INSET> <ARGS>
|
* \li Syntax: inset-modify <INSET> <ARGS>
|
||||||
* \li Params: See #LFUN_INSET_INSERT for further details.
|
* \li Params: See #LFUN_INSET_INSERT for further details.
|
||||||
* \endvar
|
* \endvar
|
||||||
*/
|
*/
|
||||||
{ LFUN_INSET_MODIFY, "", Noop, Hidden },
|
{ LFUN_INSET_MODIFY, "", Noop, Hidden },
|
||||||
|
/*!
|
||||||
|
* \var lyx::FuncCode lyx::LFUN_NEXT_INSET_MODIFY
|
||||||
|
* \li Action: Modify the inset at cursor position, if there is one.
|
||||||
|
* \li Notion: Used for label, floats, listings, box, branch, external, wrap
|
||||||
|
bibtex, ert, command, graphics, note, space, vspace, tabular,
|
||||||
|
bibitem, inlude, ref insets.
|
||||||
|
* \li Syntax: next-inset-modify <INSET> <ARGS> or next-inset-modify changetype <TYPE>
|
||||||
|
* \li Params: See #LFUN_INSET_INSERT for further details.
|
||||||
|
* \li Origin: JSpitzm, 23 Mar 2008
|
||||||
|
* \endvar
|
||||||
|
*/
|
||||||
|
{ LFUN_NEXT_INSET_MODIFY, "next-inset-modify", ReadOnly, Edit },
|
||||||
{ LFUN_INSET_DIALOG_UPDATE, "", Noop, Hidden },
|
{ LFUN_INSET_DIALOG_UPDATE, "", Noop, Hidden },
|
||||||
{ LFUN_INSET_SETTINGS, "inset-settings", ReadOnly, Edit },
|
{ LFUN_INSET_SETTINGS, "inset-settings", ReadOnly, Edit },
|
||||||
{ LFUN_NEXT_INSET_TOGGLE, "next-inset-toggle", ReadOnly, Edit },
|
{ LFUN_NEXT_INSET_TOGGLE, "next-inset-toggle", ReadOnly, Edit },
|
||||||
|
@ -186,7 +186,10 @@ void InsetBox::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
|
|
||||||
case LFUN_INSET_MODIFY: {
|
case LFUN_INSET_MODIFY: {
|
||||||
//lyxerr << "InsetBox::dispatch MODIFY" << endl;
|
//lyxerr << "InsetBox::dispatch MODIFY" << endl;
|
||||||
InsetBoxMailer::string2params(to_utf8(cmd.argument()), params_);
|
if (cmd.getArg(0) == "changetype")
|
||||||
|
params_.type = cmd.getArg(1);
|
||||||
|
else
|
||||||
|
InsetBoxMailer::string2params(to_utf8(cmd.argument()), params_);
|
||||||
setLayout(cur.buffer().params());
|
setLayout(cur.buffer().params());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -216,6 +219,11 @@ bool InsetBox::getStatus(Cursor & cur, FuncRequest const & cmd,
|
|||||||
switch (cmd.action) {
|
switch (cmd.action) {
|
||||||
|
|
||||||
case LFUN_INSET_MODIFY:
|
case LFUN_INSET_MODIFY:
|
||||||
|
if (cmd.getArg(0) == "changetype")
|
||||||
|
flag.setOnOff(cmd.getArg(1) == params_.type);
|
||||||
|
else
|
||||||
|
flag.enabled(true);
|
||||||
|
return true;
|
||||||
case LFUN_INSET_DIALOG_UPDATE:
|
case LFUN_INSET_DIALOG_UPDATE:
|
||||||
flag.enabled(true);
|
flag.enabled(true);
|
||||||
return true;
|
return true;
|
||||||
@ -490,6 +498,12 @@ void InsetBox::validate(LaTeXFeatures & features) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
docstring InsetBox::contextMenu(BufferView const &, int, int) const
|
||||||
|
{
|
||||||
|
return from_ascii("context-box");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetBoxMailer::InsetBoxMailer(InsetBox & inset)
|
InsetBoxMailer::InsetBoxMailer(InsetBox & inset)
|
||||||
: inset_(inset)
|
: inset_(inset)
|
||||||
{}
|
{}
|
||||||
|
@ -123,6 +123,8 @@ private:
|
|||||||
Inset * clone() const { return new InsetBox(*this); }
|
Inset * clone() const { return new InsetBox(*this); }
|
||||||
/// used by the constructors
|
/// used by the constructors
|
||||||
void init();
|
void init();
|
||||||
|
///
|
||||||
|
virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
|
||||||
|
|
||||||
///
|
///
|
||||||
InsetBoxParams params_;
|
InsetBoxParams params_;
|
||||||
|
@ -100,6 +100,11 @@ void InsetCommand::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
{
|
{
|
||||||
switch (cmd.action) {
|
switch (cmd.action) {
|
||||||
case LFUN_INSET_MODIFY: {
|
case LFUN_INSET_MODIFY: {
|
||||||
|
if (cmd.getArg(0) == "changetype") {
|
||||||
|
p_.setCmdName(cmd.getArg(1));
|
||||||
|
initView();
|
||||||
|
break;
|
||||||
|
}
|
||||||
InsetCommandParams p(p_.code());
|
InsetCommandParams p(p_.code());
|
||||||
InsetCommandMailer::string2params(mailer_name_, to_utf8(cmd.argument()), p);
|
InsetCommandMailer::string2params(mailer_name_, to_utf8(cmd.argument()), p);
|
||||||
if (p.getCmdName().empty())
|
if (p.getCmdName().empty())
|
||||||
@ -139,6 +144,13 @@ bool InsetCommand::getStatus(Cursor & cur, FuncRequest const & cmd,
|
|||||||
return true;
|
return true;
|
||||||
// we handle these
|
// we handle these
|
||||||
case LFUN_INSET_MODIFY:
|
case LFUN_INSET_MODIFY:
|
||||||
|
if (cmd.getArg(0) == "changetype") {
|
||||||
|
string const newtype = cmd.getArg(1);
|
||||||
|
status.enabled(p_.isCompatibleCommand(p_.code(), newtype));
|
||||||
|
status.setOnOff(newtype == p_.getCmdName());
|
||||||
|
} else
|
||||||
|
status.enabled(true);
|
||||||
|
return true;
|
||||||
case LFUN_INSET_DIALOG_UPDATE:
|
case LFUN_INSET_DIALOG_UPDATE:
|
||||||
status.enabled(true);
|
status.enabled(true);
|
||||||
return true;
|
return true;
|
||||||
|
@ -154,6 +154,8 @@ public:
|
|||||||
void preview(bool p) { preview_ = p; }
|
void preview(bool p) { preview_ = p; }
|
||||||
/// Clear the values of all parameters
|
/// Clear the values of all parameters
|
||||||
void clear();
|
void clear();
|
||||||
|
///
|
||||||
|
static bool isCompatibleCommand(InsetCode code, std::string const & s);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
@ -167,8 +169,6 @@ private:
|
|||||||
static ParamInfo const & findInfo(InsetCode code,
|
static ParamInfo const & findInfo(InsetCode code,
|
||||||
std::string const & cmdName);
|
std::string const & cmdName);
|
||||||
///
|
///
|
||||||
static bool isCompatibleCommand(InsetCode code, std::string const & s);
|
|
||||||
///
|
|
||||||
std::string getDefaultCmd(InsetCode);
|
std::string getDefaultCmd(InsetCode);
|
||||||
///
|
///
|
||||||
docstring makeKeyValArgument() const;
|
docstring makeKeyValArgument() const;
|
||||||
|
@ -197,6 +197,16 @@ bool InsetNote::getStatus(Cursor & cur, FuncRequest const & cmd,
|
|||||||
switch (cmd.action) {
|
switch (cmd.action) {
|
||||||
|
|
||||||
case LFUN_INSET_MODIFY:
|
case LFUN_INSET_MODIFY:
|
||||||
|
// disallow comment and greyed out in commands
|
||||||
|
flag.enabled(!cur.paragraph().layout().isCommand() ||
|
||||||
|
cmd.getArg(2) == "Note");
|
||||||
|
if (cmd.getArg(0) == "note") {
|
||||||
|
InsetNoteParams params;
|
||||||
|
InsetNoteMailer::string2params(to_utf8(cmd.argument()), params);
|
||||||
|
flag.setOnOff(params_.type == params.type);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
case LFUN_INSET_DIALOG_UPDATE:
|
case LFUN_INSET_DIALOG_UPDATE:
|
||||||
flag.enabled(true);
|
flag.enabled(true);
|
||||||
return true;
|
return true;
|
||||||
@ -206,6 +216,7 @@ bool InsetNote::getStatus(Cursor & cur, FuncRequest const & cmd,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetNote::updateLabels(ParIterator const & it)
|
void InsetNote::updateLabels(ParIterator const & it)
|
||||||
{
|
{
|
||||||
DocumentClass const & tclass = buffer().params().documentClass();
|
DocumentClass const & tclass = buffer().params().documentClass();
|
||||||
@ -330,6 +341,11 @@ void InsetNote::validate(LaTeXFeatures & features) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
docstring InsetNote::contextMenu(BufferView const &, int, int) const
|
||||||
|
{
|
||||||
|
return from_ascii("context-note");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
string const InsetNoteMailer::name_("note");
|
string const InsetNoteMailer::name_("note");
|
||||||
|
|
||||||
@ -375,7 +391,7 @@ void InsetNoteMailer::string2params(string const & in,
|
|||||||
string id;
|
string id;
|
||||||
lex >> id;
|
lex >> id;
|
||||||
if (!lex || id != "Note")
|
if (!lex || id != "Note")
|
||||||
return print_mailer_error("InsetBoxMailer", in, 2, "Note");
|
return print_mailer_error("InsetNoteMailer", in, 2, "Note");
|
||||||
|
|
||||||
params.read(lex);
|
params.read(lex);
|
||||||
}
|
}
|
||||||
|
@ -89,6 +89,8 @@ private:
|
|||||||
/// used by the constructors
|
/// used by the constructors
|
||||||
void init();
|
void init();
|
||||||
///
|
///
|
||||||
|
virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
|
||||||
|
///
|
||||||
friend class InsetNoteParams;
|
friend class InsetNoteParams;
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "Cursor.h"
|
#include "Cursor.h"
|
||||||
#include "Dimension.h"
|
#include "Dimension.h"
|
||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
|
#include "FuncStatus.h"
|
||||||
#include "Length.h"
|
#include "Length.h"
|
||||||
#include "Lexer.h"
|
#include "Lexer.h"
|
||||||
#include "MetricsInfo.h"
|
#include "MetricsInfo.h"
|
||||||
@ -142,6 +143,25 @@ void InsetSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool InsetSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||||
|
FuncStatus & status) const
|
||||||
|
{
|
||||||
|
switch (cmd.action) {
|
||||||
|
// we handle these
|
||||||
|
case LFUN_INSET_MODIFY:
|
||||||
|
if (cmd.getArg(0) == "space") {
|
||||||
|
InsetSpaceParams params;
|
||||||
|
InsetSpaceMailer::string2params(to_utf8(cmd.argument()), params);
|
||||||
|
status.setOnOff(params_.kind == params.kind);
|
||||||
|
} else
|
||||||
|
status.enabled(true);
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return Inset::getStatus(cur, cmd, status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetSpace::edit(Cursor & cur, bool, EntryDirection)
|
void InsetSpace::edit(Cursor & cur, bool, EntryDirection)
|
||||||
{
|
{
|
||||||
InsetSpaceMailer(*this).showDialog(&cur.bv());
|
InsetSpaceMailer(*this).showDialog(&cur.bv());
|
||||||
|
@ -128,6 +128,8 @@ private:
|
|||||||
virtual Inset * clone() const { return new InsetSpace(*this); }
|
virtual Inset * clone() const { return new InsetSpace(*this); }
|
||||||
///
|
///
|
||||||
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
||||||
|
///
|
||||||
|
bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
|
||||||
|
|
||||||
///
|
///
|
||||||
InsetSpaceParams params_;
|
InsetSpaceParams params_;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "Dimension.h"
|
#include "Dimension.h"
|
||||||
#include "DispatchResult.h"
|
#include "DispatchResult.h"
|
||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
|
#include "FuncStatus.h"
|
||||||
#include "support/gettext.h"
|
#include "support/gettext.h"
|
||||||
#include "Lexer.h"
|
#include "Lexer.h"
|
||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
@ -72,6 +73,31 @@ void InsetVSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool InsetVSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||||
|
FuncStatus & status) const
|
||||||
|
{
|
||||||
|
switch (cmd.action) {
|
||||||
|
// we handle these
|
||||||
|
case LFUN_INSET_MODIFY:
|
||||||
|
if (cmd.getArg(0) == "vspace") {
|
||||||
|
VSpace vspace;
|
||||||
|
InsetVSpaceMailer::string2params(to_utf8(cmd.argument()), vspace);
|
||||||
|
status.setOnOff(vspace == space_);
|
||||||
|
} else
|
||||||
|
status.enabled(true);
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return Inset::getStatus(cur, cmd, status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InsetVSpace::edit(Cursor & cur, bool, EntryDirection)
|
||||||
|
{
|
||||||
|
InsetVSpaceMailer(*this).showDialog(&cur.bv());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetVSpace::read(Lexer & lex)
|
void InsetVSpace::read(Lexer & lex)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(lex.isOK());
|
BOOST_ASSERT(lex.isOK());
|
||||||
@ -209,6 +235,12 @@ int InsetVSpace::docbook(odocstream & os, OutputParams const &) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
docstring InsetVSpace::contextMenu(BufferView const &, int, int) const
|
||||||
|
{
|
||||||
|
return from_ascii("context-vspace");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
string const InsetVSpaceMailer::name_ = "vspace";
|
string const InsetVSpaceMailer::name_ = "vspace";
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,6 +30,15 @@ public:
|
|||||||
~InsetVSpace();
|
~InsetVSpace();
|
||||||
/// How much?
|
/// How much?
|
||||||
VSpace const & space() const { return space_; }
|
VSpace const & space() const { return space_; }
|
||||||
|
///
|
||||||
|
InsetCode lyxCode() const { return VSPACE_CODE; }
|
||||||
|
///
|
||||||
|
void edit(Cursor & cur, bool front,
|
||||||
|
EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
|
||||||
|
///
|
||||||
|
EDITABLE editable() const { return IS_EDITABLE; }
|
||||||
|
///
|
||||||
|
virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
||||||
@ -50,6 +59,8 @@ private:
|
|||||||
///
|
///
|
||||||
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
||||||
///
|
///
|
||||||
|
bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
|
||||||
|
///
|
||||||
Inset * clone() const { return new InsetVSpace(*this); }
|
Inset * clone() const { return new InsetVSpace(*this); }
|
||||||
///
|
///
|
||||||
docstring const label() const;
|
docstring const label() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user