+2001-07-19 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
+
+ * bind/xemacs.bind:
+ * bind/sciword.bind:
+ * bind/emacs.bind:
+ * bind/cua.bind:
+ * ui/default.ui: use inset-toggle instead of open-stuff
+
2001-07-12 Kayvan A. Sylvan <kayvan@camel.internal.sylvan.com>
* layouts/literate-scrap.inc: Added PassThru tag
\bind "C-f" "find-replace"
\bind "C-g" "error-next"
-\bind "C-i" "open-stuff" # 'i' for Inset
+\bind "C-i" "inset-toggle" # 'i' for Inset
\bind "C-c" "copy"
\bind "C-x" "cut"
\bind "C-l" "screen-recenter"
\bind "C-m" "mark-toggle"
\bind "C-n" "down"
-\bind "C-o" "open-stuff"
+\bind "C-o" "inset-toggle"
\bind "C-p" "up"
# this is "quoted-insert" a total different meaning from "quote-insert"
# Numbering equations. Should perhaps simplify math-number and math-nonumber into one command since they are used in very different contexts. This and also math-macro stuff should be available in the Lyx menus!
\bind "C-n" "math-number"
\bind "S-C-n" "math-nonumber"
-\bind "C-o" "open-stuff"
+\bind "C-o" "inset-toggle"
# Insert a quote character. Do I need this?
\bind "C-q" "quote-insert"
\bind "C-l" "screen-recenter"
\bind "C-m" "mark-toggle"
\bind "C-n" "down"
-\bind "C-o" "open-stuff"
+\bind "C-o" "inset-toggle"
\bind "C-p" "up"
# this is "quoted-insert" a total different meaning from "quote-insert"
End
Menu "edit_floats"
- Item "Open/Close|O" "open-stuff"
+ Item "Open/Close|O" "inset-toggle"
# Item "Melt|M" "melt"
# Item "Open All Figures/Tables|F" "floats-operate openfig"
# Item "Close All Figures/Tables|T" "floats-operate closefig"
}
break;
- case LFUN_OPENSTUFF:
+ case LFUN_INSET_TOGGLE:
{
LyXText * lt = bv_->getLyXText();
hideCursor();
beforeChange(lt);
update(lt, BufferView::SELECT|BufferView::FITCUR);
- lt->openStuff(bv_);
+ lt->toggleInset(bv_);
update(lt, BufferView::SELECT|BufferView::FITCUR);
setState();
}
// if we are in a locking inset we should try to insert the
// inset there otherwise this is a illegal function now
if (bv_->theLockingInset()) {
- if (bv_->theLockingInset()->insertInsetAllowed(inset))
+ if (bv_->theLockingInset()->insetAllowed(inset))
return bv_->theLockingInset()->insertInset(bv_, inset);
return false;
}
+2001-07-19 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
+
+ * lyxfunc.C (getStatus): add support for all the inset insertion
+ commands.
+
+ * text2.C (insertInset):
+ * paragraph.C (insetAllowed):
+ * BufferView_pimpl.C (insertInset): update to take in account the
+ renaming of insertInsetAllowed
+
+ * lyxfunc.C (getStatus): add support for LFUN_INSET_TOGGLE.
+
+ * text2.C (getInset): new method. returns inset at cursor position.
+
+ * BufferView_pimpl.C (Dispatch): changes because of this.
+
+ * LyXAction.C (init): rename open-stuff to inset-toggle.
+
+ * commandtags.h: rename LFUN_OPENSTUFF to LFUN_INSET_TOGGLE.
+
+ * text2.C (toggleInset): renamed from openStuff; use
+ Inset::open().
+
2001-07-13 Yves Bastide <stid@libd-pc11.univ-bpclermont.fr>
* lyxrc.C (set_font_norm_type): recognise ISO_8859_15.
{ LFUN_INSET_MINIPAGE, "minipage-insert", "", Noop },
{ LFUN_INSERT_NOTE, "note-insert", "", Noop },
{ LFUN_GOTONOTE, "note-next", "", ReadOnly },
- { LFUN_OPENSTUFF, "open-stuff", "", ReadOnly },
+ { LFUN_INSET_TOGGLE, "inset-toggle",
+ N_("toggle inset"), ReadOnly },
{ LFUN_DOWN_PARAGRAPH, "paragraph-down",
N_("Go one paragraph down"), ReadOnly },
{ LFUN_DOWN_PARAGRAPHSEL, "paragraph-down-select",
LFUN_COPY,
LFUN_GOTOERROR,
LFUN_GOTONOTE,
- LFUN_OPENSTUFF,
+ LFUN_INSET_TOGGLE,
LFUN_HYPHENATION,
LFUN_HFILL,
LFUN_DEPTH,
LFUN_VC_UNDO, // Lgb 97-07-01
LFUN_VC_HISTORY, // Lgb 97-07-01
LFUN_EXPORT, // Lgb 97-07-29
+#if 0
LFUN_INSERTFOOTNOTE, // Bernhard 97-08-07
+// schedule for deletion
+#endif
LFUN_REF_GOTO, // 200 // Ale 970806
//LFUN_REF_BACK, // Ale 970806
LFUN_PARENTINSERT, // Ale 970813
+2001-07-18 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
+
+ * many files: update to match the change below
+
+ * inset.h (insetAllowed): renamed from insertInsetAllowed;
+ implement the version which takes an inset here.
+
+ * insetcollapsable.[Ch]: implement open and isOpen
+
+ * inset.h: remove insertInsetAllowed from Inset
+ (open): new method, to open or close an inset
+ (isOpen): returns the status of an inset
+ (isCollapsable, colapse): removed
+
2001-07-13 Yves Bastide <stid@libd-pc11.univ-bpclermont.fr>
* insetquotes.C (dispString): display french guillemets when using
virtual bool doClearArea() const { return true; }
///
virtual bool autoDelete() const;
+ /// returns true the inset can hold an inset of given type
+ virtual bool insetAllowed(Inset::Code) const { return false; }
+ /// wrapper around the above
+ bool insetAllowed(Inset * in) const {
+ return insetAllowed(in->lyxCode());
+ }
///
virtual void write(Buffer const *, std::ostream &) const = 0;
///
///
virtual bool needFullRow() const { return false; }
///
- virtual bool insertInsetAllowed(Inset *) const { return false; }
- ///
void setInsetName(string const & s) { name = s; }
///
string const getInsetName() const { return name; }
int id() const;
void id(int id_arg);
+ /// used to toggle insets
+ // is the inset open?
+ virtual bool isOpen() const { return false; }
+ // open or close the inset, depending on the bool
+ virtual void open(BufferView *, bool) {}
protected:
///
mutable int top_x;
///
virtual bool insertInset(BufferView *, Inset *) { return false; }
///
- virtual bool insertInsetAllowed(Inset *) const { return false; }
- virtual bool insertInsetAllowed(Inset::Code) const { return false; }
- ///
virtual UpdatableInset * getLockingInset() const {
return const_cast<UpdatableInset *>(this);
}
return block_drawing_;
}
///
- virtual bool isCollapsable() const { return false; }
- ///
- virtual bool collapsed() const { return false; }
- virtual void collapsed(BufferView *, bool) {}
- ///
// needed for spellchecking text
///
virtual string selectNextWord(BufferView *, float & value) const;
bool InsetCollapsable::insertInset(BufferView * bv, Inset * in)
{
- if (!insertInsetAllowed(in)) {
+ if (!insetAllowed(in->lyxCode())) {
lyxerr << "InsetCollapsable::InsertInset: "
"Unable to insert inset." << endl;
return false;
return inset.getInsetFromID(id_arg);
}
-void InsetCollapsable::collapsed(BufferView * bv, bool flag)
+void InsetCollapsable::open(BufferView * bv, bool flag)
{
- if (flag == collapsed_)
+ if (flag == !collapsed_)
return;
- collapsed_ = flag;
+ collapsed_ = !flag;
bv->updateInset(this, false);
}
///
bool insertInset(BufferView *, Inset * inset);
///
- bool insertInsetAllowed(Inset * in) const {
- return inset.insertInsetAllowed(in);
- }
- bool insertInsetAllowed(Inset::Code code) const {
- return inset.insertInsetAllowed(code);
+ bool insetAllowed(Inset::Code code) const {
+ return inset.insetAllowed(code);
}
///
bool isTextInset() const { return true; }
///
LyXCursor const & cursor(BufferView *) const;
///
- bool isCollapsable() const { return true; }
- bool collapsed() const { return collapsed_; }
- void collapsed(BufferView *, bool);
+ bool isOpen() const { return !collapsed_; }
+ void open(BufferView *, bool);
///
string selectNextWord(BufferView * bv, float & value) const {
return inset.selectNextWord(bv, value);
///
virtual bool insertInset(BufferView *, Inset *);
///
- virtual bool insertInsetAllowed(Inset *) const { return false; }
+ virtual bool insetAllowed(Inset::Code) const { return false; }
///
virtual void setFont(BufferView *, LyXFont const &,
bool toggleall = false, bool selectall = false);
}
-bool InsetFloat::insertInsetAllowed(Inset * in) const
-{
- return insertInsetAllowed(in->lyxCode());
-}
-
-
-bool InsetFloat::insertInsetAllowed(Inset::Code code) const
+bool InsetFloat::insetAllowed(Inset::Code code) const
{
if (code == Inset::FLOAT_CODE)
return false;
if (inset.getLockingInset() != const_cast<InsetFloat *>(this))
- return inset.insertInsetAllowed(code);
+ return inset.insetAllowed(code);
if ((code == Inset::FOOT_CODE) || (code == Inset::MARGIN_CODE))
return false;
return true;
///
string const editMessage() const;
///
- bool insertInsetAllowed(Inset * inset) const;
- bool insertInsetAllowed(Inset::Code) const;
+ bool insetAllowed(Inset::Code) const;
///
void insetButtonRelease(BufferView * bv, int x, int y, int button);
///
}
-bool InsetFootlike::insertInsetAllowed(Inset * in) const
-{
- return insertInsetAllowed(in->lyxCode());
-}
-
-bool InsetFootlike::insertInsetAllowed(Inset::Code code) const
+bool InsetFootlike::insetAllowed(Inset::Code code) const
{
if ((code == Inset::FOOT_CODE) || (code == Inset::MARGIN_CODE))
return false;
- return InsetCollapsable::insertInsetAllowed(code);
+ return InsetCollapsable::insetAllowed(code);
}
///
void write(Buffer const * buf, std::ostream & os) const;
///
- bool insertInsetAllowed(Inset * inset) const;
- bool insertInsetAllowed(Inset::Code) const;
+ bool insetAllowed(Inset::Code) const;
};
#endif
}
-bool InsetMinipage::insertInsetAllowed(Inset * in) const
-{
- return insertInsetAllowed(in->lyxCode());
-}
-
-bool InsetMinipage::insertInsetAllowed(Inset::Code code) const
+bool InsetMinipage::insetAllowed(Inset::Code code) const
{
if ((code == Inset::FLOAT_CODE) || (code == Inset::MARGIN_CODE))
return false;
- return InsetCollapsable::insertInsetAllowed(code);
+ return InsetCollapsable::insetAllowed(code);
}
///
string const editMessage() const;
///
- bool insertInsetAllowed(Inset * inset) const;
- bool insertInsetAllowed(Inset::Code) const;
+ bool insetAllowed(Inset::Code) const;
///
Position pos() const;
///
///
bool insertInset(BufferView *, Inset *);
///
- bool insertInsetAllowed(Inset *) const {
+ bool insetAllowed(Inset::Code) const {
return the_locking_inset != 0;
}
///
bool InsetText::insertInset(BufferView * bv, Inset * inset)
{
if (the_locking_inset) {
- if (the_locking_inset->insertInsetAllowed(inset))
+ if (the_locking_inset->insetAllowed(inset))
return the_locking_inset->insertInset(bv, inset);
return false;
}
}
-bool InsetText::insertInsetAllowed(Inset * in) const
+bool InsetText::insetAllowed(Inset::Code code) const
{
if (the_locking_inset)
- return the_locking_inset->insertInsetAllowed(in);
- return true;
-}
-
-bool InsetText::insertInsetAllowed(Inset::Code code) const
-{
- if (the_locking_inset)
- return the_locking_inset->insertInsetAllowed(code);
+ return the_locking_inset->insetAllowed(code);
return true;
}
///
bool insertInset(BufferView *, Inset *);
///
- bool insertInsetAllowed(Inset *) const;
- bool insertInsetAllowed(Inset::Code) const;
+ bool insetAllowed(Inset::Code) const;
///
UpdatableInset * getLockingInset() const;
///
disable = !Exporter::IsExportable(buf, "program");
break;
- case LFUN_INSERTFOOTNOTE:
- // Disable insertion of floats in a tabular.
- disable = false;
- if (owner->view()->theLockingInset()) {
- disable = (owner->view()->theLockingInset()->lyxCode() == Inset::TABULAR_CODE) ||
- owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE);
- }
- break;
-
case LFUN_LAYOUT_TABULAR:
disable = true;
if (owner->view()->theLockingInset()) {
case LFUN_BOOKMARK_GOTO:
disable = !owner->view()->
isSavedPosition(strToUnsignedInt(argument));
+ break;
+
+
+ case LFUN_INSET_TOGGLE:
+ disable = (TEXT(false)->getInset() == 0);
+ break;
case LFUN_MATH_VALIGN: {
// I think this test can be simplified (Andre')
default:
break;
- }
- if (disable)
- flag |= func_status::Disabled;
-
- if (buf) {
- func_status::value_type box = func_status::ToggleOff;
- LyXFont const & font =
- TEXT(false)->real_current_font;
- switch (action) {
- case LFUN_EMPH:
- if (font.emph() == LyXFont::ON)
- box = func_status::ToggleOn;
- break;
- case LFUN_NOUN:
- if (font.noun() == LyXFont::ON)
- box = func_status::ToggleOn;
- break;
- case LFUN_BOLD:
- if (font.series() == LyXFont::BOLD_SERIES)
- box = func_status::ToggleOn;
- break;
+ }
+
+ // the functions which insert insets
+ Inset::Code code = Inset::NO_CODE;
+ switch (action) {
+ case LFUN_INSET_TEXT:
+ code = Inset::TEXT_CODE;
+ break;
+ case LFUN_INSET_ERT:
+ code = Inset::ERT_CODE;
+ break;
+ case LFUN_INSET_GRAPHICS:
+ code = Inset::GRAPHICS_CODE;
+ break;
+ case LFUN_INSET_FOOTNOTE:
+ code = Inset::FOOT_CODE;
+ break;
+ case LFUN_INSET_TABULAR:
+ code = Inset::TABULAR_CODE;
+ break;
+ case LFUN_INSET_EXTERNAL:
+ code = Inset::EXTERNAL_CODE;
+ break;
+ case LFUN_INSET_MARGINAL:
+ code = Inset::MARGIN_CODE;
+ break;
+ case LFUN_INSET_MINIPAGE:
+ code = Inset::MINIPAGE_CODE;
+ break;
+ case LFUN_INSET_FLOAT:
+ case LFUN_INSET_WIDE_FLOAT:
+ code = Inset::FLOAT_CODE;
+ break;
+#if 0
+ case LFUN_INSET_LIST:
+ code = Inset::LIST_CODE;
+ break;
+#endif
+ case LFUN_INSET_THEOREM:
+ code = Inset::THEOREM_CODE;
+ break;
+ case LFUN_INSET_CAPTION:
+ code = Inset::CAPTION_CODE;
+ break;
+ case LFUN_INSERT_NOTE:
+ code = Inset::IGNORE_CODE;
+ break;
+ case LFUN_INSERT_LABEL:
+ code = Inset::LABEL_CODE;
+ break;
+ case LFUN_REF_INSERT:
+ code = Inset::REF_CODE;
+ break;
+ case LFUN_CITATION_INSERT:
+ code = Inset::CITE_CODE;
+ break;
+ case LFUN_INSERT_BIBTEX:
+ code = Inset::BIBTEX_CODE;
+ break;
+ case LFUN_INDEX_INSERT:
+ case LFUN_INDEX_INSERT_LAST:
+ code = Inset::INDEX_CODE;
+ break;
+#if 0
+ case LFUN_CHILD_INSERT:
+ code = Inset::CHILD_CODE;
+ break;
+#endif
+ case LFUN_TOC_INSERT:
+ code = Inset::TOC_CODE;
+ break;
+ case LFUN_PARENTINSERT:
+ code = Inset::PARENT_CODE;
+ break;
+ case LFUN_INSERT_URL:
+ code = Inset::URL_CODE;
+ break;
+ default:
+ break;
+ }
+ if (code != Inset::NO_CODE
+ && owner->view()->theLockingInset()
+ && !owner->view()->theLockingInset()->insetAllowed(code)) {
+ disable = true;
+ }
+
+ if (disable)
+ flag |= func_status::Disabled;
+
+ // the font related functions
+ func_status::value_type box = func_status::ToggleOff;
+ LyXFont const & font =
+ TEXT(false)->real_current_font;
+ switch (action) {
+ case LFUN_EMPH:
+ if (font.emph() == LyXFont::ON)
+ box = func_status::ToggleOn;
+ break;
+ case LFUN_NOUN:
+ if (font.noun() == LyXFont::ON)
+ box = func_status::ToggleOn;
+ break;
+ case LFUN_BOLD:
+ if (font.series() == LyXFont::BOLD_SERIES)
+ box = func_status::ToggleOn;
+ break;
#ifndef NO_LATEX
- case LFUN_TEX:
- if (font.latex() == LyXFont::ON)
- box = func_status::ToggleOn;
- break;
+ case LFUN_TEX:
+ if (font.latex() == LyXFont::ON)
+ box = func_status::ToggleOn;
+ break;
#endif
- case LFUN_READ_ONLY_TOGGLE:
- if (buf->isReadonly())
- box = func_status::ToggleOn;
- break;
- default:
- box = func_status::OK;
- break;
- }
- flag |= box;
+ case LFUN_READ_ONLY_TOGGLE:
+ if (buf->isReadonly())
+ box = func_status::ToggleOn;
+ break;
+ default:
+ box = func_status::OK;
+ break;
}
+ flag |= box;
return flag;
}
void getWord(LyXCursor & from, LyXCursor & to, word_location) const;
/// just selects the word the cursor is in
void selectWord(BufferView *);
+ /// returns the inset at cursor (if it exists), 0 otherwise
+ Inset * getInset() const;
/** 'selects" the next word, where the cursor is not in
and returns this word as string. THe cursor will be moved
Row * row_ptr, int y, bool cleared=false);
///
- void openStuff(BufferView *);
+ void toggleInset(BufferView *);
///
void cutSelection(BufferView *, bool = true);
///
bool Paragraph::insertFromMinibuffer(Paragraph::size_type pos)
{
if ((minibuffer_char == Paragraph::META_INSET) &&
- !insertInsetAllowed(minibuffer_inset))
+ !insetAllowed(minibuffer_inset->lyxCode()))
return false;
if (minibuffer_char == Paragraph::META_INSET)
insertInset(pos, minibuffer_inset, minibuffer_font);
}
-bool Paragraph::insertInsetAllowed(Inset * inset)
+bool Paragraph::insetAllowed(Inset::Code code)
{
//lyxerr << "Paragraph::InsertInsetAllowed" << endl;
if (pimpl_->inset_owner)
- return pimpl_->inset_owner->insertInsetAllowed(inset);
+ return pimpl_->inset_owner->insetAllowed(code);
return true;
}
///
void insertInset(size_type pos, Inset * inset, LyXFont const &);
///
- bool insertInsetAllowed(Inset * inset);
+ bool insetAllowed(Inset::Code code);
///
Inset * getInset(size_type pos);
///
}
}
-void LyXText::openStuff(BufferView * bview)
+Inset * LyXText::getInset() const
{
+ Inset * inset = 0;
if (cursor.pos() == 0 && cursor.par()->bibkey){
- cursor.par()->bibkey->edit(bview, 0, 0, 0);
+ inset = cursor.par()->bibkey;
} else if (cursor.pos() < cursor.par()->size()
&& cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET) {
- Inset * inset = cursor.par()->getInset(cursor.pos());
- if (!inset->editable())
- return;
- bview->owner()->message(inset->editMessage());
- if (inset->editable() != Inset::HIGHLY_EDITABLE)
- setCursorParUndo(bview);
- inset->edit(bview, 0, 0, 0);
+ inset = cursor.par()->getInset(cursor.pos());
}
+ return inset;
+}
+
+void LyXText::toggleInset(BufferView * bview)
+{
+ Inset * inset = getInset();
+ if (!inset->editable())
+ return;
+ //bview->owner()->message(inset->editMessage());
+
+ // do we want to keep this?? (JMarc)
+ if (inset->editable() != Inset::HIGHLY_EDITABLE)
+ setCursorParUndo(bview);
+ inset->open(bview, !inset->isOpen());
}
void LyXText::insertInset(BufferView * bview, Inset * inset)
{
- if (!cursor.par()->insertInsetAllowed(inset))
+ if (!cursor.par()->insetAllowed(inset->lyxCode()))
return;
setUndo(bview, Undo::INSERT,
cursor.par(), cursor.par()->next());