}
if (it.getInset()->getInsetFromID(id)) {
text->setCursorIntern(pit, it.getPos());
- it.getInset()->edit(this);
+ FuncRequest cmd(this, LFUN_INSET_EDIT, "left");
+ it.getInset()->localDispatch(cmd);
return theLockingInset()->lockInsetInInset(this, inset);
}
}
+2003-05-16 André Pönitz <poenitz@gmx.net>
+
+ * BufferView.C:
+ * lyxfunc.C:
+ * text.C:
+ * text2.C:
+ * text3.C:
+ * undo_funcs.C: edit() -> LFUN_INSET_EDIT
+
2003-05-14 Alfredo Braunstein <abraunst@libero.it>
* lyx_main.C (init): remove spurious static_cast
+
+2003-05-16 André Pönitz <poenitz@gmx.net>
+
+ * inset.[Ch]:
+ * insetbibitem.[Ch]:
+ * insetbibtex.[Ch]:
+ * insetbutton.[Ch]:
+ * insetcite.[Ch]:
+ * insetcollapsable.[Ch]:
+ * insetcommand.[Ch]:
+ * inseterror.[Ch]:
+ * insetert.[Ch]:
+ * insetexternal.[Ch]:
+ * insetfloatlist.[Ch]:
+ * insetgraphics.[Ch]:
+ * insetinclude.[Ch]:
+ * insetindex.[Ch]:
+ * insetlabel.[Ch]:
+ * insetlatexaccent.[Ch]:
+ * insetparent.[Ch]:
+ * insetref.[Ch]:
+ * insettabular.[Ch]:
+ * insettext.[Ch]:
+ * insettoc.[Ch]:
+ * inseturl.[Ch]:
+ * updatableinset.[Ch]: edit() -> LFUN_INSET_EDIT
+
2003-05-13 André Pönitz <poenitz@gmx.net>
* insetbibitem.C:
using std::endl;
-// Insets default methods
// Initialization of the counter for the inset id's,
unsigned int Inset::inset_id = 0;
}
-void Inset::edit(BufferView *, int, int, mouse_button::state)
-{}
-
-
void Inset::validate(LaTeXFeatures &) const
{}
}
-void Inset::edit(BufferView *, bool)
-{}
-
-
#if 0
LyXFont const Inset::convertFont(LyXFont const & font) const
{
{}
-bool Inset::forceDefaultParagraphs(Inset const * in) const
+bool Inset::forceDefaultParagraphs(Inset const * inset) const
{
if (owner())
- return owner()->forceDefaultParagraphs(in);
+ return owner()->forceDefaultParagraphs(inset);
return false;
}
#ifndef INSET_H
#define INSET_H
-
-#include <vector>
#include "LString.h"
#include "LColor.h"
#include "insetbase.h"
#include "frontends/mouse_state.h"
#include "support/types.h"
+#include <vector>
+
class LyXFont;
class Buffer;
class Painter;
/// what appears in the minibuffer when opening
virtual string const editMessage() const;
///
- virtual void edit(BufferView *, int x, int y, mouse_button::state button);
- ///
- virtual void edit(BufferView *, bool front = true);
- ///
virtual EDITABLE editable() const;
///
virtual bool isTextInset() const { return false; }
int InsetBibitem::key_counter = 0;
const string key_prefix = "key-";
+
InsetBibitem::InsetBibitem(InsetCommandParams const & p)
: InsetCommand(p), counter(1)
{
dispatch_result InsetBibitem::localDispatch(FuncRequest const & cmd)
{
- Inset::RESULT result = UNDISPATCHED;
-
switch (cmd.action) {
+
+ case LFUN_INSET_EDIT:
+ InsetCommandMailer("bibitem", *this).showDialog(cmd.view());
+ return DISPATCHED;
+
case LFUN_INSET_MODIFY: {
InsetCommandParams p;
InsetCommandMailer::string2params(cmd.argument, p);
if (p.getCmdName().empty())
- break;
+ return DISPATCHED;
if (view() && p.getContents() != params().getContents()) {
view()->ChangeCitationsIfUnique(params().getContents(),
#warning and whether the repaint() is needed at all
cmd.view()->repaint();
cmd.view()->fitCursor();
-
- result = DISPATCHED;
+ return DISPATCHED;
}
- break;
+
default:
- result = InsetCommand::localDispatch(cmd);
+ return InsetCommand::localDispatch(cmd);
}
-
- return result;
}
}
-void InsetBibitem::edit(BufferView * bv, int, int, mouse_button::state)
-{
- InsetCommandMailer mailer("bibitem", *this);
- mailer.showDialog(bv);
-}
-
-
-void InsetBibitem::edit(BufferView * bv, bool)
-{
- edit(bv, 0, 0, mouse_button::none);
-}
-
-
// ale070405 This function maybe shouldn't be here. We'll fix this at 0.13.
int bibitemMaxWidth(BufferView * bv, LyXFont const & font)
{
///
virtual string const getScreenLabel(Buffer const *) const;
///
- void edit(BufferView *, int x, int y, mouse_button::state button);
- ///
- void edit(BufferView * bv, bool front = true);
- ///
EDITABLE editable() const { return IS_EDITABLE; }
///
Inset::Code lyxCode() const { return Inset::BIBITEM_CODE; }
///
void setCounter(int);
///
- int getCounter() const { return counter; }
+ int getCounter() const { return counter; }
///
string const getBibLabel() const;
///
dispatch_result InsetBibtex::localDispatch(FuncRequest const & cmd)
{
- Inset::RESULT result = UNDISPATCHED;
-
switch (cmd.action) {
+
+ case LFUN_INSET_EDIT:
+ InsetCommandMailer("bibtex", *this).showDialog(cmd.view());
+ return DISPATCHED;
+
case LFUN_INSET_MODIFY: {
InsetCommandParams p;
InsetCommandMailer::string2params(cmd.argument, p);
if (p.getCmdName().empty())
- break;
+ return DISPATCHED;
if (view() && p.getContents() != params().getContents()) {
view()->ChangeCitationsIfUnique(params().getContents(),
setParams(p);
cmd.view()->updateInset(this);
- result = DISPATCHED;
+ return DISPATCHED;
}
- break;
+
default:
- result = InsetCommand::localDispatch(cmd);
+ return InsetCommand::localDispatch(cmd);
}
- return result;
}
string const InsetBibtex::getScreenLabel(Buffer const *) const
}
-void InsetBibtex::edit(BufferView * bv, int, int, mouse_button::state)
-{
- InsetCommandMailer mailer("bibtex", *this);
- mailer.showDialog(bv);
-}
-
-
-void InsetBibtex::edit(BufferView * bv, bool)
-{
- edit(bv, 0, 0, mouse_button::none);
-}
-
-
bool InsetBibtex::addDatabase(string const & db)
{
string contents(getContents());
///
Inset::Code lyxCode() const { return Inset::BIBTEX_CODE; }
///
- void edit(BufferView *, int x, int y, mouse_button::state button);
- ///
- void edit(BufferView * bv, bool front = true);
- ///
int latex(Buffer const *, std::ostream &,
bool fragile, bool freespace) const;
///
dispatch_result InsetButton::localDispatch(FuncRequest const & cmd)
{
- FuncRequest cmd1(cmd);
- edit(cmd1.view(), cmd1.x, cmd1.y, cmd1.button());
- return DISPATCHED;
+ return Inset::localDispatch(cmd);
}
#include <config.h>
#include "insetcite.h"
+#include "funcrequest.h"
#include "buffer.h"
#include "BufferView.h"
#include "LaTeXFeatures.h"
}
-void InsetCitation::edit(BufferView * bv, int, int, mouse_button::state)
+dispatch_result InsetCitation::localDispatch(FuncRequest const & cmd)
{
- // A call to edit() indicates that we're no longer loading the
- // buffer but doing some real work.
- setLoadingBuffer(bv->buffer(), false);
-
- InsetCommandMailer mailer("citation", *this);
- mailer.showDialog(bv);
-}
-
-
-void InsetCitation::edit(BufferView * bv, bool)
-{
- edit(bv, 0, 0, mouse_button::none);
+ switch (cmd.action) {
+ case LFUN_INSET_EDIT:
+ // A call to edit indicates that we're no longer loading the
+ // buffer but doing some real work.
+ setLoadingBuffer(cmd.view()->buffer(), false);
+ InsetCommandMailer("citation", *this).showDialog(cmd.view());
+ break;
+
+ default:
+ return UNDISPATCHED;
+ }
+ return DISPATCHED;
}
///
Inset::Code lyxCode() const { return Inset::CITE_CODE; }
///
- void edit(BufferView *, int, int, mouse_button::state);
- ///
- void edit(BufferView * bv, bool front = true);
- ///
int ascii(Buffer const *, std::ostream &, int linelen) const;
///
int latex(Buffer const *, std::ostream &, bool, bool) const;
///
+ dispatch_result localDispatch(FuncRequest const & cmd);
+ ///
void validate(LaTeXFeatures &) const;
/** Invoked by BufferView::Pimpl::dispatch when a new citation key
is inserted. Tells us that the buffer is no longer being loaded
using std::max;
-class LyXText;
-
-
InsetCollapsable::InsetCollapsable(BufferParams const & bp, bool collapsed)
: UpdatableInset(), collapsed_(collapsed), inset(bp),
button_length(0), button_top_y(0), button_bottom_y(0),
}
-void InsetCollapsable::edit(BufferView * bv, int xp, int yp,
- mouse_button::state button)
-{
-#ifdef WITH_WARNINGS
-#warning Fix this properly in BufferView_pimpl::workAreaButtonRelease
-#endif
- if (button == mouse_button::button3)
- return;
-
- UpdatableInset::edit(bv, xp, yp, button);
-
- if (collapsed_) {
- collapsed_ = false;
- // set this only here as it should be recollapsed only if
- // it was already collapsed!
- first_after_edit = true;
- if (!bv->lockInset(this))
- return;
- bv->updateInset(this);
- bv->buffer()->markDirty();
- inset.edit(bv);
- } else {
- if (!bv->lockInset(this))
- return;
- if (yp <= button_bottom_y) {
- inset.edit(bv, xp, 0, button);
- } else {
- LyXFont font(LyXFont::ALL_SANE);
- int yy = ascent(bv, font) + yp -
- (ascent_collapsed() +
- descent_collapsed() +
- inset.ascent(bv, font));
- inset.edit(bv, xp, yy, button);
- }
- }
-}
-
-
-void InsetCollapsable::edit(BufferView * bv, bool front)
-{
- UpdatableInset::edit(bv, front);
-
- if (collapsed_) {
- collapsed_ = false;
- if (!bv->lockInset(this))
- return;
- inset.setUpdateStatus(bv, InsetText::FULL);
- bv->updateInset(this);
- bv->buffer()->markDirty();
- inset.edit(bv, front);
- first_after_edit = true;
- } else {
- if (!bv->lockInset(this))
- return;
- inset.edit(bv, front);
- }
-}
-
-
Inset::EDITABLE InsetCollapsable::editable() const
{
if (collapsed_)
Inset::RESULT InsetCollapsable::localDispatch(FuncRequest const & cmd)
{
+ BufferView * bv = cmd.view();
switch (cmd.action) {
+ case LFUN_INSET_EDIT: {
+ if (!cmd.argument.empty()) {
+ UpdatableInset::localDispatch(cmd);
+ if (collapsed_) {
+ collapsed_ = false;
+ if (bv->lockInset(this)) {
+ inset.setUpdateStatus(bv, InsetText::FULL);
+ bv->updateInset(this);
+ bv->buffer()->markDirty();
+ inset.localDispatch(cmd);
+ first_after_edit = true;
+ }
+ } else {
+ if (bv->lockInset(this))
+ inset.localDispatch(cmd);
+ }
+ return DISPATCHED;
+ }
+
+#ifdef WITH_WARNINGS
+#warning Fix this properly in BufferView_pimpl::workAreaButtonRelease
+#endif
+ if (cmd.button() == mouse_button::button3)
+ return DISPATCHED;
+
+ UpdatableInset::localDispatch(cmd);
+
+ if (collapsed_) {
+ collapsed_ = false;
+ // set this only here as it should be recollapsed only if
+ // it was already collapsed!
+ first_after_edit = true;
+ if (!bv->lockInset(this))
+ return DISPATCHED;
+ bv->updateInset(this);
+ bv->buffer()->markDirty();
+ inset.localDispatch(cmd);
+ } else {
+ FuncRequest cmd1 = cmd;
+ if (!bv->lockInset(this))
+ return DISPATCHED;
+ if (cmd.y <= button_bottom_y) {
+ cmd1.y = 0;
+ } else {
+ LyXFont font(LyXFont::ALL_SANE);
+ cmd1.y = ascent(bv, font) + cmd.y -
+ (ascent_collapsed() +
+ descent_collapsed() +
+ inset.ascent(bv, font));
+ }
+ inset.localDispatch(cmd);
+ }
+ return DISPATCHED;
+ }
case LFUN_MOUSE_PRESS:
lfunMousePress(cmd);
default:
UpdatableInset::RESULT result = inset.localDispatch(cmd);
if (result >= FINISHED)
- cmd.view()->unlockInset(this);
+ bv->unlockInset(this);
first_after_edit = false;
return result;
}
- return UNDISPATCHED;
}
#ifndef INSETCOLLAPSABLE_H
#define INSETCOLLAPSABLE_H
-
#include "inset.h"
#include "insettext.h"
#include "lyxfont.h"
///
void update(BufferView *, bool =false);
///
- void edit(BufferView *, int, int, mouse_button::state);
- ///
- void edit(BufferView *, bool front = true);
- ///
EDITABLE editable() const;
///
bool insertInset(BufferView *, Inset * inset);
dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd)
{
- dispatch_result result = UNDISPATCHED;
-
+ lyxerr << "insetCommand::localDispatch\n";
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
InsetCommandParams p;
InsetCommandMailer::string2params(cmd.argument, p);
if (p.getCmdName().empty())
- break;
+ return UNDISPATCHED;
setParams(p);
cmd.view()->updateInset(this);
- result = DISPATCHED;
+ return DISPATCHED;
}
- break;
- case LFUN_INSET_DIALOG_UPDATE: {
- InsetCommandMailer mailer(cmd.argument, *this);
- mailer.updateDialog(cmd.view());
- result = DISPATCHED;
- }
- break;
+ case LFUN_INSET_DIALOG_UPDATE:
+ InsetCommandMailer(cmd.argument, *this).updateDialog(cmd.view());
+ return DISPATCHED;
case LFUN_MOUSE_RELEASE:
- edit(cmd.view(), cmd.x, cmd.y, cmd.button());
- result = DISPATCHED;
- break;
+ return localDispatch(FuncRequest(cmd.view(), LFUN_INSET_EDIT));
default:
- break;
+ return UNDISPATCHED;
}
- return result;
}
using std::ostream;
-/* Error, used for the LaTeX-Error Messages */
InsetError::InsetError(string const & str, bool)
: contents(str)
dispatch_result result = UNDISPATCHED;
switch (cmd.action) {
- case LFUN_MOUSE_RELEASE:
- edit(cmd.view(), cmd.x, cmd.y, cmd.button());
- break;
+ case LFUN_MOUSE_RELEASE:
+ case LFUN_INSET_EDIT:
+ cmd.view()->owner()->getDialogs().show("error", getContents(), this);
+ return DISPATCHED;
default:
- break;
+ return Inset::localDispatch(cmd);
}
-
- return result;
}
{
return _("Opened error");
}
-
-
-void InsetError::edit(BufferView * bv, int, int, mouse_button::state)
-{
- bv->owner()->getDialogs().show("error", getContents(), this);
-}
-
-
-void InsetError::edit(BufferView * bv, bool)
-{
- edit(bv, 0, 0, mouse_button::none);
-}
#ifndef INSET_ERROR_H
#define INSET_ERROR_H
-
#include "inset.h"
#include "LString.h"
/// what appears in the minibuffer when opening
string const editMessage() const;
///
- void edit(BufferView *, int, int, mouse_button::state);
- ///
- void edit(BufferView * bv, bool front = true);
- ///
EDITABLE editable() const { return IS_EDITABLE; }
///
Inset * clone(Buffer const &, bool same_id = false) const {
}
}
-void InsetERT::edit(BufferView * bv, int x, int y, mouse_button::state button)
-{
- if (button == mouse_button::button3)
- return;
-
- if (status_ == Inlined) {
- if (!bv->lockInset(this))
- return;
- inset.edit(bv, x, y, button);
- } else {
- InsetCollapsable::edit(bv, x, y, button);
- }
- set_latex_font(bv);
- updateStatus(bv);
-}
-
Inset::EDITABLE InsetERT::editable() const
{
}
-void InsetERT::edit(BufferView * bv, bool front)
-{
- InsetCollapsable::edit(bv, front);
- updateStatus(0);
- set_latex_font(bv);
-}
-
-
void InsetERT::lfunMousePress(FuncRequest const & cmd)
{
if (status_ == Inlined)
}
switch (cmd.action) {
+
+ case LFUN_INSET_EDIT:
+ if (cmd.button() == mouse_button::button3)
+ break;
+ if (status_ == Inlined) {
+ if (!bv->lockInset(this))
+ break;
+ result = inset.localDispatch(cmd);
+ } else {
+ result = InsetCollapsable::localDispatch(cmd);
+ }
+ set_latex_font(bv);
+ updateStatus(bv);
+ break;
+
case LFUN_INSET_MODIFY: {
InsetERT::ERTStatus status_;
InsetERTMailer::string2params(cmd.argument, status_);
void setFont(BufferView *, LyXFont const &,
bool toggleall = false, bool selectall = false);
///
- void edit(BufferView *, int, int, mouse_button::state);
- ///
- void edit(BufferView * bv, bool front = true);
- ///
EDITABLE editable() const;
///
int latex(Buffer const *, std::ostream &, bool fragile,
#include <cstdio>
#include <utility>
-
using std::ostream;
using std::endl;
dispatch_result InsetExternal::localDispatch(FuncRequest const & cmd)
{
- dispatch_result result = UNDISPATCHED;
-
switch (cmd.action) {
+
case LFUN_INSET_MODIFY: {
InsetExternal::Params p;
InsetExternalMailer::string2params(cmd.argument, p);
- if (p.filename.empty())
- break;
-
- setFromParams(p);
- cmd.view()->updateInset(this);
- result = DISPATCHED;
+ if (!p.filename.empty()) {
+ setFromParams(p);
+ cmd.view()->updateInset(this);
+ }
+ return DISPATCHED;
}
- break;
- case LFUN_INSET_DIALOG_UPDATE: {
- InsetExternalMailer mailer(*this);
- mailer.updateDialog(cmd.view());
- }
- break;
+ case LFUN_INSET_DIALOG_UPDATE:
+ InsetExternalMailer(*this).updateDialog(cmd.view());
+ return DISPATCHED;
case LFUN_MOUSE_RELEASE:
- edit(cmd.view(), cmd.x, cmd.y, cmd.button());
- result = DISPATCHED;
- break;
+ case LFUN_INSET_EDIT:
+ InsetExternalMailer(*this).showDialog(cmd.view());
+ return DISPATCHED;
default:
- break;
+ return UNDISPATCHED;
}
-
- return result;
}
}
-void InsetExternal::edit(BufferView * bv, int, int, mouse_button::state)
-{
- InsetExternalMailer mailer(*this);
- mailer.showDialog(bv);
-}
-
-
-void InsetExternal::edit(BufferView * bv, bool)
-{
- edit(bv, 0, 0, mouse_button::none);
-}
-
-
void InsetExternal::write(Buffer const *, ostream & os) const
{
os << "External " << params_.templ.lyxName << ",\""
#ifndef INSET_EXTERNAL_H
#define INSET_EXTERNAL_H
-
#include "insetbutton.h"
#include "ExternalTemplate.h"
#include "LString.h"
/// what appears in the minibuffer when opening
virtual string const editMessage() const;
///
- virtual void edit(BufferView *, int x, int y, mouse_button::state button);
- ///
- virtual void edit(BufferView * bv, bool front = true);
- ///
virtual EDITABLE editable() const { return IS_EDITABLE; }
///
virtual void write(Buffer const *, std::ostream &) const;
#include "LaTeXFeatures.h"
#include "lyxlex.h"
#include "BufferView.h"
+#include "funcrequest.h"
#include "buffer.h"
#include "toc.h"
#include "gettext.h"
#include "support/lstrings.h"
-#include "frontends/Dialogs.h"
-#include "frontends/LyXView.h"
-
using std::ostream;
using std::endl;
}
-void InsetFloatList::edit(BufferView * bv, int, int, mouse_button::state)
+dispatch_result InsetFloatList::localDispatch(FuncRequest const & cmd)
{
- InsetCommandMailer mailer("toc", *this);
- mailer.showDialog(bv);
-}
-
-
-void InsetFloatList::edit(BufferView * bv, bool)
-{
- edit(bv, 0, 0, mouse_button::none);
+ switch (cmd.action) {
+ case LFUN_INSET_EDIT:
+ InsetCommandMailer("toc", *this).showDialog(cmd.view());
+ return DISPATCHED;
+ default:
+ return InsetCommand::localDispatch(cmd);
+ }
}
return new InsetFloatList(getCmdName());
}
///
- string const getScreenLabel(Buffer const *) const;
- ///
- void edit(BufferView * bv, int, int, mouse_button::state);
+ dispatch_result localDispatch(FuncRequest const & cmd);
///
- void edit(BufferView * bv, bool front = true);
+ string const getScreenLabel(Buffer const *) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///
#include "funcrequest.h"
#include "gettext.h"
#include "LaTeXFeatures.h"
+#include "Lsstream.h"
#include "lyxlex.h"
#include "lyxrc.h"
#include "Lsstream.h"
dispatch_result InsetGraphics::localDispatch(FuncRequest const & cmd)
{
- dispatch_result result = UNDISPATCHED;
-
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
InsetGraphicsParams p;
InsetGraphicsMailer::string2params(cmd.argument, p);
- if (p.filename.empty())
- break;
-
- string const filepath = cmd.view()->buffer()->filePath();
- setParams(p, filepath);
- cmd.view()->updateInset(this);
- result = DISPATCHED;
+ if (!p.filename.empty()) {
+ string const filepath = cmd.view()->buffer()->filePath();
+ setParams(p, filepath);
+ cmd.view()->updateInset(this);
+ }
+ return DISPATCHED;
}
- break;
- case LFUN_INSET_DIALOG_UPDATE: {
- InsetGraphicsMailer mailer(*this);
- mailer.updateDialog(cmd.view());
- }
- break;
+ case LFUN_INSET_DIALOG_UPDATE:
+ InsetGraphicsMailer(*this).updateDialog(cmd.view());
+ return DISPATCHED;
+ case LFUN_INSET_EDIT:
case LFUN_MOUSE_RELEASE:
- edit(cmd.view(), cmd.x, cmd.y, cmd.button());
- break;
+ InsetGraphicsMailer(*this).showDialog(cmd.view());
+ return DISPATCHED;
default:
- result = DISPATCHED;
- break;
+ return Inset::localDispatch(cmd);
}
-
- return result;
}
}
-void InsetGraphics::edit(BufferView * bv, int, int, mouse_button::state)
-{
- InsetGraphicsMailer mailer(*this);
- mailer.showDialog(bv);
-}
-
-
-void InsetGraphics::edit(BufferView * bv, bool)
-{
- edit(bv, 0, 0, mouse_button::none);
-}
-
-
Inset::EDITABLE InsetGraphics::editable() const
{
return IS_EDITABLE;
#ifndef INSET_GRAPHICS_H
#define INSET_GRAPHICS_H
-
-
#include "insets/inset.h"
#include "insets/insetgraphicsParams.h"
///
void draw(BufferView *, LyXFont const &, int, float &) const;
///
- void edit(BufferView *, int, int, mouse_button::state);
- ///
- void edit(BufferView * bv, bool front = true);
- ///
EDITABLE editable() const;
///
void write(Buffer const *, std::ostream &) const;
dispatch_result InsetInclude::localDispatch(FuncRequest const & cmd)
{
- dispatch_result result = UNDISPATCHED;
-
switch (cmd.action) {
+
case LFUN_INSET_MODIFY: {
InsetInclude::Params p;
InsetIncludeMailer::string2params(cmd.argument, p);
- if (p.cparams.getCmdName().empty())
- break;
-
- set(p);
- params_.masterFilename_ = cmd.view()->buffer()->fileName();
-
- cmd.view()->updateInset(this);
- result = DISPATCHED;
+ if (!p.cparams.getCmdName().empty()) {
+ set(p);
+ params_.masterFilename_ = cmd.view()->buffer()->fileName();
+ cmd.view()->updateInset(this);
+ }
+ return DISPATCHED;
}
- break;
- case LFUN_INSET_DIALOG_UPDATE: {
- InsetIncludeMailer mailer(*this);
- mailer.updateDialog(cmd.view());
- }
- break;
+ case LFUN_INSET_DIALOG_UPDATE:
+ InsetIncludeMailer(*this).updateDialog(cmd.view());
+ return DISPATCHED;
case LFUN_MOUSE_RELEASE:
- edit(cmd.view(), cmd.x, cmd.y, cmd.button());
- break;
+ case LFUN_INSET_EDIT:
+ InsetIncludeMailer(*this).showDialog(cmd.view());
+ return DISPATCHED;
default:
- break;
+ return UNDISPATCHED;
}
-
- return result;
}
bool InsetInclude::Params::operator==(Params const & o) const
{
- if (cparams == o.cparams && flag == o.flag &&
- masterFilename_ == o.masterFilename_)
- return true;
-
- return false;
+ return cparams == o.cparams && flag == o.flag &&
+ masterFilename_ == o.masterFilename_;
}
}
-void InsetInclude::edit(BufferView * bv, int, int, mouse_button::state)
-{
- InsetIncludeMailer mailer(*this);
- mailer.showDialog(bv);
-}
-
-
-void InsetInclude::edit(BufferView * bv, bool)
-{
- edit(bv, 0, 0, mouse_button::none);
-}
-
-
void InsetInclude::write(Buffer const *, ostream & os) const
{
os << "Include " << params_.cparams.getCommand() << '\n'
#ifndef INSET_INCLUDE_H
#define INSET_INCLUDE_H
-
#include "insetcommand.h"
#include <boost/scoped_ptr.hpp>
/// This returns the list of bibkeys on the child buffer
void fillWithBibKeys(std::vector<std::pair<string,string> > & keys) const;
///
- void edit(BufferView *, int x, int y, mouse_button::state button);
- ///
- void edit(BufferView * bv, bool front = true);
- ///
EDITABLE editable() const
{
return IS_EDITABLE;
#include "insetindex.h"
#include "BufferView.h"
+#include "funcrequest.h"
#include "frontends/LyXView.h"
#include "frontends/Dialogs.h"
#include "LaTeXFeatures.h"
}
-void InsetIndex::edit(BufferView * bv, int, int, mouse_button::state)
+dispatch_result InsetIndex::localDispatch(FuncRequest const & cmd)
{
- InsetCommandMailer mailer("index", *this);
- mailer.showDialog(bv);
-}
-
-
-void InsetIndex::edit(BufferView * bv, bool)
-{
- edit(bv, 0, 0, mouse_button::none);
+ switch (cmd.action) {
+ case LFUN_INSET_EDIT:
+ InsetCommandMailer("index", *this).showDialog(cmd.view());
+ return DISPATCHED;
+
+ default:
+ return UNDISPATCHED;
+ }
}
}
+
InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p, bool)
: InsetCommand(p)
{}
+InsetPrintIndex::~InsetPrintIndex()
+{}
+
+
string const InsetPrintIndex::getScreenLabel(Buffer const *) const
{
return _("Index");
return new InsetIndex(params(), same_id);
}
///
+ dispatch_result localDispatch(FuncRequest const & cmd);
+ ///
string const getScreenLabel(Buffer const *) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///
- void edit(BufferView *, int, int, mouse_button::state);
- ///
- void edit(BufferView * bv, bool front = true);
- ///
Inset::Code lyxCode() const;
///
int docbook(Buffer const *, std::ostream &, bool mixcont) const;
///
InsetPrintIndex(InsetCommandParams const &, bool same_id = false);
///
- virtual Inset * clone(Buffer const &, bool same_id = false) const {
+ ~InsetPrintIndex();
+ ///
+ Inset * clone(Buffer const &, bool same_id = false) const {
return new InsetPrintIndex(params(), same_id);
}
+ ///
+ //dispatch_result localDispatch(FuncRequest const & cmd);
/// Updates needed features for this inset.
void validate(LaTeXFeatures & features) const;
///
- void edit(BufferView *, int, int, mouse_button::state) {}
- ///
- void edit(BufferView *, bool = true) {}
- ///
EDITABLE editable() const { return NOT_EDITABLE; }
///
bool display() const { return true; }
}
-void InsetLabel::edit(BufferView * bv, int, int, mouse_button::state)
-{
- InsetCommandMailer mailer("label", *this);
- mailer.showDialog(bv);
-}
-
-
dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd)
{
Inset::RESULT result = UNDISPATCHED;
switch (cmd.action) {
+
+ case LFUN_INSET_EDIT:
+ InsetCommandMailer("label", *this).showDialog(cmd.view());
+ result = DISPATCHED;
+ break;
+
case LFUN_INSET_MODIFY: {
InsetCommandParams p;
InsetCommandMailer::string2params(cmd.argument, p);
}
-void InsetLabel::edit(BufferView * bv, bool)
-{
- edit(bv, 0, 0, mouse_button::none);
-}
-
-
int InsetLabel::latex(Buffer const *, ostream & os,
bool /*fragile*/, bool /*fs*/) const
{
///
Inset::Code lyxCode() const { return Inset::LABEL_CODE; }
///
- void edit(BufferView *, int, int, mouse_button::state);
- ///
- void edit(BufferView * bv, bool front = true);
- ///
std::vector<string> const getLabelList() const;
///
int latex(Buffer const *, std::ostream &,
#include <config.h>
-
#include "insetlatexaccent.h"
+
#include "debug.h"
#include "lyxrc.h"
#include "support/lstrings.h"
using std::ostream;
using std::endl;
+
/* LatexAccent. Proper handling of accented characters */
/* This part is done by Ivan Schreter, schreter@ccsun.tuke.sk */
/* Later modified by Lars G. Bjønnes, larsbj@lyx.org */
lyxerr[Debug::KEY] << "Decode: " << contents << endl;
- remdot = false; plusasc = false; plusdesc = false;
+ remdot = false;
+ plusasc = false;
+ plusdesc = false;
switch (contents[1]) { // second char should be one of these
case '\'': // acute
#include <config.h>
-
-
#include "insetparent.h"
-#include "support/filetools.h"
#include "BufferView.h"
#include "frontends/LyXView.h"
#include "support/LOstream.h"
#include "buffer.h"
#include "gettext.h"
-#include "support/BoostFormat.h"
+#include "support/filetools.h"
+#include "support/lstrings.h"
using std::ostream;
string const InsetParent::getScreenLabel(Buffer const *) const
{
-#if USE_BOOST_FORMAT
- return STRCONV(boost::io::str(boost::format(_("Parent: %s"))
- % STRCONV(getContents())));
-#else
- return _("Parent: ") + getContents();
-#endif
-}
-
-
-void InsetParent::edit(BufferView * bv, int, int, mouse_button::state)
-{
- bv->owner()->dispatch(FuncRequest(LFUN_CHILDOPEN, getContents()));
+ return bformat(_("Parent: %1$s"), getContents());
}
-void InsetParent::edit(BufferView * bv, bool)
+dispatch_result InsetParent::localDispatch(FuncRequest const & cmd)
{
- edit(bv, 0, 0, mouse_button::none);
+ switch (cmd.action) {
+ case LFUN_INSET_EDIT:
+ cmd.view()->owner()->dispatch(FuncRequest(LFUN_CHILDOPEN, getContents()));
+ return DISPATCHED;
+ default:
+ return UNDISPATCHED;
+ }
}
return new InsetParent(params(), buffer, same_id);
}
///
+ dispatch_result localDispatch(FuncRequest const & cmd);
+ ///
string const getScreenLabel(Buffer const *) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///
Inset::Code lyxCode() const { return Inset::PARENT_CODE; }
///
- void edit(BufferView *, int, int, mouse_button::state);
- ///
- void edit(BufferView * bv, bool front = true);
- ///
int latex(Buffer const *, std::ostream &,
bool fragile, bool free_spc) const;
///
- void setParent(string fn) { setContents(fn); }
+ void setParent(string const & fn) { setContents(fn); }
};
#endif
InsetRef::~InsetRef()
{
- InsetCommandMailer mailer("ref", *this);
- mailer.hideDialog();
+ InsetCommandMailer("ref", *this).hideDialog();
}
-void InsetRef::edit(BufferView * bv, int, int, mouse_button::state button)
+dispatch_result InsetRef::localDispatch(FuncRequest const & cmd)
{
- // FuncRequestually trigger dialog with button 3 not 1
- if (button == mouse_button::button3)
- bv->owner()->dispatch(FuncRequest(LFUN_REF_GOTO, getContents()));
- else if (button == mouse_button::button1) {
- InsetCommandMailer mailer("ref", *this);
- mailer.showDialog(bv);
+ switch (cmd.action) {
+ case LFUN_INSET_EDIT:
+ // Eventually trigger dialog with button 3 not 1
+ if (cmd.button() == mouse_button::button3)
+ cmd.view()->owner()->
+ dispatch(FuncRequest(LFUN_REF_GOTO, getContents()));
+ if (cmd.button() == mouse_button::button1)
+ InsetCommandMailer("ref", *this).showDialog(cmd.view());
+ return DISPATCHED;
+
+ default:
+ return UNDISPATCHED;
}
}
-void InsetRef::edit(BufferView *, bool)
-{}
-
-
string const InsetRef::getScreenLabel(Buffer const *) const
{
string temp;
return new InsetRef(params(), buffer, same_id);
}
///
+ dispatch_result localDispatch(FuncRequest const & cmd);
+ ///
string const getScreenLabel(Buffer const *) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///
Inset::Code lyxCode() const { return Inset::REF_CODE; }
///
- void edit(BufferView *, int, int, mouse_button::state);
- ///
- void edit(BufferView * bv, bool front = true);
- ///
bool display() const { return false; }
///
int latex(Buffer const *, std::ostream &,
}
-void InsetTabular::edit(BufferView * bv, int x, int y, mouse_button::state button)
-{
- UpdatableInset::edit(bv, x, y, button);
-
- if (!bv->lockInset(this)) {
- lyxerr[Debug::INSETTEXT] << "InsetTabular::Cannot lock inset" << endl;
- return;
- }
- locked = true;
- the_locking_inset = 0;
- inset_x = 0;
- inset_y = 0;
- setPos(bv, x, y);
- clearSelection();
- finishUndo();
- if (insetHit(bv, x, y) && (button != mouse_button::button3)) {
- activateCellInsetAbs(bv, x, y, button);
- }
-}
-
-
-void InsetTabular::edit(BufferView * bv, bool front)
-{
- UpdatableInset::edit(bv, front);
-
- if (!bv->lockInset(this)) {
- lyxerr[Debug::INSETTEXT] << "InsetTabular::Cannot lock inset" << endl;
- return;
- }
- finishUndo();
- locked = true;
- the_locking_inset = 0;
- inset_x = 0;
- inset_y = 0;
- if (front) {
- if (isRightToLeft(bv))
- actcell = tabular->GetLastCellInRow(0);
- else
- actcell = 0;
- } else {
- if (isRightToLeft(bv))
- actcell = tabular->GetFirstCellInRow(tabular->rows()-1);
- else
- actcell = tabular->GetNumberOfCells() - 1;
- }
- clearSelection();
- resetPos(bv);
- bv->fitCursor();
-}
-
-
void InsetTabular::insetUnlock(BufferView * bv)
{
if (the_locking_inset) {
}
if (in->getInsetFromID(id)) {
actcell = i;
- in->edit(bv);
+ in->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT));
return the_locking_inset->lockInsetInInset(bv, inset);
}
}
// the_locking_inset->localDispatch might unlock it.
old_locking_inset = the_locking_inset;
RESULT result = UpdatableInset::localDispatch(cmd);
-
BufferView * bv = cmd.view();
+
+ if (cmd.action == LFUN_INSET_EDIT) {
+
+ if (!bv->lockInset(this)) {
+ lyxerr[Debug::INSETTEXT] << "InsetTabular::Cannot lock inset" << endl;
+ return DISPATCHED;
+ }
+
+ finishUndo();
+ locked = true;
+ the_locking_inset = 0;
+ inset_x = 0;
+ inset_y = 0;
+
+ if (cmd.argument.size()) {
+ if (cmd.argument == "left") {
+ if (isRightToLeft(bv))
+ actcell = tabular->GetLastCellInRow(0);
+ else
+ actcell = 0;
+ } else {
+ if (isRightToLeft(bv))
+ actcell = tabular->GetFirstCellInRow(tabular->rows()-1);
+ else
+ actcell = tabular->GetNumberOfCells() - 1;
+ }
+ clearSelection();
+ resetPos(bv);
+ bv->fitCursor();
+ }
+
+ else {
+ setPos(bv, cmd.x, cmd.y);
+ clearSelection();
+ finishUndo();
+ if (insetHit(bv, cmd.x, cmd.y) && cmd.button() != mouse_button::button3) {
+ activateCellInsetAbs(bv, cmd.x, cmd.y, cmd.button());
+ }
+ }
+ return DISPATCHED;
+ }
+
if (result == DISPATCHED || result == DISPATCHED_NOUPDATE) {
resetPos(bv);
return result;
}
//inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
//inset_y = cursor.y();
- inset->edit(bv, x, y, button);
+ inset->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT, x, y, button));
if (!the_locking_inset)
return false;
updateLocal(bv, CELL);
// otherwise we have to lock the next inset and ask for it's selecttion
UpdatableInset * inset =
static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
- inset->edit(bv, 0, 0, mouse_button::none);
+ inset->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT));
WordLangTuple word(selectNextWordInt(bv, value));
nodraw(false);
if (!word.word().empty())
// otherwise we have to lock the next inset and ask for it's selecttion
UpdatableInset * inset =
static_cast<UpdatableInset*>(tabular->GetCellInset(++actcell));
- inset->edit(bv);
+ inset->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT));
return selectNextWordInt(bv, value);
}
#ifndef INSETTABULAR_H
#define INSETTABULAR_H
-
#include "inset.h"
#include "tabular.h"
#include "LString.h"
void update(BufferView *, bool = false);
///
string const editMessage() const;
- ///
- void edit(BufferView *, int x, int y, mouse_button::state);
- ///
- void edit(BufferView * bv, bool front = true);
//
void insetUnlock(BufferView *);
///
using lyx::pos_type;
using lyx::textclass_type;
+
// These functions should probably go into bufferview_funcs somehow (Jug)
void InsetText::saveLyXTextState(LyXText * t) const
}
-void InsetText::edit(BufferView * bv, int x, int y, mouse_button::state button)
-{
- UpdatableInset::edit(bv, x, y, button);
-
- if (!bv->lockInset(this)) {
- lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
- return;
- }
- locked = true;
- the_locking_inset = 0;
- inset_pos = inset_x = inset_y = 0;
- inset_boundary = false;
- inset_par = 0;
- old_par = 0;
- int tmp_y = (y < 0) ? 0 : y;
- bool clear = false;
- if (!lt) {
- lt = getLyXText(bv);
- clear = true;
- }
- // we put here -1 and not button as now the button in the
- // edit call should not be needed we will fix this in 1.3.x
- // cycle hopefully (Jug 20020509)
- // FIXME: GUII I've changed this to none: probably WRONG
- if (!checkAndActivateInset(bv, x, tmp_y, mouse_button::none)) {
- lt->setCursorFromCoordinates(x - drawTextXOffset,
- y + insetAscent);
- lt->cursor.x_fix(lt->cursor.x());
- }
- lt->clearSelection();
- finishUndo();
- // If the inset is empty set the language of the current font to the
- // language to the surronding text (if different).
- if (paragraphs.begin()->empty() &&
- boost::next(paragraphs.begin()) == paragraphs.end()&&
- bv->getParentLanguage(this) != lt->current_font.language())
- {
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setLanguage(bv->getParentLanguage(this));
- setFont(bv, font, false);
- }
- if (clear)
- lt = 0;
-
- int code = CURSOR;
- if (drawFrame_ == LOCKED)
- code = CURSOR|DRAW_FRAME;
- updateLocal(bv, code, false);
-
- // Tell the paragraph dialog that we've entered an insettext.
- bv->dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
-}
-
-
-void InsetText::edit(BufferView * bv, bool front)
-{
- UpdatableInset::edit(bv, front);
-
- if (!bv->lockInset(this)) {
- lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
- return;
- }
- locked = true;
- the_locking_inset = 0;
- inset_pos = inset_x = inset_y = 0;
- inset_boundary = false;
- inset_par = 0;
- old_par = 0;
- bool clear = false;
- if (!lt) {
- lt = getLyXText(bv);
- clear = true;
- }
- if (front)
- lt->setCursor(paragraphs.begin(), 0);
- else {
- ParagraphList::iterator it = paragraphs.begin();
- ParagraphList::iterator end = paragraphs.end();
- while (boost::next(it) != end)
- ++it;
-// int const pos = (p->size() ? p->size()-1 : p->size());
- lt->setCursor(it, it->size());
- }
- lt->clearSelection();
- finishUndo();
- // If the inset is empty set the language of the current font to the
- // language to the surronding text (if different).
- if (paragraphs.begin()->empty() &&
- boost::next(paragraphs.begin()) == paragraphs.end() &&
- bv->getParentLanguage(this) != lt->current_font.language()) {
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setLanguage(bv->getParentLanguage(this));
- setFont(bv, font, false);
- }
- if (clear)
- lt = 0;
- int code = CURSOR;
- if (drawFrame_ == LOCKED)
- code = CURSOR|DRAW_FRAME;
- updateLocal(bv, code, false);
-}
-
-
void InsetText::insetUnlock(BufferView * bv)
{
if (the_locking_inset) {
}
if (it.getInset()->getInsetFromID(id)) {
getLyXText(bv)->setCursorIntern(pit, it.getPos());
- it.getInset()->edit(bv);
+ it.getInset()->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT));
return the_locking_inset->lockInsetInInset(bv, inset);
}
}
}
-Inset::RESULT InsetText::localDispatch(FuncRequest const & ev)
+Inset::RESULT InsetText::localDispatch(FuncRequest const & cmd)
{
- BufferView * bv = ev.view();
- switch (ev.action) {
+ BufferView * bv = cmd.view();
+
+ if (cmd.action == LFUN_INSET_EDIT) {
+ UpdatableInset::localDispatch(cmd);
+
+ if (!bv->lockInset(this)) {
+ lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
+ return DISPATCHED;
+ }
+
+ locked = true;
+ the_locking_inset = 0;
+ inset_pos = inset_x = inset_y = 0;
+ inset_boundary = false;
+ inset_par = 0;
+ old_par = 0;
+
+ bool clear = false;
+ if (!lt) {
+ lt = getLyXText(bv);
+ clear = true;
+ }
+
+ if (cmd.argument.size()) {
+ if (cmd.argument == "left")
+ lt->setCursor(paragraphs.begin(), 0);
+ else {
+ ParagraphList::iterator it = paragraphs.begin();
+ ParagraphList::iterator end = paragraphs.end();
+ while (boost::next(it) != end)
+ ++it;
+ // int const pos = (p->size() ? p->size()-1 : p->size());
+ lt->setCursor(it, it->size());
+ }
+ } else {
+ int tmp_y = (cmd.y < 0) ? 0 : cmd.y;
+ // we put here -1 and not button as now the button in the
+ // edit call should not be needed we will fix this in 1.3.x
+ // cycle hopefully (Jug 20020509)
+ // FIXME: GUII I've changed this to none: probably WRONG
+ if (!checkAndActivateInset(bv, cmd.x, tmp_y, mouse_button::none)) {
+ lt->setCursorFromCoordinates(cmd.x - drawTextXOffset,
+ cmd.y + insetAscent);
+ lt->cursor.x_fix(lt->cursor.x());
+ }
+ }
+
+ lt->clearSelection();
+ finishUndo();
+
+ // If the inset is empty set the language of the current font to the
+ // language to the surronding text (if different).
+ if (paragraphs.begin()->empty() &&
+ boost::next(paragraphs.begin()) == paragraphs.end()&&
+ bv->getParentLanguage(this) != lt->current_font.language())
+ {
+ LyXFont font(LyXFont::ALL_IGNORE);
+ font.setLanguage(bv->getParentLanguage(this));
+ setFont(bv, font, false);
+ }
+
+ if (clear)
+ lt = 0;
+ int code = CURSOR;
+ if (drawFrame_ == LOCKED)
+ code = CURSOR | DRAW_FRAME;
+
+ updateLocal(bv, code, false);
+ // Tell the paragraph dialog that we've entered an insettext.
+ bv->dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
+ return DISPATCHED;
+ }
+
+
+ switch (cmd.action) {
case LFUN_MOUSE_PRESS:
- lfunMousePress(ev);
+ lfunMousePress(cmd);
return DISPATCHED;
case LFUN_MOUSE_MOTION:
- lfunMouseMotion(ev);
+ lfunMouseMotion(cmd);
return DISPATCHED;
case LFUN_MOUSE_RELEASE:
- return lfunMouseRelease(ev) ? DISPATCHED : UNDISPATCHED;
+ return lfunMouseRelease(cmd) ? DISPATCHED : UNDISPATCHED;
default:
break;
}
bool was_empty = (paragraphs.begin()->empty() &&
boost::next(paragraphs.begin()) == paragraphs.end());
no_selection = false;
- RESULT result = UpdatableInset::localDispatch(ev);
+ RESULT result = UpdatableInset::localDispatch(cmd);
if (result != UNDISPATCHED)
return DISPATCHED;
result = DISPATCHED;
- if (ev.action < 0 && ev.argument.empty())
+ if (cmd.action < 0 && cmd.argument.empty())
return FINISHED;
if (the_locking_inset) {
- result = the_locking_inset->localDispatch(ev);
+ result = the_locking_inset->localDispatch(cmd);
if (result == DISPATCHED_NOUPDATE)
return result;
else if (result == DISPATCHED) {
if (lt->selection.set())
cursor_update = SELECTION;
- switch (ev.action) {
+ switch (cmd.action) {
// Normal chars
case LFUN_SELFINSERT:
// setErrorMessage(N_("Document is read only"));
break;
}
- if (!ev.argument.empty()) {
+ if (!cmd.argument.empty()) {
/* Automatically delete the currently selected
* text and replace it with what is being
* typed in now. Depends on lyxrc settings
}
}
lt->clearSelection();
- for (string::size_type i = 0; i < ev.argument.length(); ++i) {
+ for (string::size_type i = 0; i < cmd.argument.length(); ++i) {
bv->owner()->getIntl().getTransManager().
- TranslateAndInsert(ev.argument[i], lt);
+ TranslateAndInsert(cmd.argument[i], lt);
}
}
lt->selection.cursor = lt->cursor;
if (clip.empty())
break;
- if (ev.argument == "paragraph") {
+ if (cmd.argument == "paragraph") {
lt->insertStringAsParagraphs(clip);
} else {
lt->insertStringAsLines(clip);
// and current buffer's textclass (number). */
LyXTextClass const & tclass =
bv->buffer()->params.getLyXTextClass();
- string layout = ev.argument;
+ string layout = cmd.argument;
bool hasLayout = tclass.hasLayout(layout);
// If the entry is obsolete, use the new one instead.
// see if we found the layout number:
if (!hasLayout) {
- FuncRequest lf(LFUN_MESSAGE, N_("Layout ") + ev.argument + N_(" not known"));
+ FuncRequest lf(LFUN_MESSAGE, N_("Layout ") + cmd.argument + N_(" not known"));
bv->owner()->dispatch(lf);
break;
}
cur_value = pit->params().spacing().getValue();
}
- istringstream istr(STRCONV(ev.argument));
+ istringstream istr(STRCONV(cmd.argument));
string tmp;
istr >> tmp;
Spacing::Space new_spacing = cur_spacing;
new_spacing = Spacing::Default;
} else {
lyxerr << _("Unknown spacing argument: ")
- << ev.argument << endl;
+ << cmd.argument << endl;
}
if (cur_spacing != new_spacing || cur_value != new_value) {
pit->params().spacing(Spacing(new_spacing, new_value));
case LFUN_ENDBUF:
case LFUN_BEGINNINGBUF:
updwhat = cursor_update;
- if (!bv->dispatch(ev))
+ if (!bv->dispatch(cmd))
result = UNDISPATCHED;
break;
// fallthrough
default:
- if (!bv->dispatch(ev))
+ if (!bv->dispatch(cmd))
result = UNDISPATCHED;
break;
}
static_cast<UpdatableInset*>(cpar(bv)->getInset(cpos(bv)));
if (!isHighlyEditableInset(inset))
return false;
- inset->edit(bv, front);
+ FuncRequest cmd(bv, LFUN_INSET_EDIT, front ? "left" : "right");
+ inset->localDispatch(cmd);
if (!the_locking_inset)
return false;
updateLocal(bv, CURSOR, false);
y = insetDescent;
inset_x = cix(bv) - top_x + drawTextXOffset;
inset_y = ciy(bv) + drawTextYOffset;
- inset->edit(bv, x - inset_x, y - inset_y, button);
+ FuncRequest cmd(bv, LFUN_INSET_EDIT, x - inset_x, y - inset_y, button);
+ inset->localDispatch(cmd);
if (!the_locking_inset)
return false;
updateLocal(bv, CURSOR, false);
#ifndef INSETTEXT_H
#define INSETTEXT_H
-
#include "updatableinset.h"
#include "LString.h"
#include "LColor.h"
#include "ParagraphList.h"
#include "RowList.h"
+#include "frontends/mouse_state.h"
#include "support/types.h"
///
string const editMessage() const;
///
- void edit(BufferView *, int, int, mouse_button::state);
- ///
- void edit(BufferView *, bool front = true);
- ///
bool isTextInset() const { return true; }
///
void insetUnlock(BufferView *);
#include "gettext.h"
#include "insettoc.h"
+#include "funcrequest.h"
#include "BufferView.h"
#include "frontends/LyXView.h"
#include "frontends/Dialogs.h"
}
-void InsetTOC::edit(BufferView * bv, int, int, mouse_button::state)
+dispatch_result InsetTOC::localDispatch(FuncRequest const & cmd)
{
- InsetCommandMailer mailer("toc", *this);
- mailer.showDialog(bv);
-}
-
-
-void InsetTOC::edit(BufferView * bv, bool)
-{
- edit(bv, 0, 0, mouse_button::none);
+ switch (cmd.action) {
+ case LFUN_INSET_EDIT:
+ InsetCommandMailer("toc", *this).showDialog(cmd.view());
+ return DISPATCHED;
+ default:
+ return UNDISPATCHED;
+ }
}
return new InsetTOC(params(), same_id);
}
///
- string const getScreenLabel(Buffer const *) const;
- ///
- void edit(BufferView * bv, int, int, mouse_button::state);
+ dispatch_result localDispatch(FuncRequest const & cmd);
///
- void edit(BufferView * bv, bool front = true);
+ string const getScreenLabel(Buffer const *) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///
*
* Full author contact details are available in file CREDITS
*/
-#include <config.h>
+#include <config.h>
#include "inseturl.h"
+#include "funcrequest.h"
#include "BufferView.h"
#include "LaTeXFeatures.h"
#include "frontends/LyXView.h"
InsetUrl::~InsetUrl()
{
- InsetCommandMailer mailer("url", *this);
- mailer.hideDialog();
+ InsetCommandMailer("url", *this).hideDialog();
}
-void InsetUrl::edit(BufferView * bv, int, int, mouse_button::state)
+dispatch_result InsetUrl::localDispatch(FuncRequest const & cmd)
{
- InsetCommandMailer mailer("url", *this);
- mailer.showDialog(bv);
-}
-
-
-void InsetUrl::edit(BufferView * bv, bool)
-{
- edit(bv, 0, 0, mouse_button::none);
+ switch (cmd.action) {
+ case LFUN_INSET_EDIT:
+ InsetCommandMailer("url", *this).showDialog(cmd.view());
+ return DISPATCHED;
+ default:
+ return InsetCommand::localDispatch(cmd);
+ }
}
return new InsetUrl(params(), same_id);
}
///
+ dispatch_result localDispatch(FuncRequest const & cmd);
+ ///
Inset::Code lyxCode() const { return Inset::URL_CODE; }
///
void validate(LaTeXFeatures &) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///
- void edit(BufferView *, int, int, mouse_button::state);
- ///
- void edit(BufferView * bv, bool front = true);
- ///
bool display() const { return false; }
///
int latex(Buffer const *, std::ostream &,
{}
-void UpdatableInset::edit(BufferView *, int, int, mouse_button::state)
-{}
-
-
-void UpdatableInset::edit(BufferView *, bool)
-{}
-
-
void UpdatableInset::draw(BufferView *, LyXFont const &,
int /* baseline */, float & x) const
{
///
virtual void insetUnlock(BufferView *);
///
- virtual void edit(BufferView *, int x, int y, mouse_button::state button);
- ///
- virtual void edit(BufferView *, bool front = true);
- ///
virtual void draw(BufferView *, LyXFont const &,
int baseline, float & x) const;
///
LFUN_MOUSE_RELEASE, // André 9 Aug 2002
LFUN_MOUSE_DOUBLE, // André 9 Aug 2002
LFUN_MOUSE_TRIPLE, // André 9 Aug 2002
- LFUN_EDIT, // André 16 Aug 2002
+ LFUN_INSET_EDIT, // André 16 Aug 2002
LFUN_INSET_WRAP, // Dekel 7 Apr 2002
// 240
LFUN_TRACK_CHANGES, // Levon 20021001 (cool date !)
if (view()->theLockingInset())
view()->unlockInset(view()->theLockingInset());
if (par->inInset()) {
- par->inInset()->edit(view());
+ FuncRequest cmd(view(), LFUN_INSET_EDIT, "left");
+ par->inInset()->localDispatch(cmd);
}
// Set the cursor
view()->getLyXText()->setCursor(par, 0);
*/
#include <config.h>
-#include <fstream>
#include "Lsstream.h"
#include "support/LAssert.h"
-
-
#include "formula.h"
#include "formulamacro.h"
#include "lyxrc.h"
#include "intl.h"
#include "ref_inset.h"
+#include <fstream>
+
using std::endl;
using std::ostream;
using std::vector;
using std::abs;
using std::max;
-MathCursor * mathcursor = 0;
+MathCursor * mathcursor = 0;
namespace {
int first_x;
int first_y;
-
-
bool openNewInset(BufferView * bv, UpdatableInset * new_inset)
{
if (!bv->insertInset(new_inset)) {
delete new_inset;
return false;
}
- new_inset->edit(bv, true);
+ new_inset->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT, "left"));
return true;
}
}
-void InsetFormulaBase::edit(BufferView * bv, int x, int y, mouse_button::state)
-{
- if (!bv->lockInset(this))
- lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl;
- releaseMathCursor(bv);
- mathcursor = new MathCursor(this, true);
- metrics(bv);
- mathcursor->setPos(x + xo_, y + yo_);
- // if that is removed, we won't get the magenta box when entering an
- // inset for the first time
- bv->updateInset(this);
-}
-
-
-void InsetFormulaBase::edit(BufferView * bv, bool front)
-{
- if (!bv->lockInset(this))
- lyxerr << "Cannot lock math inset in edit call!\n";
- releaseMathCursor(bv);
- mathcursor = new MathCursor(this, front);
- metrics(bv);
- bv->updateInset(this);
-}
-
-
void InsetFormulaBase::insetUnlock(BufferView * bv)
{
if (mathcursor) {
// << " y: '" << cmd.y
// << "' button: " << cmd.button() << endl;
+ BufferView * bv = cmd.view();
+
// delete empty mathbox (LFUN_BACKSPACE and LFUN_DELETE)
bool remove_inset = false;
switch (cmd.action) {
+ case LFUN_INSET_EDIT:
+ if (!bv->lockInset(this))
+ lyxerr << "Cannot lock math inset in edit call!\n";
+ releaseMathCursor(bv);
+ if (!cmd.argument.empty()) {
+ mathcursor = new MathCursor(this, cmd.argument == "left");
+ metrics(bv);
+ } else {
+ mathcursor = new MathCursor(this, true);
+ metrics(bv);
+ mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
+ }
+ // if that is removed, we won't get the magenta box when entering an
+ // inset for the first time
+ bv->updateInset(this);
+ return DISPATCHED;
+
case LFUN_MOUSE_PRESS:
//lyxerr << "Mouse single press\n";
return lfunMousePress(cmd);
if (!mathcursor)
return UNDISPATCHED;
- BufferView * bv = cmd.view();
string argument = cmd.argument;
RESULT result = DISPATCHED;
bool sel = false;
/// what appears in the minibuffer when opening
virtual string const editMessage() const;
///
- virtual void edit(BufferView *, int x, int y, mouse_button::state button);
- ///
- virtual void edit(BufferView *, bool front = true);
- ///
virtual void fitInsetCursor(BufferView *) const;
/// FIXME
virtual void getCursorPos(BufferView *, int &, int &) const;
/// identifies things that can get \limits or \nolimits
virtual bool takesLimits() const { return false; }
- ///
- virtual void edit(BufferView *, int, int, mouse_button::state) {}
-
/// request "external features"
virtual void validate(LaTeXFeatures &) const {}
/// char char code if possible
if (cursor.pos() < cursor.par()->size() &&
cursor.par()->isInset(cursor.pos())) {
// lock the inset!
- cursor.par()->getInset(cursor.pos())->edit(bv());
+ FuncRequest cmd(bv(), LFUN_INSET_EDIT, "left");
+ cursor.par()->getInset(cursor.pos())->localDispatch(cmd);
// now call us again to do the above trick
// but obviously we have to start from down below ;)
return bv()->text->selectNextWordToSpellcheck(value);
string const oldLabel = pit->params().labelString();
- int maxdepth = 0;
+ size_t maxdepth = 0;
if (pit != ownerParagraphs().begin())
maxdepth = boost::prior(pit)->getMaxDepthAfter();
y -= topy;
Inset * inset_hit = checkInsetHit(x, y1);
if (inset_hit && isHighlyEditableInset(inset_hit)) {
- inset_hit->edit(bv(), x, y - (y2 - y1), mouse_button::none);
+ inset_hit->localDispatch(
+ FuncRequest(bv(), LFUN_INSET_EDIT, x, y - (y2 - y1), mouse_button::none));
}
}
#else
y -= topy;
Inset * inset_hit = checkInsetHit(x, y1);
if (inset_hit && isHighlyEditableInset(inset_hit)) {
- inset_hit->edit(bv(), x, y - (y2 - y1), mouse_button::none);
+ FuncRequest cmd(bv(), LFUN_INSET_EDIT, x, y - (y2 - y1), mouse_button::none);
+ inset_hit->localDispatch(cmd);
}
}
#else
gotsel = true;
}
if (bv->insertInset(inset)) {
- if (edit)
- inset->edit(bv);
+ if (edit) {
+ FuncRequest cmd(bv, LFUN_INSET_EDIT, "left");
+ inset->localDispatch(cmd);
+ }
if (gotsel && pastesel)
bv->owner()->dispatch(FuncRequest(LFUN_PASTESELECTION));
}
&& isHighlyEditableInset(cursor.par()->getInset(cursor.pos()))) {
Inset * tmpinset = cursor.par()->getInset(cursor.pos());
cmd.message(tmpinset->editMessage());
- tmpinset->edit(bv, !is_rtl);
+ FuncRequest cmd1(bv, LFUN_INSET_EDIT, is_rtl ? "left" : "right");
+ tmpinset->localDispatch(cmd1);
break;
}
if (!is_rtl)
isHighlyEditableInset(cursor.par()->getInset(cursor.pos()))) {
Inset * tmpinset = cursor.par()->getInset(cursor.pos());
cmd.message(tmpinset->editMessage());
- tmpinset->edit(bv, is_rtl);
+ FuncRequest cmd1(bv, LFUN_INSET_EDIT, is_rtl ? "right" : "left");
+ tmpinset->localDispatch(cmd1);
break;
}
if (is_rtl)
#include "undo_funcs.h"
#include "lyxtext.h"
+#include "funcrequest.h"
#include "BufferView.h"
#include "buffer.h"
#include "insets/updatableinset.h"
it = static_cast<UpdatableInset*>(tmppar->inInset());
LyXText * t;
if (it) {
- it->edit(bv);
+ FuncRequest cmd(bv, LFUN_INSET_EDIT, "left");
+ it->localDispatch(cmd);
t = it->getLyXText(bv);
} else {
t = bv->text;
LyXText * t;
Inset * it = tmppar->inInset();
if (it) {
- it->edit(bv);
+ FuncRequest cmd(bv, LFUN_INSET_EDIT, "left");
+ it->localDispatch(cmd);
t = it->getLyXText(bv);
} else {
t = bv->text;