All changes I made to have text-insets working. Look at the Changelog

for more details.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@571 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2000-02-25 12:06:15 +00:00
parent b92c965543
commit d6fa7c567c
48 changed files with 2382 additions and 179 deletions

View File

@ -1,3 +1,26 @@
2000-02-24 Juergen Vigna <jug@sad.it>
* src/buffer.C:
* src/commandtags.h:
* src/LyXAction.C:
* src/lyxfunc.C: added code for LFUN_INSET_ERT and LFUN_INSET_TEXT
* src/BufferView.h
* src/BufferView.C
* src/BufferView2.C: added/updated code for various inset-functions
* src/insets/insetert.[Ch]: added implementation of InsetERT
* src/insets/insettext.[Ch]: added implementation of InsetText
* src/insets/inset.C (Edit): added "unsigned int button" parameter
(draw): added preliminary code for inset scrolling not finshed yet
* src/insets/inset.C (LocalDispatch): changed arg parameter to string
as it is in lyxfunc.C now
* src/insets/lyxinset.h: Added functions for text-insets
2000-02-22 Lars Gullik Bjønnes <larsbj@lyx.org>
* src/lyx_cb.C src/UpdateInset.[Ch]: move the updateinsetlist into

View File

@ -29,6 +29,7 @@ src/insets/form_url.C
src/insets/insetbib.C
src/insets/inseterror.C
src/insets/inseterror.h
src/insets/insetert.C
src/insets/insetinclude.C
src/insets/insetindex.C
src/insets/insetinfo.C
@ -38,6 +39,7 @@ src/insets/insetlof.h
src/insets/insetlot.h
src/insets/insetparent.h
src/insets/insetref.C
src/insets/insettext.C
src/insets/insettoc.h
src/insets/inseturl.C
src/insets/inseturl.h

View File

@ -736,7 +736,7 @@ void BufferView::workAreaButtonPress(int xpos, int ypos, unsigned int button)
selection_possible = false;
owner_->updateLayoutChoice();
owner_->getMiniBuffer()->Set(inset_hit->EditMessage());
inset_hit->Edit(this, xpos, ypos);
inset_hit->Edit(this, xpos, ypos, button);
return;
}
@ -870,7 +870,7 @@ void BufferView::workAreaButtonRelease(int x, int y, unsigned int button)
}
owner_->getMiniBuffer()->Set(inset_hit->EditMessage());
inset_hit->Edit(this, x, y);
inset_hit->Edit(this, x, y, button);
return;
}
@ -946,7 +946,7 @@ void BufferView::workAreaButtonRelease(int x, int y, unsigned int button)
textclasslist
.TextClass(buffer_->
params.textclass).defaultfont())) {
text->cursor.par->bibkey->Edit(this, 0, 0);
text->cursor.par->bibkey->Edit(this, 0, 0, 0);
}
return;
@ -1025,7 +1025,6 @@ Inset * BufferView::checkInsetHit(int & x, int & y)
return 0;
}
void BufferView::workAreaExpose()
{
// this is a hack to ensure that we only call this through
@ -1427,7 +1426,7 @@ void BufferView::insetSleep()
void BufferView::insetWakeup()
{
if (the_locking_inset && inset_slept) {
the_locking_inset->Edit(this, slx, sly);
the_locking_inset->Edit(this, slx, sly, 0);
inset_slept = false;
}
}
@ -1462,6 +1461,18 @@ bool BufferView::active() const
}
Painter & BufferView::getPainter() const
{
return workarea->getPainter();
}
unsigned short BufferView::paperWidth() const
{
return text->paperWidth();
}
bool BufferView::belowMouse() const
{
return workarea->belowMouse();

View File

@ -41,6 +41,8 @@ public:
///
Painter & painter();
///
Painter & getPainter() const;
///
void buffer(Buffer * b);
///
void resize(int, int, int, int);
@ -83,8 +85,12 @@ public:
*/
LyXText * text;
///
unsigned short paperWidth() const;
///
UpdatableInset * the_locking_inset;
///
void updateInset(Inset * inset, bool mark_dirty);
///
bool inset_slept;
///
int slx;
@ -264,8 +270,6 @@ private:
///
UpdateInset updatelist;
public:
///
void updateInset(Inset *, bool);
///
void pushIntoUpdateList(Inset * i) {
updatelist.push(i);

View File

@ -237,7 +237,7 @@ void BufferView::open_new_inset(UpdatableInset * new_inset)
insertInset(new_inset);
text->CursorLeft();
update(1);
new_inset->Edit(this, 0, 0);
new_inset->Edit(this, 0, 0, 0);
}
/* This is also a buffer property (ale) */
@ -360,7 +360,7 @@ void BufferView::insertNote()
{
InsetInfo * new_inset = new InsetInfo();
insertInset(new_inset);
new_inset->Edit(this, 0, 0);
new_inset->Edit(this, 0, 0, 0);
}
@ -684,6 +684,7 @@ void BufferView::replaceWord(string const & replacestring)
// End of spellchecker stuff
/* these functions return 1 if an error occured,
otherwise 0 */
int BufferView::lockInset(UpdatableInset * inset)
@ -756,16 +757,31 @@ void BufferView::updateInset(Inset * inset, bool mark_dirty)
return;
// first check for locking insets
if (the_locking_inset == inset) {
if (text->UpdateInset(inset)){
update();
if (mark_dirty){
if (buffer()->isLyxClean())
owner()->getMiniBuffer()->setTimer(4);
buffer()->markDirty();
if (the_locking_inset) {
if (the_locking_inset == inset) {
if (text->UpdateInset(inset)){
update();
if (mark_dirty){
if (buffer()->isLyxClean())
owner()->getMiniBuffer()->
setTimer(4);
buffer()->markDirty();
}
updateScrollbar();
return;
}
} else if (the_locking_inset->UpdateInsetInInset(this,inset)) {
if (text->UpdateInset(the_locking_inset)) {
update();
if (mark_dirty){
if (buffer()->isLyxClean())
owner()->getMiniBuffer()->
setTimer(4);
buffer()->markDirty();
}
updateScrollbar();
return;
}
updateScrollbar();
return;
}
}

View File

@ -177,6 +177,8 @@ void LyXAction::init()
{ LFUN_GOTOERROR, "error-next", N_("Go to next error"), Noop },
{ LFUN_REMOVEERRORS, "error-remove-all",
N_("Remove all error boxes"), ReadOnly },
{ LFUN_INSET_ERT, "ert-inset-insert",
N_("Insert a new ERT Inset"), Noop },
{ LFUN_FIGURE, "figure-insert", N_("Insert Figure"), Noop },
{ LFUN_FILE_INSERT, "file-insert", "", Noop },
{ LFUN_FILE_INSERT_ASCII, "file-insert-ascii", "", Noop },
@ -330,6 +332,8 @@ void LyXAction::init()
{ LFUN_TABINSERT, "tab-insert", "", Noop },
{ LFUN_TABLE, "table-insert", N_("Insert Table"), Noop },
{ LFUN_TEX, "tex-mode", N_("Toggle TeX style"), Noop },
{ LFUN_INSET_TEXT, "text-inset-insert",
N_("Insert a new Text Inset"), Noop },
{ LFUN_TOC_INSERT, "toc-insert",
N_("Insert table of contents"), Noop },
{ LFUN_TOCVIEW, "toc-view",

View File

@ -73,6 +73,8 @@ using std::setw;
#include "insets/insetparent.h"
#include "insets/insetspecialchar.h"
#include "insets/figinset.h"
#include "insets/insettext.h"
#include "insets/insetert.h"
#include "support/filetools.h"
#include "support/path.h"
#include "LaTeX.h"
@ -745,6 +747,20 @@ bool Buffer::readLyXformat2(LyXLex & lex, LyXParagraph * par)
par->InsertInset(pos, inset);
par->SetFont(pos, font);
++pos;
} else if (tmptok == "ERT") {
inset = new InsetERT(this);
inset->Read(lex);
par->InsertChar(pos, LyXParagraph::META_INSET);
par->InsertInset(pos, inset);
par->SetFont(pos, font);
++pos;
} else if (tmptok == "Text") {
inset = new InsetText(this);
inset->Read(lex);
par->InsertChar(pos, LyXParagraph::META_INSET);
par->InsertInset(pos, inset);
par->SetFont(pos, font);
++pos;
} else if (tmptok == "LatexCommand") {
InsetCommand inscmd;
inscmd.Read(lex);

View File

@ -240,6 +240,8 @@ enum kb_action {
LFUN_SAVEPREFERENCES, // Lgb 991127
LFUN_DATE_INSERT, // jdblair 20000131
LFUN_RTL, // Dekel 20000203
LFUN_INSET_TEXT, // Jug 20000214
LFUN_INSET_ERT, // Jug 20000218
LFUN_LASTACTION /* this marks the end of the table */
};

View File

@ -17,6 +17,8 @@ libinsets_la_SOURCES = \
insetcommand.h \
inseterror.C \
inseterror.h \
insetert.C \
insetert.h \
insetinclude.C \
insetinclude.h \
insetindex.C \
@ -41,6 +43,8 @@ libinsets_la_SOURCES = \
insetref.h \
insetspecialchar.C \
insetspecialchar.h \
insettext.C \
insettext.h \
insettoc.C \
insettoc.h \
inseturl.C \

View File

@ -1036,8 +1036,7 @@ int InsetFig::width(Painter &, LyXFont const &) const
}
void InsetFig::draw(Painter & pain, LyXFont const & f,
int baseline, float & x) const
void InsetFig::draw(Painter & pain, LyXFont const & f, int baseline, float & x) const
{
LyXFont font(f);
@ -1241,7 +1240,7 @@ bool InsetFig::Deletable() const
}
void InsetFig::Edit(BufferView * bv, int, int)
void InsetFig::Edit(BufferView * bv, int, int, unsigned int)
{
lyxerr.debug() << "Editing InsetFig." << endl;
Regenerate();

View File

@ -49,9 +49,9 @@ public:
void Validate(LaTeXFeatures & features) const;
/// what appears in the minibuffer when opening
char const * EditMessage() const { return _("Opened figure"); }
const char * EditMessage() const { return _("Opened figure"); }
///
void Edit(BufferView *, int, int);
void Edit(BufferView *, int, int, unsigned int);
///
unsigned char Editable() const;
///

View File

@ -16,6 +16,7 @@
#include "lyxinset.h"
#include "debug.h"
#include "BufferView.h"
#include "support/lstrings.h"
/* Insets default methods */
@ -49,7 +50,7 @@ bool Inset::AutoDelete() const
}
void Inset::Edit(BufferView *, int, int)
void Inset::Edit(BufferView *, int, int, unsigned int)
{
}
@ -105,3 +106,48 @@ unsigned char UpdatableInset::Editable() const
void UpdatableInset::ToggleInsetCursor(BufferView *)
{
}
void UpdatableInset::Edit(BufferView * bv, int, int, unsigned int)
{
LyXFont
font;
// bview = bv;
scx = 0;
mx_scx=abs((width(bv->getPainter(), font) - bv->paperWidth())/2);
}
void UpdatableInset::draw(Painter &, LyXFont const &,
int baseline, float & x) const
{
if (scx) x += float(scx);
top_x = int(x);
top_baseline = baseline;
}
void UpdatableInset::SetFont(LyXFont const &, bool )
{
}
/// An updatable inset could handle lyx editing commands
#ifdef SCROLL_INSET
UpdatableInset::RESULT UpdatableInset::LocalDispatch(BufferView *,
int action, string arg)
#else
UpdatableInset::RESULT UpdatableInset::LocalDispatch(BufferView *, int, string)
#endif
{
#ifdef SCROLL_INSET
if (action==LFUN_SCROLL_INSET)
{
float xx;
sscanf(arg.c_str(), "%f", &xx);
scroll(xx);
return DISPATCHED;
}
#endif
return UNDISPATCHED;
}

View File

@ -156,7 +156,7 @@ InsetCitation::~InsetCitation()
}
void InsetCitation::Edit(BufferView * bv, int, int)
void InsetCitation::Edit(BufferView * bv, int, int, unsigned int)
{
if(bv->buffer()->isReadonly())
WarnReadonly(bv->buffer()->fileName());
@ -265,7 +265,7 @@ string InsetBibKey::getScreenLabel() const
upwards?
(Joacim 1998-03-04)
*/
void InsetBibKey::Edit(BufferView * bv, int, int)
void InsetBibKey::Edit(BufferView * bv, int, int, unsigned int)
{
if(bv->buffer()->isReadonly())
WarnReadonly(bv->buffer()->fileName());
@ -419,7 +419,7 @@ string InsetBibtex::getKeys(char delim)
// BibTeX should have its own dialog. This is provisional.
void InsetBibtex::Edit(BufferView *, int, int)
void InsetBibtex::Edit(BufferView *, int, int, unsigned int)
{
if (!bibitem_form) {
bibitem_form = create_form_bibitem_form();

View File

@ -18,8 +18,7 @@
#include "insetcommand.h"
// Created by Alejandro 970222
class Buffer;
/** Used to insert citations
*/
@ -38,7 +37,7 @@ public:
///
string getScreenLabel()const;
///
void Edit(BufferView *, int, int);
void Edit(BufferView *, int x, int y, unsigned int button);
///
unsigned char Editable() const {
return 1;
@ -77,7 +76,7 @@ public:
///
virtual string getScreenLabel() const;
///
void Edit(BufferView *, int, int);
void Edit(BufferView *, int x, int y, unsigned int button);
///
unsigned char Editable() const {
return 1;
@ -126,7 +125,7 @@ public:
///
string getScreenLabel() const;
///
void Edit(BufferView *, int, int);
void Edit(BufferView *, int x, int y, unsigned int button);
///
int Latex(ostream &, signed char) const;
///

View File

@ -155,7 +155,7 @@ extern "C" void C_InsetError_CloseErrorCB(FL_OBJECT * ob, long data)
}
void InsetError::Edit(BufferView *, int, int)
void InsetError::Edit(BufferView *, int, int, unsigned int)
{
static int ow = 400, oh = 240;

View File

@ -41,8 +41,7 @@ public:
///
int width(Painter &, LyXFont const & font) const;
///
void draw(Painter &, LyXFont const & font,
int baseline, float & x) const;
void draw(Painter &, LyXFont const & font, int baseline, float & x) const;
///
void Write(ostream &) const;
///
@ -58,9 +57,9 @@ public:
///
bool AutoDelete() const;
/// what appears in the minibuffer when opening
char const * EditMessage() const {return _("Opened error");}
const char * EditMessage() const {return _("Opened error");}
///
void Edit(BufferView *, int, int);
void Edit(BufferView *, int x, int y, unsigned int button);
///
unsigned char Editable() const;
///

191
src/insets/insetert.C Normal file
View File

@ -0,0 +1,191 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright (C) 1998 The LyX Team.
*
*======================================================*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "insetert.h"
#include "gettext.h"
#include "lyxfont.h"
#include "Painter.h"
#include "lyx_gui_misc.h"
InsetERT::InsetERT(Buffer * bf): InsetText(bf)
{
closed = true;
nomotion = false;
}
InsetERT * InsetERT::Clone() const
{
InsetERT * result = new InsetERT(buffer);
return result;
}
void InsetERT::Write(ostream & os) const
{
os << "ERT\n";
WriteParagraphData(os);
}
int InsetERT::ascent_closed(Painter & pain, LyXFont const & f) const
{
int width, ascent, descent;
LyXFont font(LyXFont::ALL_SANE);
font.setSize(f.size());
font.decSize();
font.decSize();
pain.buttonText(0, 0, _("ERT"), font, false, width, ascent, descent);
return ascent;
}
int InsetERT::descent_closed(Painter & pain, LyXFont const & f) const
{
int width, ascent, descent;
LyXFont font(LyXFont::ALL_SANE);
font.setSize(f.size());
font.decSize();
font.decSize();
pain.buttonText(0, 0, _("ERT"), font, false, width, ascent, descent);
return descent;
}
int InsetERT::width_closed(Painter & pain, LyXFont const & f) const
{
int width, ascent, descent;
LyXFont font(LyXFont::ALL_SANE);
font.setSize(f.size());
font.decSize();
font.decSize();
pain.buttonText(TEXT_TO_INSET_OFFSET, 0, _("ERT"), font, false,
width, ascent, descent);
return width + (2*TEXT_TO_INSET_OFFSET);
}
int InsetERT::ascent(Painter & pain, LyXFont const & font) const
{
if (closed)
return ascent_closed(pain, font);
else
return InsetText::ascent(pain, font);
}
int InsetERT::descent(Painter & pain, LyXFont const & font) const
{
if (closed)
return descent_closed(pain, font);
else
return InsetText::descent(pain, font);
}
int InsetERT::width(Painter & pain, LyXFont const & font) const
{
if (closed)
return width_closed(pain, font);
else
return InsetText::width(pain, font);
}
void InsetERT::draw_closed(Painter & pain, LyXFont const & f,
int baseline, float & x) const
{
LyXFont font(LyXFont::ALL_SANE);
font.setSize(f.size());
font.decSize();
font.decSize();
font.setColor(LColor::ert);
int width;
pain.buttonText(int(x)+TEXT_TO_INSET_OFFSET, baseline, _("ERT"), font,
true, width);
x += width + (2*TEXT_TO_INSET_OFFSET);
}
void InsetERT::draw(Painter & pain, LyXFont const & f, int baseline, float & x) const
{
if (closed) {
top_x = int(x);
top_baseline = baseline;
draw_closed(pain, f, baseline, x);
} else {
InsetText::draw(pain, f, baseline, x);
}
// resetPos(bv);
}
void InsetERT::InsetButtonRelease(BufferView * bv, int x, int y, int button)
{
nomotion = false;
InsetText::InsetButtonRelease(bv, x, y, button);
}
void InsetERT::InsetButtonPress(BufferView * bv, int x, int y, int button)
{
nomotion = false;
InsetText::InsetButtonPress(bv, x, y, button);
}
void InsetERT::InsetMotionNotify(BufferView * bv, int x, int y, int button)
{
if (nomotion)
return;
InsetText::InsetMotionNotify(bv, x, y, button);
}
void InsetERT::Edit(BufferView * bv, int x, int y, unsigned int button)
{
closed = false;
nomotion = true;
LyXFont font(LyXFont::ALL_SANE);
font.setLatex (LyXFont::ON);
InsetText::Edit(bv, (x > (width_closed(bv->getPainter(),font)-5) ?
width(bv->getPainter(), font) : 0), y, button);
real_current_font = current_font = font;
bv->updateInset(this, false);
}
void InsetERT::InsetUnlock(BufferView * bv)
{
closed = true;
InsetText::InsetUnlock(bv);
bv->updateInset(this, false);
}
bool InsetERT::InsertInset(Inset *)
{
return false;
}
void InsetERT::SetFont(LyXFont const &, bool)
{
WriteAlert(_("Impossible Operation!"),
_("Not permitted to change font-types inside ERT-insets!"),
_("Sorry."));
}

86
src/insets/insetert.h Normal file
View File

@ -0,0 +1,86 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright (C) 1998 The LyX Team.
*
*======================================================
*/
// The pristine updatable inset: Text
#ifndef INSETERT_H
#define INSETERT_H
#ifdef __GNUG__
#pragma interface
#endif
#include "insettext.h"
class Painter;
/** A colapsable text inset
To write full ert (including styles and other insets) in a given
space.
*/
class InsetERT : public InsetText {
public:
///
InsetERT(Buffer *);
///
// InsetERT(InsetERT const &, Buffer *);
///
~InsetERT() {}
///
InsetERT * Clone() const;
///
// void Read(LyXLex &);
///
void Write(ostream &) const;
///
int ascent(Painter &, LyXFont const &) const;
///
int descent(Painter &, LyXFont const &) const;
///
int width(Painter &, LyXFont const & f) const;
///
void draw(Painter & pain, const LyXFont &, int , float &) const;
///
//LString EditMessage() const;
///
void InsetButtonRelease(BufferView *, int, int, int);
///
void InsetButtonPress(BufferView *, int, int, int);
///
void InsetMotionNotify(BufferView *, int, int, int);
///
void Edit(BufferView *, int, int, unsigned int);
///
void InsetUnlock(BufferView *);
///
bool InsertInset(Inset *);
///
void SetFont(LyXFont const &, bool toggleall);
protected:
///
int ascent_closed(Painter &, LyXFont const &) const;
///
int descent_closed(Painter &, LyXFont const &) const;
///
int width_closed(Painter &, LyXFont const & f) const;
///
void draw_closed(Painter & pain, const LyXFont &, int , float &) const;
private:
///
bool
closed,
nomotion;
};
#endif

View File

@ -226,7 +226,7 @@ Inset * InsetInclude::Clone() const
}
void InsetInclude::Edit(BufferView * bv, int, int)
void InsetInclude::Edit(BufferView * bv, int, int, unsigned int)
{
if(bv->buffer()->isReadonly())
WarnReadonly(bv->buffer()->fileName());

View File

@ -47,7 +47,7 @@ public:
/// This returns the list of bibkeys on the child buffer
string getKeys(char delim) const;
///
void Edit(BufferView *, int, int);
void Edit(BufferView *, int x, int y, unsigned int button);
///
unsigned char Editable() const
{

View File

@ -85,7 +85,7 @@ InsetIndex::~InsetIndex()
}
void InsetIndex::Edit(BufferView * bv, int, int)
void InsetIndex::Edit(BufferView * bv, int, int, unsigned int)
{
if(bv->buffer()->isReadonly())
WarnReadonly(bv->buffer()->fileName());

View File

@ -37,7 +37,7 @@ public:
///
Inset * Clone() const { return new InsetIndex(contents);}
///
void Edit(BufferView *, int, int);
void Edit(BufferView *, int, int, unsigned int);
///
unsigned char Editable() const
{
@ -59,7 +59,7 @@ public:
/// Updates needed features for this inset.
void Validate(LaTeXFeatures & features) const;
///
void Edit(BufferView *, int, int) {}
void Edit(BufferView *, int, int, unsigned int) {}
///
unsigned char Editable() const{
return 1;

View File

@ -180,7 +180,7 @@ extern "C" void C_InsetInfo_CloseInfoCB(FL_OBJECT * ob, long data)
}
void InsetInfo::Edit(BufferView * bv, int, int)
void InsetInfo::Edit(BufferView *bv, int, int, unsigned int)
{
static int ow = -1, oh;

View File

@ -57,9 +57,9 @@ public:
///
int DocBook(string & file) const;
/// what appears in the minibuffer when opening
char const * EditMessage() const {return _("Opened note");}
const char * EditMessage() const {return _("Opened note");}
///
void Edit(BufferView *, int, int);
void Edit(BufferView *, int, int, unsigned int);
///
unsigned char Editable() const;
///

View File

@ -19,7 +19,7 @@
#include "insetcommand.h"
#include "gettext.h"
// Created by Bernhard 970807
class Buffer;
/** Used to insert table of algorithms
*/

View File

@ -35,10 +35,10 @@ InsetParent::InsetParent(string const & fn, Buffer * owner)
}
void InsetParent::Edit(BufferView * bv, int, int)
void InsetParent::Edit(BufferView * bv, int, int, unsigned int)
{
bv->owner()->getLyXFunc()->Dispatch(LFUN_CHILDOPEN,
getContents().c_str());
bv->owner()->getLyXFunc()->
Dispatch(LFUN_CHILDOPEN, getContents().c_str());
}

View File

@ -17,7 +17,8 @@
#include "insetcommand.h"
#include "gettext.h"
// Created by asierra 970813
class Buffer;
/** Reference to the parent document.
@ -41,7 +42,7 @@ public:
return string(_("Parent:")) + getContents();
}
///
void Edit(BufferView *, int, int);
void Edit(BufferView *, int, int, unsigned int);
///
unsigned char Editable() const {
return 1;

View File

@ -43,10 +43,10 @@ InsetRef::InsetRef(InsetCommand const & inscmd, Buffer * bf)
}
void InsetRef::Edit(BufferView * bv, int, int)
void InsetRef::Edit(BufferView * bv, int, int, unsigned int)
{
bv->owner()->getLyXFunc()
->Dispatch(LFUN_REFGOTO, getContents().c_str());
bv->owner()->getLyXFunc()->
Dispatch(LFUN_REFGOTO, getContents().c_str());
}

View File

@ -45,7 +45,7 @@ public:
///
Inset::Code LyxCode() const { return Inset::REF_CODE; }
///
void Edit(BufferView *, int, int);
void Edit(BufferView *, int, int, unsigned int);
///
unsigned char Editable() const {
return 1;

1466
src/insets/insettext.C Normal file

File diff suppressed because it is too large Load Diff

242
src/insets/insettext.h Normal file
View File

@ -0,0 +1,242 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright (C) 1998 The LyX Team.
*
*======================================================
*/
// The pristine updatable inset: Text
#ifndef INSETTEXT_H
#define INSETTEXT_H
#ifdef __GNUG__
#pragma interface
#endif
#include "lyxinset.h"
#include "lyxparagraph.h"
#include "LString.h"
#include "buffer.h"
class Painter;
class BufferView;
/** A text inset is like a TeX box
To write full text (including styles and other insets) in a given
space.
*/
class InsetText : public UpdatableInset {
public:
///
enum { TEXT_TO_INSET_OFFSET = 1 };
///
InsetText(Buffer *);
///
InsetText(InsetText const &, Buffer *);
///
~InsetText();
///
InsetText * Clone() const;
///
void Read(LyXLex &);
///
void Write(ostream &) const;
///
int ascent(Painter &, LyXFont const &) const;
///
int descent(Painter &, LyXFont const &) const;
///
int width(Painter &, LyXFont const & f) const;
///
int getMaxWidth(UpdatableInset *) const;
///
void draw(Painter & pain, const LyXFont &, int , float &) const;
///
const char * EditMessage() const;
///
void Edit(BufferView *, int, int, unsigned int);
///
void InsetUnlock(BufferView *);
///
bool UnlockInsetInInset(BufferView *, Inset *, bool lr=false);
///
//void UpdateLocal(bool flag=true);
///
bool UpdateInsetInInset(BufferView *, Inset *);
///
void InsetButtonRelease(BufferView *, int, int, int);
///
void InsetButtonPress(BufferView *, int, int, int);
///
void InsetMotionNotify(BufferView *, int, int, int);
///
void InsetKeyPress(XKeyEvent *);
///
UpdatableInset::RESULT LocalDispatch(BufferView *, int, string);
///
int Latex(ostream &, signed char) const;
///
int Latex(string &, signed char) const;
///
int Linuxdoc(class string &) const { return true; }
///
int DocBook(class string &) const { return true; }
///
void Validate(LaTeXFeatures & features) const;
///
Inset::Code LyxCode() const { return Inset::TEXT_CODE; }
///
void GetCursorPos(int & x, int & y);
///
int InsetInInsetY();
///
void ToggleInsetCursor(BufferView *);
///
bool InsertInset(BufferView *, Inset *);
///
UpdatableInset * GetLockingInset();
///
void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
///
void init(BufferView *);
LyXParagraph * par;
protected:
///
void WriteParagraphData(ostream &) const;
///
void resetPos(BufferView *);
///
void drawSelection(Painter & pain, int pos, int baseline, float x);
///
void SingleHeight(BufferView *, LyXParagraph * par,int pos,
int & asc, int & desc);
///
int SingleWidth(BufferView * bv, LyXParagraph * par, int pos);
///
LyXFont GetFont(LyXParagraph * par, int pos) const;
///
Buffer * buffer;
///
LyXFont current_font;
///
LyXFont real_current_font;
///
int maxWidth;
///
int maxAscent;
///
int maxDescent;
///
int insetWidth;
private:
///
void drawRowSelection(Painter &, int startpos, int endpos, int row,
int baseline, float x) const;
///
void drawRowText(Painter &, int startpos, int endpos, int baseline,
float x) const;
///
void computeTextRows(BufferView *);
///
void computeBaselines(int) const;
///
int BeginningOfMainBody(LyXParagraph * par) const;
///
void ShowInsetCursor(BufferView *);
///
void HideInsetCursor(BufferView *);
///
void setPos(BufferView *, int x, int y, bool activate_inset=true);
///
bool moveRight(BufferView *, bool activate_inset = true);
bool moveLeft(BufferView *, bool activate_inset = true);
bool moveUp(BufferView *, bool activate_inset = true);
bool moveDown(BufferView *, bool activate_inset = true);
bool Delete();
///
bool hasSelection() const {return (selection_start != selection_end);}
///
void SetCharFont(int pos, LyXFont font);
///
string getText(int);
/* Private structures and variables */
///
int inset_pos;
///
int inset_x;
///
int inset_y;
///
int interline_space;
///
int selection_start;
///
int selection_end;
///
int old_x;
///
int cx;
///
int cy;
///
int actpos;
///
int actrow;
///
bool no_selection;
///
bool init_inset;
///
UpdatableInset * the_locking_inset;
///
struct row_struct {
///
int asc;
///
int desc;
///
int pos;
///
int baseline;
};
///
typedef vector<row_struct> RowList;
///
mutable RowList rows;
InsetText & operator = (InsetText const & it) {
par = it.par;
buffer = it.buffer; // suspect
current_font = it.current_font;
real_current_font = it.real_current_font;
maxWidth = it.maxWidth;
maxAscent = it.maxAscent;
maxDescent = it.maxDescent;
insetWidth = it.insetWidth;
inset_pos = it.inset_pos;
inset_x = it.inset_x;
inset_y = it.inset_y;
interline_space = it.interline_space;
selection_start = it.selection_start;
selection_end = it.selection_end;
old_x = it.old_x;
cx = it.cx;
cy = it.cy;
actpos = it.actpos;
actrow = it.actrow;
no_selection = it.no_selection;
the_locking_inset = it.the_locking_inset; // suspect
rows = it.rows;
return * this;
}
};
#endif

View File

@ -10,8 +10,9 @@
#include "commandtags.h"
#include "lyxfunc.h"
#include "LyXView.h"
#include "BufferView.h"
void InsetTOC::Edit(BufferView * bv, int, int)
void InsetTOC::Edit(BufferView * bv, int, int, unsigned int)
{
bv->owner()->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
}

View File

@ -19,7 +19,7 @@
#include "insetcommand.h"
#include "gettext.h"
// Created by Lgb 970527
class Buffer;
/** Used to insert table of contents
*/
@ -34,7 +34,7 @@ public:
///
string getScreenLabel() const { return _("Table of Contents"); }
/// On edit, we open the TOC pop-up
void Edit(BufferView *, int, int);
void Edit(BufferView * bv, int, int, unsigned int);
///
unsigned char Editable() const {
return 1;

View File

@ -109,7 +109,7 @@ extern "C" void C_InsetUrl_CloseUrlCB(FL_OBJECT * ob, long data)
}
void InsetUrl::Edit(BufferView * bv, int, int)
void InsetUrl::Edit(BufferView * bv, int, int, unsigned int)
{
static int ow = -1, oh;

View File

@ -52,13 +52,13 @@ public:
///
void Validate(LaTeXFeatures &) const;
///
void Edit(BufferView *, int, int);
void Edit(BufferView *, int, int, unsigned int);
///
unsigned char Editable() const {
return 1;
}
///
char const * EditMessage() const {return _("Opened Url");}
const char * EditMessage() const {return _("Opened Url");}
///
bool display() const { return false; }
///

View File

@ -76,7 +76,9 @@ public:
///
PARENT_CODE,
///
BIBTEX_CODE
BIBTEX_CODE,
///
TEXT_CODE
};
///
@ -93,9 +95,9 @@ public:
///
virtual LyXFont ConvertFont(LyXFont font);
/// what appears in the minibuffer when opening
virtual char const * EditMessage() const {return _("Opened inset");}
virtual const char * EditMessage() const {return _("Opened inset");}
///
virtual void Edit(BufferView *, int, int);
virtual void Edit(BufferView *, int x, int y, unsigned int button);
///
virtual unsigned char Editable() const;
///
@ -142,6 +144,8 @@ public:
virtual int GetNumberOfLabels() const {
return 0;
}
///
virtual void init(BufferView *) {}
};
@ -174,6 +178,28 @@ public:
*/
class UpdatableInset: public Inset {
public:
/** Dispatch result codes
Now that nested updatable insets are allowed, the local dispatch
becomes a bit complex, just two possible results (boolean)
are not enough.
DISPATCHED = the inset catched the action
FINISHED = the inset must be unlocked as a result
of the action
UNDISPATCHED = the action was not catched, it should be
dispatched by lower level insets
*/
enum RESULT {
UNDISPATCHED=0,
DISPATCHED,
FINISHED
};
/// To convert old binary dispatch results
RESULT DISPATCH_RESULT(bool b) {
return (b) ? DISPATCHED: FINISHED;
}
///
//virtual ~UpdatableInset() {}
///
@ -188,20 +214,48 @@ public:
///
virtual void InsetButtonRelease(BufferView *,
int x, int y, int button);
///
virtual void InsetKeyPress(XKeyEvent * ev);
///
virtual void InsetMotionNotify(BufferView *, int x, int y, int state);
///
virtual void InsetUnlock(BufferView *);
///
virtual void Edit(BufferView *, int x, int y, unsigned int button);
///
virtual void draw(Painter &, LyXFont const &,
int baseline, float & x) const;
///
virtual void SetFont(LyXFont const &, bool toggleall = false);
///
virtual bool InsertInset(Inset *) { return false; }
///
virtual UpdatableInset * GetLockingInset() { return this; }
///
virtual int InsetInInsetY() { return 0; }
///
virtual bool UpdateInsetInInset(BufferView *, Inset *) {return false;}
///
virtual bool UnlockInsetInInset(BufferView *,Inset *,bool /*lr*/=false)
{return false;}
/// An updatable inset could handle lyx editing commands
virtual bool LocalDispatch(BufferView *, int, char const *) { return false; };
//
bool isCursorVisible() const { return cursor_visible; }
virtual RESULT LocalDispatch(BufferView *, int, string);
///
virtual bool isCursorVisible() const { return cursor_visible; }
///
virtual int getMaxWidth(UpdatableInset *) const { return -1; }
protected:
///
// virtual void UpdateLocal(bool flag=true);
///
mutable int top_x;
mutable int top_baseline;
mutable bool cursor_visible;
private:
///
int mx_scx;
mutable int scx;
};
#endif

View File

@ -2134,7 +2134,10 @@ void ToggleAndShow(BufferView * bv, LyXFont const & font)
if (bv->available()) {
bv->hideCursor();
bv->update(-2);
bv->text->ToggleFree(font, toggleall);
if (bv->the_locking_inset)
bv->the_locking_inset->SetFont(font, toggleall);
else
bv->text->ToggleFree(font, toggleall);
bv->update(1);
}
}
@ -3143,7 +3146,7 @@ extern "C" void FigureApplyCB(FL_OBJECT *, long)
InsetFig * new_inset = new InsetFig(100, 20, buffer);
current_view->insertInset(new_inset);
current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
new_inset->Edit(current_view, 0, 0);
new_inset->Edit(current_view, 0, 0, 0);
return;
}
@ -3192,7 +3195,7 @@ extern "C" void FigureApplyCB(FL_OBJECT *, long)
Inset * new_inset = new InsetFig(100, 100, buffer);
current_view->insertInset(new_inset);
new_inset->Edit(current_view, 0, 0);
new_inset->Edit(current_view, 0, 0, 0);
current_view->update(0);
current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
current_view->text->UnFreezeUndo();

View File

@ -41,6 +41,8 @@
#include "insets/insetindex.h"
#include "insets/insetinclude.h"
#include "insets/insetbib.h"
#include "insets/insettext.h"
#include "insets/insetert.h"
#include "mathed/formulamacro.h"
#include "toolbar.h"
#include "spellchecker.h" // RVDK_PATCH_5
@ -524,44 +526,55 @@ string LyXFunc::Dispatch(int ac,
inset->GetCursorPos(slx, sly);
owner->view()->unlockInset(inset);
owner->view()->menuUndo();
inset = static_cast<UpdatableInset*>(owner->view()->text->cursor.par->GetInset(owner->view()->text->cursor.pos));
if (inset)
inset->Edit(owner->view(), slx, sly);
inset = static_cast<UpdatableInset*>(
owner->view()->text->cursor.par->
GetInset(owner->view()->text->
cursor.pos));
if (inset)
inset->Edit(owner->view(),slx,sly,0);
return string();
} else
if (action == LFUN_REDO) {
int slx, sly;
UpdatableInset * inset = owner->view()->the_locking_inset;
inset->GetCursorPos(slx, sly);
owner->view()->unlockInset(inset);
owner->view()->menuRedo();
inset = static_cast<UpdatableInset*>(owner->view()->text->cursor.par->GetInset(owner->view()->text->cursor.pos));
if (inset)
inset->Edit(owner->view(),
slx, sly);
} else if (action == LFUN_REDO) {
int slx, sly;
UpdatableInset * inset = owner->view()->
the_locking_inset;
inset->GetCursorPos(slx, sly);
owner->view()->unlockInset(inset);
owner->view()->menuRedo();
inset = static_cast<UpdatableInset*>(
owner->view()->text->cursor.par->
GetInset(owner->view()->text->
cursor.pos));
if (inset)
inset->Edit(owner->view(),slx,sly,0);
return string();
} else if (owner->view()->the_locking_inset->
LocalDispatch(owner->view(),action,
argument) ==
UpdatableInset::DISPATCHED)
return string();
else {
setMessage(N_("Text mode"));
LyXDirection direction = owner->view()->text->
cursor.par->getParDirection();
if ((action == -1) ||
((action == LFUN_RIGHT) &&
(direction == LYX_DIR_LEFT_TO_RIGHT))) {
owner->view()->text->CursorRight();
moveCursorUpdate(false);
owner->getMiniBuffer()->
Set(CurrentState());
}
if ((action == LFUN_LEFT) &&
(direction == LYX_DIR_RIGHT_TO_LEFT)) {
owner->view()->text->CursorRight();
moveCursorUpdate(false);
owner->getMiniBuffer()->
Set(CurrentState());
}
if ((action == LFUN_LEFT) ||
(action == LFUN_RIGHT))
return string();
} else
if (owner->view()->the_locking_inset->LocalDispatch(owner->view(), action, argument.c_str()))
return string();
else {
setMessage(N_("Text mode"));
LyXDirection direction = owner->view()->text->cursor.par->getParDirection();
if ( action == -1 ||
(action == LFUN_RIGHT
&& direction == LYX_DIR_LEFT_TO_RIGHT)) {
owner->view()->text->CursorRight();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
}
if ( action == LFUN_LEFT
&& direction == LYX_DIR_RIGHT_TO_LEFT) {
owner->view()->text->CursorRight();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
}
if (action == LFUN_LEFT || action == LFUN_RIGHT)
return string();
}
}
}
}
@ -1288,7 +1301,7 @@ string LyXFunc::Dispatch(int ac,
&& tmptext->cursor.par->GetInset(tmptext->cursor.pos)->Editable() == 2){
Inset * tmpinset = tmptext->cursor.par->GetInset(tmptext->cursor.pos);
setMessage(tmpinset->EditMessage());
tmpinset->Edit(owner->view(), 0, 0);
tmpinset->Edit(owner->view(), 0, 0, 0);
break;
}
if (direction == LYX_DIR_LEFT_TO_RIGHT)
@ -1319,7 +1332,8 @@ string LyXFunc::Dispatch(int ac,
tmpinset->Edit(owner->view(),
tmpinset->width(owner->view()->painter(),
txt->GetFont(txt->cursor.par,
txt->cursor.pos)), 0);
txt->cursor.pos)),
0, 0);
break;
}
if (direction == LYX_DIR_RIGHT_TO_LEFT)
@ -1876,7 +1890,21 @@ string LyXFunc::Dispatch(int ac,
else
new_inset = new InsetUrl("url", "", "");
owner->view()->insertInset(new_inset);
new_inset->Edit(owner->view(), 0, 0);
new_inset->Edit(owner->view(), 0, 0, 0);
}
break;
case LFUN_INSET_TEXT:
{
InsetText * new_inset = new InsetText(owner->buffer());
owner->view()->insertInset(new_inset);
new_inset->Edit(owner->view(), 0, 0, 0);
}
break;
case LFUN_INSET_ERT:
{
InsetERT * new_inset = new InsetERT(owner->buffer());
owner->view()->insertInset(new_inset);
new_inset->Edit(owner->view(), 0, 0, 0);
}
break;
@ -2169,7 +2197,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->insertInset(new_inset);
} else {
owner->view()->insertInset(new_inset);
new_inset->Edit(owner->view(), 0, 0);
new_inset->Edit(owner->view(), 0, 0, 0);
}
}
break;
@ -2190,7 +2218,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->insertInset(new_inset);
if (lsarg.empty()) {
new_inset->Edit(owner->view(), 0, 0);
new_inset->Edit(owner->view(), 0, 0, 0);
}
}
break;
@ -2256,7 +2284,7 @@ string LyXFunc::Dispatch(int ac,
//don't edit it if the call was to INSERT_LAST
if(action != LFUN_INDEX_INSERT_LAST) {
new_inset->Edit(owner->view(), 0, 0);
new_inset->Edit(owner->view(), 0, 0, 0);
} else {
//it looks blank on the screen unless
//we do something. put it here.
@ -2294,7 +2322,7 @@ string LyXFunc::Dispatch(int ac,
Inset * new_inset = new InsetInclude(argument,
owner->buffer());
owner->view()->insertInset(new_inset, "Standard", true);
new_inset->Edit(owner->view(), 0, 0);
new_inset->Edit(owner->view(), 0, 0, 0);
}
break;

View File

@ -154,6 +154,8 @@ public:
LyXParagraph * TeXOnePar(string & file, TexRow & texrow,
string & foot, TexRow & foot_texrow,
int & foot_count);
///
bool SimpleTeXOnePar(string & file, TexRow & texrow);
///
LyXParagraph * TeXEnvironment(string & file, TexRow & texrow,
@ -522,8 +524,6 @@ private:
int & foot_count,
LyXDirection par_direction);
///
bool SimpleTeXOnePar(string & file, TexRow & texrow);
///
bool SimpleTeXOneTablePar(string & file, TexRow & texrow);
///
bool TeXContTableRows(string & file, size_type i,

View File

@ -344,11 +344,11 @@ public:
LyXAlignment align,
string labelwidthstring,
bool noindent);
void SetParagraphExtraOpt(int type,
char const * width,
char const * widthp,
int alignment, bool hfill,
bool start_minipage);
void SetParagraphExtraOpt(int type,
char const * width,
char const * widthp,
int alignment, bool hfill,
bool start_minipage);
/* these things are for search and replace */
@ -468,12 +468,12 @@ public:
void CursorLeftIntern() const;
///
void CursorRightIntern() const;
///
void RemoveTableRow(LyXCursor * cursor) const;
///
bool IsEmptyTableCell() const;
///
void toggleAppendix();
///
void RemoveTableRow(LyXCursor * cursor) const;
///
bool IsEmptyTableCell() const;
///
void toggleAppendix();
///
unsigned short paperWidth() const { return paperwidth; }
private:

View File

@ -452,15 +452,15 @@ void InsetFormula::draw(Painter & pain, LyXFont const &,
}
void InsetFormula::Edit(BufferView * bv, int x, int y)
void InsetFormula::Edit(BufferView * bv, int x, int y, unsigned int)
{
mathcursor = new MathedCursor(par);
bv->lockInset(this);
par->Metrics();
bv->updateInset(this, false);
x += par->xo;
y += par->yo;
mathcursor->SetPos(x, y);
mathcursor = new MathedCursor(par);
bv->lockInset(this);
par->Metrics();
bv->updateInset(this, false);
x += par->xo;
y += par->yo;
mathcursor->SetPos(x, y);
sel_x = sel_y = 0;
sel_flag = false;
}
@ -712,16 +712,17 @@ bool InsetFormula::SetNumber(bool numbf)
}
bool InsetFormula::LocalDispatch(BufferView * bv, int action, char const * arg)
UpdatableInset::RESULT InsetFormula::LocalDispatch(BufferView * bv,
int action, string arg)
{
// extern char *dispatch_result;
MathedTextCodes varcode = LM_TC_MIN;
bool was_macro = mathcursor->InMacroMode();
bool sel = false;
bool space_on = false;
bool was_selection = mathcursor->Selection();
bool result = true;
static MathSpaceInset * sp= 0;
bool was_macro = mathcursor->InMacroMode();
bool sel = false;
bool space_on = false;
bool was_selection = mathcursor->Selection();
RESULT result = DISPATCHED;
static MathSpaceInset * sp= 0;
HideInsetCursor(bv);
@ -734,23 +735,23 @@ bool InsetFormula::LocalDispatch(BufferView * bv, int action, char const * arg)
case LFUN_RIGHTSEL: sel = true;
case LFUN_RIGHT:
{
result = mathcursor->Right(sel);
result = DISPATCH_RESULT(mathcursor->Right(sel));
break;
}
case LFUN_LEFTSEL: sel = true;
case LFUN_LEFT:
{
result = mathcursor->Left(sel);
result = DISPATCH_RESULT(mathcursor->Left(sel));
break;
}
case LFUN_UPSEL: sel = true;
case LFUN_UP:
result = mathcursor->Up(sel);
result = DISPATCH_RESULT(mathcursor->Up(sel));
break;
case LFUN_DOWNSEL: sel = true;
case LFUN_DOWN:
result = mathcursor->Down(sel);
result = DISPATCH_RESULT(mathcursor->Down(sel));
break;
case LFUN_HOME:
mathcursor->Home();
@ -802,7 +803,7 @@ bool InsetFormula::LocalDispatch(BufferView * bv, int action, char const * arg)
case LFUN_SETXY:
{
int x, y, x1, y1;
sscanf(arg, "%d %d", &x, &y);
sscanf(arg.c_str(), "%d %d", &x, &y);
par->GetXY(x1, y1);
mathcursor->SetPos(x1+x, y1+y);
}
@ -918,8 +919,8 @@ bool InsetFormula::LocalDispatch(BufferView * bv, int action, char const * arg)
}
case LFUN_MATH_SIZE:
if (arg) {
latexkeys * l = in_word_set (arg, strlen(arg));
if (!arg.empty()) {
latexkeys * l = in_word_set (arg.c_str(), strlen(arg.c_str()));
int sz = (l) ? l->id: -1;
mathcursor->SetSize(sz);
UpdateLocal(bv);
@ -929,7 +930,7 @@ bool InsetFormula::LocalDispatch(BufferView * bv, int action, char const * arg)
case LFUN_INSERT_MATH:
{
bv->lockedInsetStoreUndo(Undo::INSERT);
InsertSymbol(bv, arg);
InsertSymbol(bv, arg.c_str());
break;
}
@ -939,7 +940,7 @@ bool InsetFormula::LocalDispatch(BufferView * bv, int action, char const * arg)
int k, m, n;
char s[80], arg2[80];
// This is just so that too long args won't ooze out of s.
strncpy(arg2, arg, 80); arg2[79]= '\0';
strncpy(arg2, arg.c_str(), 80); arg2[79]= '\0';
k = sscanf(arg2, "%d %d %s", &m, &n, s);
s[79] = '\0';
@ -967,8 +968,9 @@ bool InsetFormula::LocalDispatch(BufferView * bv, int action, char const * arg)
latexkeys * l;
string vdelim("(){}[]./|");
if (!arg) break;
strncpy(arg2, arg, 40); arg2[39]= '\0';
if (arg.empty())
break;
strncpy(arg2, arg.c_str(), 40); arg2[39]= '\0';
int n = sscanf(arg2, "%s %s", lf, rg);
lf[39] = '\0'; rg[39] = '\0';
@ -1070,7 +1072,7 @@ bool InsetFormula::LocalDispatch(BufferView * bv, int action, char const * arg)
break;
default:
if ((action == -1 || action == LFUN_SELFINSERT) && arg) {
if ((action == -1 || action == LFUN_SELFINSERT) && !arg.empty()) {
unsigned char c = arg[0];
bv->lockedInsetStoreUndo(Undo::INSERT);
@ -1158,7 +1160,7 @@ bool InsetFormula::LocalDispatch(BufferView * bv, int action, char const * arg)
space_on = true;
} else {
if (!mathcursor->Pop() && mathcursor->IsEnd())
result = false;
result = FINISHED;
}
} else
if (c == '\'') {
@ -1173,7 +1175,7 @@ bool InsetFormula::LocalDispatch(BufferView * bv, int action, char const * arg)
UpdateLocal(bv);
} else {
// lyxerr << "Closed by action " << action << endl;
result = false;
result = FINISHED;
}
}
if (was_macro != mathcursor->InMacroMode()
@ -1184,7 +1186,7 @@ bool InsetFormula::LocalDispatch(BufferView * bv, int action, char const * arg)
if (mathcursor->Selection() || was_selection)
ToggleInsetSelection(bv);
if (result)
if (result == DISPATCHED)
ShowInsetCursor(bv);
else
bv->unlockInset(this);

View File

@ -70,9 +70,9 @@ public:
}
/// what appears in the minibuffer when opening
char const * EditMessage() const {return _("Math editor mode");}
const char * EditMessage() const {return _("Math editor mode");}
///
void Edit(BufferView *, int x, int y);
void Edit(BufferView *, int x, int y, unsigned int button);
///
bool display() const { return (disp_flag) ? true: false; }
///
@ -99,7 +99,7 @@ public:
void InsetUnlock(BufferView *);
/// To allow transparent use of math editing functions
virtual bool LocalDispatch(BufferView *, int, char const *);
virtual RESULT LocalDispatch(BufferView *, int, string);
///
void InsertSymbol(BufferView *, char const *);

View File

@ -146,7 +146,7 @@ int InsetFormulaMacro::width(Painter & pain, LyXFont const & f) const
void InsetFormulaMacro::draw(Painter & pain, LyXFont const & f,
int baseline, float & x) const
int baseline, float & x)
{
LyXFont font(f);
tmacro->update();
@ -173,11 +173,11 @@ void InsetFormulaMacro::draw(Painter & pain, LyXFont const & f,
}
void InsetFormulaMacro::Edit(BufferView * bv, int x, int y)
void InsetFormulaMacro::Edit(BufferView * bv, int x, int y,unsigned int button)
{
opened = true;
par = static_cast<MathParInset*>(tmacro->Clone());
InsetFormula::Edit(bv, x, y);
InsetFormula::Edit(bv, x, y, button);
}
@ -193,21 +193,21 @@ void InsetFormulaMacro::InsetUnlock(BufferView * bv)
}
bool InsetFormulaMacro::LocalDispatch(BufferView * bv,
int action, char const * arg)
UpdatableInset::RESULT InsetFormulaMacro::LocalDispatch(BufferView * bv,
int action, string arg)
{
if (action == LFUN_MATH_MACROARG) {
int i = atoi(arg) - 1;
int i = atoi(arg.c_str()) - 1;
if (i >= 0 && i < tmacro->getNoArgs()) {
mathcursor->Insert(tmacro->getMacroPar(i), LM_TC_INSET);
InsetFormula::UpdateLocal(bv);
}
return true;
return DISPATCHED;
}
tmacro->setEditMode(true);
tmacro->Metrics();
bool result = InsetFormula::LocalDispatch(bv, action, arg);
RESULT result = InsetFormula::LocalDispatch(bv, action, arg);
tmacro->setEditMode(false);
return result;

View File

@ -42,7 +42,7 @@ public:
///
int width(Painter &, LyXFont const &) const;
///
void draw(Painter &, LyXFont const &, int baseline, float & x) const;
void draw(Painter &, LyXFont const &, int baseline, float & x);
///
void Read(LyXLex & lex);
///
@ -59,16 +59,18 @@ public:
Inset * Clone() const;
/// what appears in the minibuffer when opening
char const * EditMessage() const {return _("Math macro editor mode");}
const char * EditMessage() const {return _("Math macro editor mode");}
///
void Edit(BufferView *, int x, int y);
void Edit(BufferView *, int x, int y, unsigned int button);
///
void InsetUnlock(BufferView *);
///
bool LocalDispatch(BufferView *, int, char const *);
RESULT LocalDispatch(BufferView *, int, string);
protected:
///
//void UpdateLocal();
private:
///
bool opened;

View File

@ -287,9 +287,9 @@ class MathedInset {
/// In a near future maybe we use a better fonts renderer than X
void drawStr(Painter &, short, int, int, int, byte *, int);
///
///
friend class MathedCursor;
///
///
friend void mathed_init_fonts();
};

View File

@ -371,7 +371,7 @@ void math_insert_symbol(char const * s)
current_view->beforeChange();
current_view->insertInset(new_inset);
// Update(1);//BUG
new_inset->Edit(current_view, 0, 0);
new_inset->Edit(current_view, 0, 0, 0);
new_inset->InsertSymbol(current_view, s);
} else
if (current_view->the_locking_inset->LyxCode() == Inset::MATH_CODE)

View File

@ -370,9 +370,11 @@ void LyXText::draw(Row const * row,
return;
} else if (c == LyXParagraph::META_INSET) {
Inset * tmpinset = row->par->GetInset(pos);
if (tmpinset)
if (tmpinset) {
tmpinset->init(owner_);
tmpinset->draw(owner_->painter(), font,
offset + row->baseline, x);
}
++vpos;
return;
}

View File

@ -348,7 +348,7 @@ void LyXText::ToggleFootnote()
void LyXText::OpenStuff()
{
if (cursor.pos == 0 && cursor.par->bibkey){
cursor.par->bibkey->Edit(owner_, 0, 0);
cursor.par->bibkey->Edit(owner_, 0, 0, 0);
}
else if (cursor.pos < cursor.par->Last()
&& cursor.par->GetChar(cursor.pos) == LyXParagraph::META_INSET
@ -357,7 +357,7 @@ void LyXText::OpenStuff()
->Set(cursor.par->GetInset(cursor.pos)->EditMessage());
if (cursor.par->GetInset(cursor.pos)->Editable() != 2)
SetCursorParUndo();
cursor.par->GetInset(cursor.pos)->Edit(owner_, 0, 0);
cursor.par->GetInset(cursor.pos)->Edit(owner_, 0, 0, 0);
} else {
ToggleFootnote();
}