some small stuff before the meeting begins for real

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@806 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2000-06-08 23:16:16 +00:00
parent d9807f7423
commit 2889b5fd3e
49 changed files with 4047 additions and 3194 deletions

View File

@ -1,3 +1,66 @@
2000-06-09 Lars Gullik Bjønnes <larsbj@lyx.org>
* src/support/LSubstring.C (operator): simplify
* src/lyxtext.h: removed bparams, use buffer_->params instead
* src/lyxrow.h: make Row a real class, move all variables to
private and use accessors.
* src/lyxparagraph.h (getParLanguage): add BufferParamas as
arguament.
(isRightToLeftPar): ditto
(ChangeLanguage): ditto
(isMultiLingual): ditto
(String): ditto
(TeXOnePar): ditto
(SimpleTeXOnePar): ditto
(TeXEnvironment): ditto
(GetEndLabel): ditto
(SetLayout): ditto
(SetOnlyLayout): ditto
(BreakParagraph): ditto
(BreakParagraphConservative): ditto
(GetFontSettings): ditto
(getFont): ditto
(CopyIntoMinibuffer): ditto
(CutIntoMinibuffer): ditto
(PasteParagraph): ditto
(SetPExtraType): ditto
(UnsetPExtraType): ditto
(DocBookContTableRows): ditto
(SimpleDocBookOneTablePar): ditto
(TeXDeeper): ditto
(TeXFootnote): ditto
(SimpleTeXOneTablePar): ditto
(TeXContTableRows): ditto
(SimpleTeXSpecialChars): ditto
* src/lyxcursor.h: make LyXCursor a real class, move all variables
to private and use accessors.
* src/lyx_cb.C: remove char updatetimer, and all code that uses
this, we did not use it anymore and has not been for ages. Just a
waste of cpu cycles.
* src/language.h: make Language a real class, move all variables
to private and use accessors.
* src/BufferView_pimpl.C (Pimpl): use new timer code.
(create_view): remove
(update): some changes for new timer
(cursorToggle): use new timer
(beforeChange): change for new timer
* src/BufferView.h (cursorToggleCB): removed last paramter because
of new timer code.
* src/BufferView.C (C_BufferView_CursorToggleCB): removed
(cursorToggleCB): change because of new timer code
* lib/CREDITS: updated own mailaddress
2000-06-08 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/support/filetools.C (PutEnv): fix the code in case neither

View File

@ -25,7 +25,7 @@
@bGraham Biswell
small bugfixes that were very hard to find
@bLars Gullik Bjønnes
@iE-mail: larsbj@ifi.uio.no
@iE-mail: larsbj@lyx.org
improvements to user interface (menus and
keyhandling) including configurable toolbar,
and a few other minor things. Also current

View File

@ -121,13 +121,14 @@ void BufferView::gotoError()
}
#if 0
extern "C" {
void C_BufferView_CursorToggleCB(FL_OBJECT * ob, long buf)
{
BufferView::cursorToggleCB(ob, buf);
}
}
#endif
void BufferView::enterView()
{
@ -186,21 +187,13 @@ void BufferView::workAreaExpose()
// // Callback for cursor timer
void BufferView::cursorToggleCB(FL_OBJECT * ob, long )
void BufferView::cursorToggleCB(void * ob)
{
BufferView * view = static_cast<BufferView*>(ob->u_vdata);
BufferView * view = static_cast<BufferView*>(ob);
view->pimpl_->cursorToggle();
}
#ifndef XFORMS_CLIPBOARD
void BufferView::workAreaSelectionNotify(Window win, XEvent * event)
{
pimpl_->workAreaSelectionNotify(win, event);
}
#endif
void BufferView::cursorPrevious()
{
pimpl_->cursorPrevious();
@ -333,7 +326,6 @@ void BufferView::center()
}
#ifdef XFORMS_CLIPBOARD
void BufferView::pasteClipboard(bool asPara)
{
pimpl_->pasteClipboard(asPara);
@ -344,4 +336,3 @@ void BufferView::stuffClipboard(string const & stuff) const
{
pimpl_->stuffClipboard(stuff);
}
#endif

View File

@ -24,8 +24,6 @@ class LyXText;
class TeXErrors;
class Buffer;
#define XFORMS_CLIPBOARD 1
///
class BufferView {
public:
@ -197,7 +195,7 @@ public:
void scrollCB(double);
///
static void cursorToggleCB(FL_OBJECT * ob, long);
static void cursorToggleCB(void * ob);
///
void setState();
@ -220,18 +218,12 @@ public:
void enterView();
///
void leaveView();
#ifndef XFORMS_CLIPBOARD
///
void workAreaSelectionNotify(Window win, XEvent * event);
#endif
///
bool ChangeRefs(string const & from, string const & to);
#ifdef XFORMS_CLIPBOARD
///
void pasteClipboard(bool asPara);
///
void stuffClipboard(string const &) const;
#endif
private:
struct Pimpl;
Pimpl * pimpl_;

View File

@ -82,10 +82,10 @@ bool BufferView::insertLyXFile(string const & filen)
if (c == '#') {
lyxerr.debug() << "Will insert file with header" << endl;
res = buffer()->readFile(lex, text->cursor.par);
res = buffer()->readFile(lex, text->cursor.par());
} else {
lyxerr.debug() << "Will insert file without header" << endl;
res = buffer()->readLyXformat2(lex, text->cursor.par);
res = buffer()->readLyXformat2(lex, text->cursor.par());
}
resize();
@ -108,16 +108,16 @@ bool BufferView::removeAutoInsets()
a = true;
if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){
text->RedoParagraphs(cursor,
cursor.par->Next());
cursor.par()->Next());
text->FullRebreak();
}
}
par = par->next;
}
// avoid forbidden cursor positions caused by error removing
if (tmpcursor.pos > tmpcursor.par->Last())
tmpcursor.pos = tmpcursor.par->Last();
text->SetCursorIntern(tmpcursor.par, tmpcursor.pos);
if (tmpcursor.pos() > tmpcursor.par()->Last())
tmpcursor.pos(tmpcursor.par()->Last());
text->SetCursorIntern(tmpcursor.par(), tmpcursor.pos());
return a;
}
@ -164,7 +164,7 @@ void BufferView::insertErrors(TeXErrors & terr)
text->FullRebreak();
}
// Restore the cursor position
text->SetCursorIntern(cursor.par, cursor.pos);
text->SetCursorIntern(cursor.par(), cursor.pos());
}
@ -198,13 +198,15 @@ bool BufferView::insertInset(Inset * inset, string const & lout,
return false;
}
#ifndef NEW_TABULAR
// check for table/list in tables
if (no_table && text->cursor.par->table){
if (no_table && text->cursor.par()->table){
WriteAlert(_("Impossible Operation!"),
_("Cannot insert table/list in table."),
_("Sorry."));
return false;
}
#endif
// not quite sure if we want this...
text->SetCursorParUndo();
@ -216,7 +218,7 @@ bool BufferView::insertInset(Inset * inset, string const & lout,
text->BreakParagraph();
update(-1);
if (text->cursor.par->Last()) {
if (text->cursor.par()->Last()) {
text->CursorLeft();
text->BreakParagraph();
@ -256,7 +258,7 @@ bool BufferView::insertInset(Inset * inset, string const & lout,
// and cannot do this as the cursor is behind the inset and GetInset
// does not return the inset!
if (inset->IsTextInset()) {
if (text->cursor.par->isRightToLeftPar())
if (text->cursor.par()->isRightToLeftPar(buffer()->params))
text->CursorRight();
else
text->CursorLeft();
@ -309,23 +311,23 @@ void BufferView::allFloats(char flag, char figmar)
LyXCursor cursor = text->cursor;
if (!flag && cursor.par->footnoteflag != LyXParagraph::NO_FOOTNOTE
if (!flag && cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE
&& ((figmar
&& cursor.par->footnotekind != LyXParagraph::FOOTNOTE
&& cursor.par->footnotekind != LyXParagraph::MARGIN)
&& cursor.par()->footnotekind != LyXParagraph::FOOTNOTE
&& cursor.par()->footnotekind != LyXParagraph::MARGIN)
|| (!figmar
&& cursor.par->footnotekind != LyXParagraph::FIG
&& cursor.par->footnotekind != LyXParagraph::TAB
&& cursor.par->footnotekind != LyXParagraph::WIDE_FIG
&& cursor.par->footnotekind != LyXParagraph::WIDE_TAB
&& cursor.par->footnotekind != LyXParagraph::ALGORITHM)))
&& cursor.par()->footnotekind != LyXParagraph::FIG
&& cursor.par()->footnotekind != LyXParagraph::TAB
&& cursor.par()->footnotekind != LyXParagraph::WIDE_FIG
&& cursor.par()->footnotekind != LyXParagraph::WIDE_TAB
&& cursor.par()->footnotekind != LyXParagraph::ALGORITHM)))
toggleFloat();
else
beforeChange();
LyXCursor tmpcursor = cursor;
cursor.par = tmpcursor.par->ParFromPos(tmpcursor.pos);
cursor.pos = tmpcursor.par->PositionInParFromPos(tmpcursor.pos);
cursor.par(tmpcursor.par()->ParFromPos(tmpcursor.pos()));
cursor.pos(tmpcursor.par()->PositionInParFromPos(tmpcursor.pos()));
LyXParagraph *par = buffer()->paragraph;
while (par) {
@ -382,7 +384,7 @@ void BufferView::allFloats(char flag, char figmar)
par = par->next;
}
text->SetCursorIntern(cursor.par, cursor.pos);
text->SetCursorIntern(cursor.par(), cursor.pos());
redraw();
fitCursor();
//updateScrollbar();
@ -621,11 +623,11 @@ void BufferView::gotoNote()
LyXCursor tmp;
if (!text->GotoNextNote()) {
if (text->cursor.pos
|| text->cursor.par != text->FirstParagraph()) {
if (text->cursor.pos()
|| text->cursor.par() != text->FirstParagraph()) {
tmp = text->cursor;
text->cursor.par = text->FirstParagraph();
text->cursor.pos = 0;
text->cursor.par(text->FirstParagraph());
text->cursor.pos(0);
if (!text->GotoNextNote()) {
text->cursor = tmp;
owner()->getMiniBuffer()->Set(_("No more notes"));
@ -645,8 +647,8 @@ void BufferView::insertCorrectQuote()
{
char c;
if (text->cursor.pos)
c = text->cursor.par->GetChar(text->cursor.pos - 1);
if (text->cursor.pos())
c = text->cursor.par()->GetChar(text->cursor.pos() - 1);
else
c = ' ';
@ -734,13 +736,14 @@ void BufferView::showLockedInsetCursor(long x, long y, int asc, int desc)
{
if (the_locking_inset && available()) {
LyXCursor cursor = text->cursor;
if ((cursor.pos - 1 >= 0) &&
(cursor.par->GetChar(cursor.pos-1) ==
if ((cursor.pos() - 1 >= 0) &&
(cursor.par()->GetChar(cursor.pos() - 1) ==
LyXParagraph::META_INSET) &&
(cursor.par->GetInset(cursor.pos - 1) ==
(cursor.par()->GetInset(cursor.pos() - 1) ==
the_locking_inset->GetLockingInset()))
text->SetCursor(cursor, cursor.par, cursor.pos-1);
y += cursor.y + the_locking_inset->InsetInInsetY();
text->SetCursor(cursor,
cursor.par(), cursor.pos() - 1);
y += cursor.y() + the_locking_inset->InsetInInsetY();
pimpl_->screen->ShowManualCursor(x, y, asc, desc,
LyXScreen::BAR_SHAPE);
}
@ -758,7 +761,7 @@ void BufferView::hideLockedInsetCursor()
void BufferView::fitLockedInsetCursor(long x, long y, int asc, int desc)
{
if (the_locking_inset && available()){
y += text->cursor.y + the_locking_inset->InsetInInsetY();
y += text->cursor.y() + the_locking_inset->InsetInInsetY();
if (pimpl_->screen->FitManualCursor(x, y, asc, desc))
updateScrollbar();
}
@ -788,10 +791,10 @@ void BufferView::lockedInsetStoreUndo(Undo::undo_kind kind)
if (kind == Undo::EDIT) // in this case insets would not be stored!
kind = Undo::FINISH;
text->SetUndo(kind,
text->cursor.par->
ParFromPos(text->cursor.pos)->previous,
text->cursor.par->
ParFromPos(text->cursor.pos)->next);
text->cursor.par()->
ParFromPos(text->cursor.pos())->previous,
text->cursor.par()->
ParFromPos(text->cursor.pos())->next);
}
@ -849,8 +852,8 @@ bool BufferView::ChangeRefs(string const & from, string const & to)
LyXParagraph * par = buffer()->paragraph;
LyXCursor cursor = text->cursor;
LyXCursor tmpcursor = cursor;
cursor.par = tmpcursor.par->ParFromPos(tmpcursor.pos);
cursor.pos = tmpcursor.par->PositionInParFromPos(tmpcursor.pos);
cursor.par(tmpcursor.par()->ParFromPos(tmpcursor.pos()));
cursor.pos(tmpcursor.par()->PositionInParFromPos(tmpcursor.pos()));
while (par) {
bool flag2 = false;
@ -871,12 +874,12 @@ bool BufferView::ChangeRefs(string const & from, string const & to)
// care about footnotes
text->SetCursorIntern(par, 0);
text->RedoParagraphs(text->cursor,
text->cursor.par->Next());
text->cursor.par()->Next());
text->FullRebreak();
}
}
par = par->next;
}
text->SetCursorIntern(cursor.par, cursor.pos);
text->SetCursorIntern(cursor.par(), cursor.pos());
return flag;
}

View File

@ -40,11 +40,13 @@ extern char ascii_type;
extern void sigchldhandler(pid_t pid, int * status);
extern int bibitemMaxWidth(Painter &, LyXFont const &);
#if 0
extern void FreeUpdateTimer();
#endif
#if 0
extern "C"
void C_BufferView_CursorToggleCB(FL_OBJECT * ob, long buf);
#endif
static inline
void waitForX()
@ -70,15 +72,23 @@ void SetXtermCursor(Window win)
BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o,
int xpos, int ypos, int width, int height)
: bv_(b), owner_(o)
: bv_(b), owner_(o), cursor_timeout(400)
{
buffer_ = 0;
workarea = new WorkArea(bv_, xpos, ypos, width, height);
screen = 0;
#if 0
timer_cursor = 0;
create_view();
#else
cursor_timeout.callback(BufferView::cursorToggleCB, bv_);
#endif
current_scrollbar_value = 0;
#if 0
fl_set_timer(timer_cursor, 0.4);
#else
cursor_timeout.start();
#endif
workarea->setFocus();
work_area_focus = true;
lyx_focus = false;
@ -222,12 +232,12 @@ int BufferView::Pimpl::resizeCurrentBuffer()
owner_->getMiniBuffer()->Set(_("Formatting document..."));
if (bv_->text) {
par = bv_->text->cursor.par;
pos = bv_->text->cursor.pos;
selstartpar = bv_->text->sel_start_cursor.par;
selstartpos = bv_->text->sel_start_cursor.pos;
selendpar = bv_->text->sel_end_cursor.par;
selendpos = bv_->text->sel_end_cursor.pos;
par = bv_->text->cursor.par();
pos = bv_->text->cursor.pos();
selstartpar = bv_->text->sel_start_cursor.par();
selstartpos = bv_->text->sel_start_cursor.pos();
selendpar = bv_->text->sel_end_cursor.par();
selendpos = bv_->text->sel_end_cursor.pos();
selection = bv_->text->selection;
mark_set = bv_->text->mark_set;
delete bv_->text;
@ -296,11 +306,11 @@ void BufferView::Pimpl::gotoError()
LyXCursor tmp;
if (!bv_->text->GotoNextError()) {
if (bv_->text->cursor.pos
|| bv_->text->cursor.par != bv_->text->FirstParagraph()) {
if (bv_->text->cursor.pos()
|| bv_->text->cursor.par() != bv_->text->FirstParagraph()) {
tmp = bv_->text->cursor;
bv_->text->cursor.par = bv_->text->FirstParagraph();
bv_->text->cursor.pos = 0;
bv_->text->cursor.par(bv_->text->FirstParagraph());
bv_->text->cursor.pos(0);
if (!bv_->text->GotoNextError()) {
bv_->text->cursor = tmp;
owner_->getMiniBuffer()
@ -325,6 +335,7 @@ void BufferView::Pimpl::updateScreen()
}
#if 0
void BufferView::Pimpl::create_view()
{
FL_OBJECT * obj;
@ -339,6 +350,7 @@ void BufferView::Pimpl::create_view()
fl_set_object_callback(obj, C_BufferView_CursorToggleCB, 0);
obj->u_vdata = bv_;
}
#endif
void BufferView::Pimpl::updateScrollbar()
@ -422,11 +434,11 @@ void BufferView::Pimpl::scrollCB(double value)
LyXText * vbt = bv_->text;
unsigned int height = vbt->DefaultHeight();
if (vbt->cursor.y < screen->first + height) {
if (vbt->cursor.y() < screen->first + height) {
vbt->SetCursorFromCoordinates(0,
screen->first +
height);
} else if (vbt->cursor.y >
} else if (vbt->cursor.y() >
screen->first + workarea->height() - height) {
vbt->SetCursorFromCoordinates(0,
screen->first +
@ -509,8 +521,8 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
LyXCursor cursor = bv_->text->cursor;
bv_->the_locking_inset->
InsetMotionNotify(bv_,
x - cursor.x,
y - cursor.y + screen->first,
x - cursor.x(),
y - cursor.y() + screen->first,
state);
return;
}
@ -576,10 +588,11 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
if (!inset_hit)
selection_possible = true;
screen->HideCursor();
#ifndef NEW_TABULAR
// Right button mouse click on a table
if (button == 3 &&
(bv_->text->cursor.par->table ||
(bv_->text->cursor.par()->table ||
bv_->text->MouseHitInTable(xpos, ypos + screen->first))) {
// Set the cursor to the press-position
bv_->text->SetCursorFromCoordinates(xpos, ypos + screen->first);
@ -587,7 +600,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
// Only show the table popup if the hit is in
// the table, too
if (!bv_->text->HitInTable(bv_->text->cursor.row, xpos))
if (!bv_->text->HitInTable(bv_->text->cursor.row(), xpos))
doit = false;
// Hit above or below the table?
@ -612,6 +625,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
return;
}
}
#endif
int screen_first = screen->first;
@ -653,7 +667,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
bv_->text->SetCursorFromCoordinates(xpos, ypos + screen_first);
bv_->text->FinishUndo();
bv_->text->sel_cursor = bv_->text->cursor;
bv_->text->cursor.x_fix = bv_->text->cursor.x;
bv_->text->cursor.x_fix(bv_->text->cursor.x());
owner_->updateLayoutChoice();
if (fitCursor()) {
@ -750,17 +764,19 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
}
selection_possible = false;
if (bv_->text->cursor.par->table) {
#ifndef NEW_TABULAR
if (bv_->text->cursor.par()->table) {
int cell = bv_->text->
NumberOfCell(bv_->text->cursor.par,
bv_->text->cursor.pos);
if (bv_->text->cursor.par->table->IsContRow(cell) &&
bv_->text->cursor.par->table->
CellHasContRow(bv_->text->cursor.par->table->
NumberOfCell(bv_->text->cursor.par(),
bv_->text->cursor.pos());
if (bv_->text->cursor.par()->table->IsContRow(cell) &&
bv_->text->cursor.par()->table->
CellHasContRow(bv_->text->cursor.par()->table->
GetCellAbove(cell))<0) {
bv_->text->CursorUp();
}
}
#endif
if (button >= 2) return;
@ -807,10 +823,10 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
if (bv_->text) {
bool hit = false;
char c = ' ';
if (bv_->text->cursor.pos <
bv_->text->cursor.par->Last()) {
c = bv_->text->cursor.par->
GetChar(bv_->text->cursor.pos);
if (bv_->text->cursor.pos() <
bv_->text->cursor.par()->Last()) {
c = bv_->text->cursor.par()->
GetChar(bv_->text->cursor.pos());
}
if (c == LyXParagraph::META_FOOTNOTE
|| c == LyXParagraph::META_MARGIN
@ -820,9 +836,9 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
|| c == LyXParagraph::META_WIDE_TAB
|| c == LyXParagraph::META_ALGORITHM){
hit = true;
} else if (bv_->text->cursor.pos - 1 >= 0) {
c = bv_->text->cursor.par->
GetChar(bv_->text->cursor.pos - 1);
} else if (bv_->text->cursor.pos() - 1 >= 0) {
c = bv_->text->cursor.par()->
GetChar(bv_->text->cursor.pos() - 1);
if (c == LyXParagraph::META_FOOTNOTE
|| c == LyXParagraph::META_MARGIN
|| c == LyXParagraph::META_FIG
@ -843,10 +859,10 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
}
// Do we want to close a float? (click on the float-label)
if (bv_->text->cursor.row->par->footnoteflag ==
if (bv_->text->cursor.row()->par()->footnoteflag ==
LyXParagraph::OPEN_FOOTNOTE
&& bv_->text->cursor.row->previous &&
bv_->text->cursor.row->previous->par->
&& bv_->text->cursor.row()->previous() &&
bv_->text->cursor.row()->previous()->par()->
footnoteflag != LyXParagraph::OPEN_FOOTNOTE){
LyXFont font(LyXFont::ALL_SANE);
font.setSize(LyXFont::SIZE_FOOTNOTE);
@ -857,10 +873,10 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
unsigned int screen_first = screen->first;
if (x < box_x
&& y + screen_first > bv_->text->cursor.y -
bv_->text->cursor.row->baseline
&& y + screen_first < bv_->text->cursor.y -
bv_->text->cursor.row->baseline
&& y + screen_first > bv_->text->cursor.y() -
bv_->text->cursor.row()->baseline()
&& y + screen_first < bv_->text->cursor.y() -
bv_->text->cursor.row()->baseline()
+ lyxfont::maxAscent(font) * 1.2 + lyxfont::maxDescent(font) * 1.2) {
bv_->toggleFloat();
selection_possible = false;
@ -869,12 +885,12 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
}
// Maybe we want to edit a bibitem ale970302
if (bv_->text->cursor.par->bibkey && x < 20 +
if (bv_->text->cursor.par()->bibkey && x < 20 +
bibitemMaxWidth(bv_->painter(),
textclasslist
.TextClass(buffer_->
params.textclass).defaultfont())) {
bv_->text->cursor.par->bibkey->Edit(bv_, 0, 0, 0);
bv_->text->cursor.par()->bibkey->Edit(bv_, 0, 0, 0);
}
return;
@ -898,67 +914,67 @@ Inset * BufferView::Pimpl::checkInsetHit(int & x, int & y,
bv_->text->SetCursorFromCoordinates(cursor, x, y_tmp);
#if 0 // Are you planning to use this Jürgen? (Lgb)
bool move_cursor = ((cursor.par != bv_->text->cursor.par) ||
(cursor.pos != bv_->text->cursor.pos));
(cursor.pos != bv_->text->cursor.pos()));
#endif
if (cursor.pos < cursor.par->Last()
&& cursor.par->GetChar(cursor.pos) == LyXParagraph::META_INSET
&& cursor.par->GetInset(cursor.pos)
&& cursor.par->GetInset(cursor.pos)->Editable()) {
if (cursor.pos() < cursor.par()->Last()
&& cursor.par()->GetChar(cursor.pos()) == LyXParagraph::META_INSET
&& cursor.par()->GetInset(cursor.pos())
&& cursor.par()->GetInset(cursor.pos())->Editable()) {
// Check whether the inset really was hit
Inset * tmpinset = cursor.par->GetInset(cursor.pos);
LyXFont font = bv_->text->GetFont(cursor.par, cursor.pos);
Inset * tmpinset = cursor.par()->GetInset(cursor.pos());
LyXFont font = bv_->text->GetFont(cursor.par(), cursor.pos());
bool is_rtl = font.isVisibleRightToLeft();
int start_x, end_x;
if (is_rtl) {
start_x = cursor.x - tmpinset->width(bv_->painter(), font);
end_x = cursor.x;
start_x = cursor.x() - tmpinset->width(bv_->painter(), font);
end_x = cursor.x();
} else {
start_x = cursor.x;
end_x = cursor.x + tmpinset->width(bv_->painter(), font);
start_x = cursor.x();
end_x = cursor.x() + tmpinset->width(bv_->painter(), font);
}
if (x > start_x && x < end_x
&& y_tmp > cursor.y - tmpinset->ascent(bv_->painter(), font)
&& y_tmp < cursor.y + tmpinset->descent(bv_->painter(), font)) {
&& y_tmp > cursor.y() - tmpinset->ascent(bv_->painter(), font)
&& y_tmp < cursor.y() + tmpinset->descent(bv_->painter(), font)) {
#if 0
if (move_cursor && (tmpinset != bv_->the_locking_inset))
#endif
bv_->text->SetCursor(cursor.par,cursor.pos,true);
bv_->text->SetCursor(cursor.par(),cursor.pos(),true);
x = x - start_x;
// The origin of an inset is on the baseline
y = y_tmp - (bv_->text->cursor.y);
y = y_tmp - (bv_->text->cursor.y());
return tmpinset;
}
}
if ((cursor.pos - 1 >= 0) &&
(cursor.par->GetChar(cursor.pos-1) == LyXParagraph::META_INSET) &&
(cursor.par->GetInset(cursor.pos - 1)) &&
(cursor.par->GetInset(cursor.pos - 1)->Editable())) {
Inset * tmpinset = cursor.par->GetInset(cursor.pos-1);
LyXFont font = bv_->text->GetFont(cursor.par, cursor.pos-1);
if ((cursor.pos() - 1 >= 0) &&
(cursor.par()->GetChar(cursor.pos()-1) == LyXParagraph::META_INSET) &&
(cursor.par()->GetInset(cursor.pos() - 1)) &&
(cursor.par()->GetInset(cursor.pos() - 1)->Editable())) {
Inset * tmpinset = cursor.par()->GetInset(cursor.pos()-1);
LyXFont font = bv_->text->GetFont(cursor.par(), cursor.pos()-1);
bool is_rtl = font.isVisibleRightToLeft();
int start_x, end_x;
if (!is_rtl) {
start_x = cursor.x - tmpinset->width(bv_->painter(), font);
end_x = cursor.x;
start_x = cursor.x() - tmpinset->width(bv_->painter(), font);
end_x = cursor.x();
} else {
start_x = cursor.x;
end_x = cursor.x + tmpinset->width(bv_->painter(), font);
start_x = cursor.x();
end_x = cursor.x() + tmpinset->width(bv_->painter(), font);
}
if (x > start_x && x < end_x
&& y_tmp > cursor.y - tmpinset->ascent(bv_->painter(), font)
&& y_tmp < cursor.y + tmpinset->descent(bv_->painter(), font)) {
&& y_tmp > cursor.y() - tmpinset->ascent(bv_->painter(), font)
&& y_tmp < cursor.y() + tmpinset->descent(bv_->painter(), font)) {
#if 0
if (move_cursor && (tmpinset != bv_->the_locking_inset))
#endif
bv_->text->SetCursor(cursor.par,cursor.pos-1,true);
bv_->text->SetCursor(cursor.par(),cursor.pos()-1,true);
x = x - start_x;
// The origin of an inset is on the baseline
y = y_tmp - (bv_->text->cursor.y);
y = y_tmp - (bv_->text->cursor.y());
return tmpinset;
}
}
@ -1023,83 +1039,6 @@ void BufferView::Pimpl::workAreaExpose()
}
#ifndef XFORMS_CLIPBOARD
static
string fromClipboard(Window win, XEvent * event)
{
string strret;
if (event->xselection.type == XA_STRING
&& event->xselection.property) {
Atom tmpatom;
unsigned long ul1;
unsigned long ul2;
unsigned char * uc = 0;
int tmpint;
if (XGetWindowProperty(
event->xselection.display, // display
win, // w
event->xselection.property, // property
0, // long_offset
0, // logn_length
False, // delete
XA_STRING, // req_type
&tmpatom, // actual_type_return
&tmpint, // actual_format_return
&ul1,
&ul2,
&uc // prop_return
) != Success) {
return strret;
}
if (uc) {
free(uc);
uc = 0;
}
if (XGetWindowProperty(
event->xselection.display, // display
win, // w
event->xselection.property, // property
0, // long_offset
ul2/4+1, // long_length
True, // delete
XA_STRING, // req_type
&tmpatom, // actual_type_return
&tmpint, // actual_format_return
&ul1, // nitems_return
&ul2, // bytes_after_return
&uc // prop_return */
) != Success) {
return strret;
}
if (uc) {
strret = reinterpret_cast<char*>(uc);
free(uc); // yes free!
uc = 0;
}
}
return strret;
}
void BufferView::Pimpl::workAreaSelectionNotify(Window win, XEvent * event)
{
if (buffer_ == 0) return;
screen->HideCursor();
bv_->beforeChange();
string clb = fromClipboard(win, event);
if (!clb.empty()) {
if (!ascii_type)
bv_->text->InsertStringA(clb);
else
bv_->text->InsertStringB(clb);
update(1);
}
}
#endif
void BufferView::Pimpl::update()
{
if (screen) screen->Update();
@ -1149,8 +1088,9 @@ void BufferView::Pimpl::update(signed char f)
if (!bv_->text->selection && f > -3)
bv_->text->sel_cursor = bv_->text->cursor;
#if 0
FreeUpdateTimer();
#endif
bv_->text->FullRebreak();
update();
@ -1173,8 +1113,11 @@ void BufferView::Pimpl::update(signed char f)
if (!bv_->text->selection && (f & SELECT))
bv_->text->sel_cursor = bv_->text->cursor;
#if 1
//owner_->update_timeout.stop();
#else
FreeUpdateTimer();
#endif
bv_->text->FullRebreak();
update();
@ -1293,7 +1236,11 @@ void BufferView::Pimpl::cursorToggle()
}
set_timer_and_return:
#if 1
cursor_timeout.restart();
#else
fl_set_timer(timer_cursor, 0.4);
#endif
skip_timer:
return;
}
@ -1301,20 +1248,20 @@ void BufferView::Pimpl::cursorToggle()
void BufferView::Pimpl::cursorPrevious()
{
if (!bv_->text->cursor.row->previous) return;
if (!bv_->text->cursor.row()->previous()) return;
long y = screen->first;
Row * cursorrow = bv_->text->cursor.row;
bv_->text->SetCursorFromCoordinates(bv_->text->cursor.x_fix, y);
Row * cursorrow = bv_->text->cursor.row();
bv_->text->SetCursorFromCoordinates(bv_->text->cursor.x_fix(), y);
bv_->text->FinishUndo();
// This is to allow jumping over large insets
if ((cursorrow == bv_->text->cursor.row))
if ((cursorrow == bv_->text->cursor.row()))
bv_->text->CursorUp();
if (bv_->text->cursor.row->height < workarea->height())
screen->Draw(bv_->text->cursor.y
- bv_->text->cursor.row->baseline
+ bv_->text->cursor.row->height
if (bv_->text->cursor.row()->height() < workarea->height())
screen->Draw(bv_->text->cursor.y()
- bv_->text->cursor.row()->baseline()
+ bv_->text->cursor.row()->height()
- workarea->height() + 1 );
updateScrollbar();
}
@ -1322,21 +1269,21 @@ void BufferView::Pimpl::cursorPrevious()
void BufferView::Pimpl::cursorNext()
{
if (!bv_->text->cursor.row->next) return;
if (!bv_->text->cursor.row()->next()) return;
long y = screen->first;
bv_->text->GetRowNearY(y);
Row * cursorrow = bv_->text->cursor.row;
bv_->text->SetCursorFromCoordinates(bv_->text->cursor.x_fix, y
Row * cursorrow = bv_->text->cursor.row();
bv_->text->SetCursorFromCoordinates(bv_->text->cursor.x_fix(), y
+ workarea->height());
bv_->text->FinishUndo();
// This is to allow jumping over large insets
if ((cursorrow == bv_->text->cursor.row))
if ((cursorrow == bv_->text->cursor.row()))
bv_->text->CursorDown();
if (bv_->text->cursor.row->height < workarea->height())
screen->Draw(bv_->text->cursor.y
- bv_->text->cursor.row->baseline);
if (bv_->text->cursor.row()->height() < workarea->height())
screen->Draw(bv_->text->cursor.y()
- bv_->text->cursor.row()->baseline());
updateScrollbar();
}
@ -1352,15 +1299,20 @@ void BufferView::Pimpl::beforeChange()
{
toggleSelection();
bv_->text->ClearSelection();
#if 1
// CHECK
//owner_->update_timeout.stop();
#else
FreeUpdateTimer();
#endif
}
void BufferView::Pimpl::savePosition()
{
backstack.push(buffer_->fileName(),
bv_->text->cursor.x,
bv_->text->cursor.y);
bv_->text->cursor.x(),
bv_->text->cursor.y());
}
@ -1487,8 +1439,8 @@ void BufferView::Pimpl::toggleToggle()
void BufferView::Pimpl::center()
{
beforeChange();
if (bv_->text->cursor.y > workarea->height() / 2) {
screen->Draw(bv_->text->cursor.y - workarea->height() / 2);
if (bv_->text->cursor.y() > workarea->height() / 2) {
screen->Draw(bv_->text->cursor.y() - workarea->height() / 2);
} else {
screen->Draw(0);
}
@ -1497,7 +1449,6 @@ void BufferView::Pimpl::center()
}
#ifdef XFORMS_CLIPBOARD
void BufferView::Pimpl::pasteClipboard(bool asPara)
{
if (buffer_ == 0) return;
@ -1522,4 +1473,3 @@ void BufferView::Pimpl::stuffClipboard(string const & stuff) const
{
workarea->putClipboard(stuff);
}
#endif

View File

@ -6,6 +6,7 @@
#include "BufferView.h"
#include "UpdateInset.h"
#include "BackStack.h"
#include "Timeout.h"
#ifdef __GNUG__
#pragma interface
@ -48,8 +49,10 @@ struct BufferView::Pimpl {
void updateScrollbar();
///
void scrollCB(double value);
#if 0
///
void create_view();
#endif
///
Inset * checkInsetHit(int & x, int & y, unsigned int button);
///
@ -62,10 +65,6 @@ struct BufferView::Pimpl {
void workAreaButtonPress(int x, int y, unsigned int button);
///
void workAreaButtonRelease(int x, int y, unsigned int button);
#ifndef XFORMS_CLIPBOARD
///
void workAreaSelectionNotify(Window win, XEvent * event);
#endif
///
void doubleClick(int x, int y, unsigned int button);
///
@ -132,8 +131,12 @@ struct BufferView::Pimpl {
bool work_area_focus;
///
FL_OBJECT * figinset_canvas;
#if 0
///
FL_OBJECT * timer_cursor;
#else
Timeout cursor_timeout;
#endif
///
BackStack backstack;
///
@ -142,12 +145,10 @@ struct BufferView::Pimpl {
WorkArea * workarea;
///
UpdateInset updatelist;
#ifdef XFORMS_CLIPBOARD
///
void pasteClipboard(bool asPara);
///
void stuffClipboard(string const &) const;
#endif
private:
bool using_xterm_cursor;
};

View File

@ -10,9 +10,12 @@
#include <config.h>
#include "CutAndPaste.h"
#include "BufferView.h"
#include "buffer.h"
#include "lyxparagraph.h"
#include "insets/inseterror.h"
#include "lyx_gui_misc.h"
#include "lyxcursor.h"
#ifdef __GNUG__
#pragma implementation
@ -20,6 +23,8 @@
using std::pair;
extern BufferView * current_view;
// Jürgen, note that this means that you cannot currently have a list
// of selections cut/copied. So IMHO later we should have a
// list/vector/deque that we could store
@ -81,23 +86,30 @@ bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar,
if (end > startpar->Last())
end = startpar->Last();
for (; i < end; ++i) {
startpar->CopyIntoMinibuffer(start);
startpar->CopyIntoMinibuffer(current_view->buffer()->params,
start);
#ifndef NEW_TABULAR
/* table stuff -- begin */
if (startpar->table && startpar->IsNewline(start)) {
++start;
} else {
/* table stuff -- end */
#endif
startpar->Erase(start);
#ifndef NEW_TABULAR
}
#endif
buf->InsertFromMinibuffer(buf->Last());
}
} else {
// more than one paragraph
(*endpar)->BreakParagraphConservative(end);
(*endpar)->BreakParagraphConservative(current_view->buffer()->params,
end);
*endpar = (*endpar)->Next();
end = 0;
startpar->BreakParagraphConservative(start);
startpar->BreakParagraphConservative(current_view->buffer()->params,
start);
// store the selection
buf = startpar->ParFromPos(start)->next;
@ -126,7 +138,7 @@ bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar,
startpar->Next()->StripLeadingSpaces(textclass);
if (startpar->FirstPhysicalPar()->HasSameLayout(startpar->Next()) ||
!startpar->Next()->Last()) {
startpar->ParFromPos(start)->PasteParagraph();
startpar->ParFromPos(start)->PasteParagraph(current_view->buffer()->params);
(*endpar) = startpar; // this because endpar gets deleted here!
}
}
@ -152,7 +164,7 @@ bool CutAndPaste::copySelection(LyXParagraph * startpar, LyXParagraph * endpar,
if (end > startpar->Last())
end = startpar->Last();
for (; i < end; ++i) {
startpar->CopyIntoMinibuffer(i);
startpar->CopyIntoMinibuffer(current_view->buffer()->params, i);
buf->InsertFromMinibuffer(buf->Last());
}
} else {
@ -213,6 +225,7 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar,
if (!buf->next) {
// only within a paragraph
tmpbuf = buf->Clone();
#ifndef NEW_TABULAR
/* table stuff -- begin */
bool table_too_small = false;
if ((*par)->table) {
@ -233,7 +246,7 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar,
if (!tmppos && buf->IsLineSeparator(0)) {
buf->Erase(0);
} else {
buf->CutIntoMinibuffer(0);
buf->CutIntoMinibuffer(current_view->buffer()->params, 0);
buf->Erase(0);
if (tmppar->InsertFromMinibuffer(tmppos))
++tmppos;
@ -242,6 +255,7 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar,
}
} else {
/* table stuff -- end */
#endif
// Some provisions should be done here for checking
// if we are inserting at the beginning of a
// paragraph. If there are a space at the beginning
@ -255,13 +269,15 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar,
if (!tmppos && buf->IsLineSeparator(0)) {
buf->Erase(0);
} else {
buf->CutIntoMinibuffer(0);
buf->CutIntoMinibuffer(current_view->buffer()->params, 0);
buf->Erase(0);
if (tmppar->InsertFromMinibuffer(tmppos))
++tmppos;
}
}
#ifndef NEW_TABULAR
}
#endif
delete buf;
buf = tmpbuf;
*endpar = tmppar->Next();
@ -305,7 +321,8 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar,
// open the paragraph for inserting the buf
// if necessary
if (((*par)->Last() > pos) || !(*par)->Next()) {
(*par)->BreakParagraphConservative(pos);
(*par)->BreakParagraphConservative(current_view->buffer()->params,
pos);
paste_the_end = true;
}
@ -324,22 +341,22 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar,
if ((*par)->ParFromPos(pos)->Next() == lastbuffer)
lastbuffer = *par;
(*par)->ParFromPos(pos)->PasteParagraph();
(*par)->ParFromPos(pos)->PasteParagraph(current_view->buffer()->params);
// store the new cursor position
*par = lastbuffer;
pos = lastbuffer->Last();
pos = lastbuffer->Last();
// maybe some pasting
if (lastbuffer->Next() && paste_the_end) {
if (lastbuffer->Next()->HasSameLayout(lastbuffer)) {
lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph();
lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params);
} else if (!lastbuffer->Next()->Last()) {
lastbuffer->Next()->MakeSameLayout(lastbuffer);
lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph();
lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params);
} else if (!lastbuffer->Last()) {
lastbuffer->MakeSameLayout(lastbuffer->next);
lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph();
lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params);
} else
lastbuffer->Next()->StripLeadingSpaces(tc);
}
@ -425,6 +442,7 @@ bool CutAndPaste::checkPastePossible(LyXParagraph * par, int) const
return false;
}
}
#ifndef NEW_TABULAR
/* table stuff -- begin */
if (par->table) {
if (buf->next) {
@ -435,5 +453,6 @@ bool CutAndPaste::checkPastePossible(LyXParagraph * par, int) const
}
}
/* table stuff -- end */
#endif
return true;
}

View File

@ -24,7 +24,8 @@ class CutAndPaste {
public:
///
bool cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar,
int start, int & end, char tc, bool doclear = false);
int start, int & end,
char tc, bool doclear = false);
///
bool copySelection(LyXParagraph * startpar, LyXParagraph * endpar,
int start, int end, char tc);

View File

@ -648,7 +648,7 @@ void LaTeX::deplog(DepTable & head)
}
lyxerr[Debug::DEPEND] << "Found file: "
<< foundfile << endl;
<< foundfile << endl;
// Ok now we found a file.
// Now we should make sure that this is a file that we can
@ -673,22 +673,25 @@ void LaTeX::deplog(DepTable & head)
// insert it into head
if (FileInfo(OnlyFilename(foundfile)).exist()) {
if (suffixIs(foundfile, ".aux")) {
lyxerr[Debug::DEPEND] << "We don't want "
<< OnlyFilename(foundfile)
<< " in the dep file"
<< endl;
lyxerr[Debug::DEPEND]
<< "We don't want "
<< OnlyFilename(foundfile)
<< " in the dep file"
<< endl;
} else if (suffixIs(foundfile, ".tex")) {
// This is a tex file generated by LyX
// and latex is not likely to change this
// during its runs.
lyxerr[Debug::DEPEND] << "Tmpdir TeX file: "
<< OnlyFilename(foundfile)
<< endl;
lyxerr[Debug::DEPEND]
<< "Tmpdir TeX file: "
<< OnlyFilename(foundfile)
<< endl;
head.insert(foundfile, true);
} else {
lyxerr[Debug::DEPEND] << "In tmpdir file:"
<< OnlyFilename(foundfile)
<< endl;
lyxerr[Debug::DEPEND]
<< "In tmpdir file:"
<< OnlyFilename(foundfile)
<< endl;
head.insert(OnlyFilename(foundfile));
}
continue;

View File

@ -40,7 +40,9 @@ using std::endl;
extern FD_form_document * fd_form_document;
extern void AutoSave(BufferView *);
#if 0
extern char updatetimer;
#endif
extern void QuitLyX();
LyXTextClass::size_type current_layout = 0;
@ -50,6 +52,7 @@ BufferView * current_view;
extern "C" int C_LyXView_atCloseMainFormCB(FL_FORM *, void *);
LyXView::LyXView(int width, int height)
// : update_timeout(300)
{
create_form_form_main(width, height);
fl_set_form_atclose(form_, C_LyXView_atCloseMainFormCB, 0);
@ -134,28 +137,33 @@ Intl * LyXView::getIntl() const
// Callback for update timer
void LyXView::UpdateTimerCB(FL_OBJECT * ob, long)
void LyXView::UpdateTimerCB(void * ob)
{
LyXView * view = static_cast<LyXView*>(ob->u_vdata);
LyXView * view = static_cast<LyXView*>(ob);
if (!view->view()->available())
return;
#if 0
if (!updatetimer)
return;
#endif
view->view()->hideCursor();
view->view()->update(-2);
#if 0
/* This update can happen, even when the work area has lost
* the focus. So suppress the cursor in that case */
updatetimer = 0;
#endif
}
#if 0
// Wrapper for the above
extern "C" void C_LyXView_UpdateTimerCB(FL_OBJECT * ob, long data)
{
LyXView::UpdateTimerCB(ob, data);
}
#endif
// Callback for autosave timer
@ -168,18 +176,24 @@ void LyXView::AutoSave()
// Wrapper for the above
extern "C" void C_LyXView_AutosaveTimerCB(FL_OBJECT * ob, long)
{
LyXView * view = static_cast<LyXView*>(ob->u_vdata);
view->AutoSave();
extern "C" {
static
void C_LyXView_AutosaveTimerCB(void * ob)
{
LyXView * view = static_cast<LyXView*>(ob);
view->AutoSave();
}
}
/// Reset autosave timer
void LyXView::resetAutosaveTimer()
{
if (lyxrc.autosave)
#if 1
autosave_timeout.restart();
#else
fl_set_timer(form_main_->timer_autosave, lyxrc.autosave);
#endif
}
@ -272,19 +286,26 @@ void LyXView::create_form_form_main(int width, int height)
//
// TIMERS
//
#if 0
// timer_autosave
fdui->timer_autosave = obj = fl_add_timer(FL_HIDDEN_TIMER,
0, 0, 0, 0, "Timer");
obj->u_vdata = this;
fl_set_object_callback(obj, C_LyXView_AutosaveTimerCB, 0);
#else
autosave_timeout.callback(C_LyXView_AutosaveTimerCB, this);
#endif
#if 0
// timer_update
fdui->timer_update = obj = fl_add_timer(FL_HIDDEN_TIMER,
0, 0, 0, 0, "Timer");
fl_set_object_callback(obj, C_LyXView_UpdateTimerCB, 0);
obj->u_vdata = this;
#else
//update_timeout.callback(LyXView::UpdateTimerCB, this);
#endif
//
// Misc
//
@ -320,8 +341,12 @@ void LyXView::init()
// Start autosave timer
if (lyxrc.autosave)
#if 0
fl_set_timer(form_main_->timer_autosave, lyxrc.autosave);
#else
autosave_timeout.setTimeout(lyxrc.autosave * 1000);
autosave_timeout.start();
#endif
// Install the raw callback for keyboard events
fl_register_raw_callback(form_,
@ -368,7 +393,7 @@ void LyXView::updateLayoutChoice()
// we need to do this.
toolbar->combox->Redraw();
LyXTextClass::size_type layout = bufferview->text->cursor.par->GetLayout();
LyXTextClass::size_type layout = bufferview->text->cursor.par()->GetLayout();
if (layout != current_layout){
toolbar->combox->select(layout + 1);

View File

@ -18,6 +18,8 @@
#include FORMS_H_LOCATION
#include "Timeout.h"
class LyXFunc;
class Toolbar;
class MiniBuffer;
@ -30,14 +32,20 @@ class BufferView;
struct FD_form_main {
///
FL_FORM * form_main;
#if 0
///
FL_OBJECT * timer_autosave;
#endif
#if 0
///
FL_OBJECT * timer_update;
#endif
#if 0
///
void * vdata;
///
long ldata;
#endif
};
@ -130,15 +138,20 @@ public:
/// A callback
void AutoSave();
/// A callback
static void UpdateTimerCB(FL_OBJECT *, long);
static void UpdateTimerCB(void *);
#if 1
///
//Timeout update_timeout;
#endif
private:
///
Timeout autosave_timeout;
/// makes the main form.
void create_form_form_main(int width, int height);
/// A pointer to the form.
FD_form_main * form_main_;
/// A pointer to the form.
FL_FORM * form_;
/** The last textclass layout list in the layout choice selector
This should probably be moved to the toolbar, but for now it's
here. (Asger) */

View File

@ -62,6 +62,8 @@ lyx_SOURCES = \
TabularLayout.C \
TextCache.C \
TextCache.h \
Timeout.C \
Timeout.h \
ToolbarDefaults.C \
ToolbarDefaults.h \
UpdateInset.C \
@ -136,6 +138,7 @@ lyx_SOURCES = \
lyx_sendfax_main.C \
lyx_sty.C \
lyx_sty.h \
lyxcursor.C \
lyxcursor.h \
lyxfont.C \
lyxfont.h \
@ -154,6 +157,7 @@ lyx_SOURCES = \
lyxparagraph.h \
lyxrc.C \
lyxrc.h \
lyxrow.C \
lyxrow.h \
lyxscreen.h \
lyxserver.C \

View File

@ -80,7 +80,7 @@ bool UpdateParagraphExtra()
bool update = false;
if (current_view->available()) {
update = true;
LyXParagraph * par = current_view->text->cursor.par;
LyXParagraph * par = current_view->text->cursor.par();
EnableParagraphExtra();

View File

@ -54,15 +54,11 @@ public:
string writeEnvirEnd() const;
///
friend bool operator==(Spacing const & a, Spacing const & b) {
if (a.space == b.space && a.getValue() == b.getValue())
return true;
return false;
return a.space == b.space && a.getValue() == b.getValue();
}
///
friend bool operator!=(Spacing const & a, Spacing const & b) {
if (a.space == b.space && a.getValue() == b.getValue())
return false;
return true;
return !(a == b);
}
private:
///

View File

@ -50,15 +50,15 @@ bool UpdateLayoutTable(int flag)
if (!current_view->available())
update = false;
if (update && current_view->text->cursor.par->table) {
if (update && current_view->text->cursor.par()->table) {
char buf[12];
string pwidth, special;
LyXTable * table = current_view->text->cursor.par->table;
LyXTable * table = current_view->text->cursor.par()->table;
int cell = current_view->text->
NumberOfCell(current_view->text->cursor.par,
current_view->text->cursor.pos);
NumberOfCell(current_view->text->cursor.par(),
current_view->text->cursor.pos());
ActCell = cell;
int column = table->column_of_cell(cell)+1;
fl_set_object_label(fd_form_table_options->text_warning, "");
@ -274,13 +274,13 @@ void TableOptionsCB(FL_OBJECT * ob, long l)
string special, str;
if (!current_view->available()
|| !(table = current_view->text->cursor.par->table)) {
|| !(table = current_view->text->cursor.par()->table)) {
MenuLayoutTable(0);
return;
}
int cell = current_view->text->
NumberOfCell(current_view->text->cursor.par,
current_view->text->cursor.pos);
NumberOfCell(current_view->text->cursor.par(),
current_view->text->cursor.pos());
if (ActCell != cell) {
MenuLayoutTable(0);
fl_set_object_label(fd_form_table_options->text_warning,

View File

@ -35,7 +35,7 @@ public:
text_fits(Buffer * b, unsigned short p)
: buf(b), pw(p) {}
bool operator()(TextCache::value_type & vt) {
if (vt->buffer == buf && vt->paperWidth() == pw) return true;
if (vt->buffer() == buf && vt->paperWidth() == pw) return true;
return false;
}
private:
@ -61,7 +61,7 @@ class show_text {
public:
show_text(ostream & o) : os(o) {}
void operator()(TextCache::value_type & vt) {
os << "\tBuffer: " << vt->buffer
os << "\tBuffer: " << vt->buffer()
<< "\tWidth: " << vt->paperWidth() << endl;
}
private:
@ -85,7 +85,7 @@ void TextCache::show(ostream & os, LyXText * lt)
void TextCache::add(LyXText * text)
{
lyxerr.debug() << "TextCache::add " << text;
if (bufferlist.isLoaded(text->buffer)) {
if (bufferlist.isLoaded(text->buffer())) {
cache.push_back(text);
lyxerr.debug() << " added" << endl;
} else {
@ -115,7 +115,7 @@ public:
has_buffer(Buffer * b)
: buf(b) {}
bool operator()(TextCache::value_type & vt) {
if (vt->buffer == buf) return true;
if (vt->buffer() == buf) return true;
return false;
}
private:

87
src/Timeout.C Normal file
View File

@ -0,0 +1,87 @@
#include <config.h>
#include FORMS_H_LOCATION
#include "Timeout.h"
#include "debug.h"
using std::endl;
extern "C" {
static
void C_intern_timeout_cb(int, void * data)
{
Timeout * to = static_cast<Timeout*>(data);
to->callback();
}
}
Timeout::Timeout()
: type(ONETIME), timeout(0), timeout_id(-1),
callback_(0), data_(0) {}
Timeout::Timeout(int msec, Type t = ONETIME)
: type(t), timeout(msec), timeout_id(-1),
callback_(0), data_(0) {}
Timeout::~Timeout()
{
stop();
}
void Timeout::restart()
{
stop();
start();
}
void Timeout::start()
{
if (timeout_id != -1)
lyxerr << "Timeout::start: already running!" << endl;
timeout_id = fl_add_timeout(timeout,
C_intern_timeout_cb, this);
}
void Timeout::stop()
{
if (timeout_id != -1) {
fl_remove_timeout(timeout_id);
timeout_id = -1;
}
}
void Timeout::callback(TimeoutCallback cb, void * data)
{
callback_ = cb;
data_ = data;
}
void Timeout::callback()
{
timeout_id = -1;
if (callback_)
callback_(data_);
if (type == CONTINOUS)
start();
}
void Timeout::setType(Type t)
{
type = t;
}
void Timeout::setTimeout(int msec)
{
timeout = msec;
}

52
src/Timeout.h Normal file
View File

@ -0,0 +1,52 @@
// -*- C++ -*-
#ifndef TIMEOUT_H
#define TIMEOUT_H
/** This class executes the callback when the timeout expires.
This class currently uses a regular callback, later it will use
signals and slots to provide the same.
*/
class Timeout {
public:
///
typedef void (*TimeoutCallback)(void *);
///
enum Type {
ONETIME,
CONTINOUS
};
///
Timeout();
///
Timeout(int msec, Type = ONETIME);
///
~Timeout();
///
void start();
///
void stop();
///
void restart();
///
void callback(TimeoutCallback cb, void * data);
///
void callback();
///
void setType(Type t);
///
void setTimeout(int msec);
private:
///
Type type;
///
int timeout;
///
int timeout_id;
///
TimeoutCallback callback_;
///
void * data_;
};
#endif

View File

@ -344,12 +344,6 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
break;
case FL_OTHER:
if (!ev) break;
#ifndef XFORMS_CLIPBOARD
if (ev->type == SelectionNotify) {
lyxerr.debug() << "Workarea event: SELECTION" << endl;
area->owner->workAreaSelectionNotify(area->work_area->form->window, ev);
} else
#endif
lyxerr.debug() << "Workarea event: OTHER" << endl;
break;
@ -359,7 +353,6 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
}
#ifdef XFORMS_CLIPBOARD
static string clipboard_selection;
static bool clipboard_read = false;
@ -406,4 +399,3 @@ void WorkArea::putClipboard(string const & s) const
fl_stuff_clipboard(work_area, 0, hold.c_str(), hold.size(), 0);
}
#endif

View File

@ -23,7 +23,6 @@
class BufferView;
#define XFORMS_CLIPBOARD 1
class WorkArea {
public:
@ -92,12 +91,10 @@ public:
int /*key*/, void * xev);
/// xforms callback
static void scroll_cb(FL_OBJECT *, long);
#ifdef XFORMS_CLIPBOARD
///
string getClipboard() const;
///
void putClipboard(string const &) const;
#endif
private:
///
void createPixmap(int, int);

View File

@ -12,15 +12,6 @@
* ======================================================
*/
// Change Log:
// ===========
// 23/03/98 Heinrich Bauer (heinrich.bauer@t-mobil.de)
// Spots marked "changed Heinrich Bauer, 23/03/98" modified due to the
// following bug: dvi file export did not work after printing (or previewing)
// and vice versa as long as the same file was concerned. This happened
// every time the LyX-file was left unchanged between the two actions mentioned
// above.
#include <config.h>
#include <fstream>
@ -1404,6 +1395,7 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
// par->GetLayout()); // unused
//bool free_spc = layout.free_spacing; //unused
#ifndef NEW_TABULAR
/* It might be a table */
if (par->table){
#if 0
@ -1449,7 +1441,7 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
if (clen[j] < h)
clen[j] = h;
}
#endif
font1 = LyXFont(LyXFont::ALL_INHERIT, params.language_info);
actcell = 0;
for (i = 0, actpos = 1; i < par->size(); ++i, ++actpos) {
@ -1481,6 +1473,7 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
ofs << " ";
currlinelen += (ltype_depth-depth)*2;
}
#ifndef NEW_TABULAR
if (par->table) {
for(j = 0; j < cells; ++j) {
ofs << '+';
@ -1500,8 +1493,9 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
}
ofs << "| ";
}
#endif
}
font2 = par->GetFontSettings(i);
font2 = par->GetFontSettings(params, i);
if (font1.latex() != font2.latex()) {
if (font2.latex() == LyXFont::OFF)
islatex = 0;
@ -1523,6 +1517,7 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
}
break;
case LyXParagraph::META_NEWLINE:
#ifndef NEW_TABULAR
if (par->table) {
if (par->table->NumberOfCellsInRow(actcell) <= cell) {
for(j = actpos; j < clen[cell - 1]; ++j)
@ -1563,6 +1558,7 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
++actcell;
currlinelen = actpos = 0;
} else {
#endif
ofs << "\n";
for(j = 0; j < depth; ++j)
ofs << " ";
@ -1573,7 +1569,9 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
ofs << " ";
currlinelen += (ltype_depth - depth) * 2;
}
#ifndef NEW_TABULAR
}
#endif
break;
case LyXParagraph::META_HFILL:
ofs << "\t";
@ -1602,6 +1600,7 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
break;
}
}
#ifndef NEW_TABULAR
if (par->table) {
for(j = actpos; j < clen[cell - 1]; ++j)
ofs << ' ';
@ -1621,7 +1620,8 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
}
ofs << "+\n";
delete [] clen;
}
}
#endif
par = par->next;
}
@ -1756,7 +1756,7 @@ void Buffer::makeLaTeXFile(string const & fname,
// language should be a parameter to \documentclass
bool use_babel = false;
if (params.language_info->RightToLeft) // This seems necessary
if (params.language_info->RightToLeft()) // This seems necessary
features.UsedLanguages.insert(default_language);
if (params.language != "default" ||
!features.UsedLanguages.empty() ) {
@ -1764,8 +1764,8 @@ void Buffer::makeLaTeXFile(string const & fname,
for (LaTeXFeatures::LanguageList::const_iterator cit =
features.UsedLanguages.begin();
cit != features.UsedLanguages.end(); ++cit)
options += (*cit)->lang + ",";
options += params.language_info->lang + ',';
options += (*cit)->lang() + ",";
options += params.language_info->lang() + ',';
}
// the user-defined options
@ -2146,10 +2146,10 @@ void Buffer::latexParagraphs(ostream & ofs, LyXParagraph *par,
ftcount = -1;
if (layout.isEnvironment()
|| par->pextra_type != LyXParagraph::PEXTRA_NONE) {
par = par->TeXEnvironment(ofs, texrow,
par = par->TeXEnvironment(params, ofs, texrow,
ftnote, ft_texrow, ftcount);
} else {
par = par->TeXOnePar(ofs, texrow, false,
par = par->TeXOnePar(params, ofs, texrow, false,
ftnote, ft_texrow, ftcount);
}
@ -2654,7 +2654,7 @@ void Buffer::SimpleLinuxDocOnePar(ostream & os, LyXParagraph * par,
font1 = style.font;
}
font2 = par->getFont(i);
font2 = par->getFont(params, i);
if (font1.family() != font2.family()) {
switch(family_type) {
@ -3119,10 +3119,13 @@ void Buffer::SimpleDocBookOnePar(ostream & os, string & extra,
LyXParagraph * par, int & desc_on,
int const depth)
{
#ifndef NEW_TABULAR
if (par->table) {
par->SimpleDocBookOneTablePar(os, extra, desc_on, depth);
par->SimpleDocBookOneTablePar(params,
os, extra, desc_on, depth);
return;
}
#endif
bool emph_flag = false;
@ -3146,7 +3149,7 @@ void Buffer::SimpleDocBookOnePar(ostream & os, string & extra,
// parsing main loop
for (LyXParagraph::size_type i = 0;
i < par->size(); ++i) {
LyXFont font2 = par->getFont(i);
LyXFont font2 = par->getFont(params, i);
// handle <emphasis> tag
if (font1.emph() != font2.emph() && i) {
@ -3794,7 +3797,7 @@ vector<vector<Buffer::TocItem> > Buffer::getTocList()
TocItem tmp;
tmp.par = par;
tmp.depth = 0;
tmp.str = par->String(false);
tmp.str = par->String(params, false);
switch (par->footnotekind) {
case LyXParagraph::FIG:
case LyXParagraph::WIDE_FIG:
@ -3824,7 +3827,7 @@ vector<vector<Buffer::TocItem> > Buffer::getTocList()
tmp.depth = max(0,
labeltype -
textclasslist.TextClass(params.textclass).maxcounter());
tmp.str = par->String(true);
tmp.str = par->String(params, true);
l[TOC_TOC].push_back(tmp);
}
}
@ -3844,12 +3847,12 @@ vector<pair<string,string> > Buffer::getBibkeyList()
return tmp->getBibkeyList();
}
vector<pair<string,string> > keys;
vector<pair<string, string> > keys;
LyXParagraph * par = paragraph;
while (par) {
if (par->bibkey)
keys.push_back(pair<string,string>(par->bibkey->getContents(),
par->String(false)));
par->String(params, false)));
par = par->next;
}
@ -3937,7 +3940,7 @@ void Buffer::ChangeLanguage(Language const * from, Language const * to)
LyXParagraph * par = paragraph;
while (par) {
par->ChangeLanguage(from, to);
par->ChangeLanguage(params, from, to);
par = par->next;
}
}
@ -3948,7 +3951,7 @@ bool Buffer::isMultiLingual()
LyXParagraph * par = paragraph;
while (par) {
if (par->isMultiLingual())
if (par->isMultiLingual(params))
return true;
par = par->next;
}

View File

@ -251,9 +251,9 @@ string CurrentState(BufferView * bv)
state += string(_(", Depth: ")) + tostr(depth);
// The paragraph spacing, but only if different from
// buffer spacing.
if (!bv->text->cursor.par->spacing.isDefault()) {
if (!bv->text->cursor.par()->spacing.isDefault()) {
Spacing::Space cur_space =
bv->text->cursor.par->spacing.getSpace();
bv->text->cursor.par()->spacing.getSpace();
state += _(", Spacing: ");
switch (cur_space) {
case Spacing::Single:
@ -267,7 +267,7 @@ string CurrentState(BufferView * bv)
break;
case Spacing::Other:
state += _("Other (");
state += tostr(bv->text->cursor.par->spacing.getValue());
state += tostr(bv->text->cursor.par()->spacing.getValue());
state += ")";
break;
case Spacing::Default:
@ -298,12 +298,12 @@ void ToggleAndShow(BufferView * bv, LyXFont const & font)
font.latex() != LyXFont::IGNORE) {
LyXText * text = bv->text;
LyXCursor & cursor = text->cursor;
text->ComputeBidiTables(cursor.row);
if (cursor.boundary !=
text->IsBoundary(cursor.par, cursor.pos,
text->ComputeBidiTables(cursor.row());
if (cursor.boundary() !=
text->IsBoundary(cursor.par(), cursor.pos(),
text->real_current_font) )
text->SetCursor(cursor.par, cursor.pos,
false, !cursor.boundary);
text->SetCursor(cursor.par(), cursor.pos(),
false, !cursor.boundary());
}
}
}

View File

@ -58,9 +58,10 @@ InsetTabular::InsetTabular(Buffer * buf, int rows, int columns)
// just for test!!!
the_locking_inset = 0;
locked = no_selection = cursor_visible = false;
cursor.x_fix = -1;
cursor.x_fix(-1);
oldcell = -1;
actcell = cursor.pos = 0;
actcell = 0;
cursor.pos(0);
sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
init_inset = true;
}
@ -72,9 +73,10 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer * buf)
tabular = new LyXTabular(this, *(tab.tabular));
the_locking_inset = 0;
locked = no_selection = cursor_visible = false;
cursor.x_fix = -1;
cursor.x_fix(-1);
oldcell = -1;
actcell = cursor.pos = 0;
actcell = 0;
cursor.pos(0);
sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
init_inset = true;
}
@ -284,7 +286,7 @@ void InsetTabular::Edit(BufferView * bv, int x, int y, unsigned int button)
the_locking_inset = 0;
inset_pos = inset_x = inset_y = 0;
setPos(bv->painter(), x, y);
sel_pos_start = sel_pos_end = cursor.pos;
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
bv->text->FinishUndo();
if (InsetHit(bv, x, y)) {
@ -304,7 +306,7 @@ void InsetTabular::InsetUnlock(BufferView * bv)
}
HideInsetCursor(bv);
if (hasSelection()) {
sel_pos_start = sel_pos_end = cursor.pos;
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
UpdateLocal(bv, false);
}
@ -332,16 +334,16 @@ bool InsetTabular::LockInsetInInset(BufferView * bv, UpdatableInset * inset)
lyxerr[Debug::INSETS] << "OK" << endl;
the_locking_inset = tabular->GetCellInset(actcell);
resetPos(bv->painter());
inset_x = cursor.x - top_x + tabular->GetBeginningOfTextInCell(actcell);
inset_y = cursor.y;
inset_pos = cursor.pos;
inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
inset_y = cursor.y();
inset_pos = cursor.pos();
return true;
} else if (the_locking_inset && (the_locking_inset == inset)) {
if (cursor.pos == inset_pos) {
if (cursor.pos() == inset_pos) {
lyxerr[Debug::INSETS] << "OK" << endl;
resetPos(bv->painter());
inset_x = cursor.x - top_x + tabular->GetBeginningOfTextInCell(actcell);
inset_y = cursor.y;
inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
inset_y = cursor.y();
} else {
lyxerr[Debug::INSETS] << "cursor.pos != inset_pos" << endl;
}
@ -454,7 +456,7 @@ void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int button)
int ocell = actcell;
setPos(bv->painter(), x, y);
sel_pos_start = sel_pos_end = cursor.pos;
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
bool inset_hit = InsetHit(bv, x, y);
@ -492,7 +494,7 @@ void InsetTabular::InsetMotionNotify(BufferView * bv, int x, int y, int button)
int old = sel_pos_end;
setPos(bv->painter(), x, y);
sel_pos_end = cursor.pos;
sel_pos_end = cursor.pos();
sel_cell_end = actcell;
if (old != sel_pos_end)
UpdateLocal(bv, false);
@ -534,7 +536,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
if ((action != LFUN_DOWN) && (action != LFUN_UP) &&
(action != LFUN_DOWNSEL) && (action != LFUN_UPSEL))
cursor.x_fix = -1;
cursor.x_fix(-1);
if (the_locking_inset) {
result=the_locking_inset->LocalDispatch(bv, action, arg);
if (result == DISPATCHED_NOUPDATE)
@ -547,10 +549,10 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
return result;
} else if (result == FINISHED) {
if ((action == LFUN_RIGHT) || (action == -1)) {
cursor.pos = inset_pos + 1;
cursor.pos(inset_pos + 1);
resetPos(bv->painter());
}
sel_pos_start = sel_pos_end = cursor.pos;
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
the_locking_inset=0;
result = DISPATCHED;
@ -566,11 +568,11 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
break;
// --- Cursor Movements ---------------------------------------------
case LFUN_RIGHTSEL:
if (tabular->IsLastCellInRow(actcell) && !cellstart(cursor.pos))
if (tabular->IsLastCellInRow(actcell) && !cellstart(cursor.pos()))
break;
moveRight(bv, false);
sel_pos_end = cursor.pos;
if (!cellstart(cursor.pos)) {
sel_pos_end = cursor.pos();
if (!cellstart(cursor.pos())) {
if (tabular->right_column_of_cell(sel_cell_start) >
tabular->right_column_of_cell(actcell))
sel_cell_end = actcell+1;
@ -581,17 +583,17 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
break;
case LFUN_RIGHT:
result = moveRight(bv);
sel_pos_start = sel_pos_end = cursor.pos;
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
if (hs)
UpdateLocal(bv, false);
break;
case LFUN_LEFTSEL:
if (tabular->IsFirstCellInRow(actcell) && cellstart(cursor.pos))
if (tabular->IsFirstCellInRow(actcell) && cellstart(cursor.pos()))
break;
moveLeft(bv, false);
sel_pos_end = cursor.pos;
if (cellstart(cursor.pos)) {
sel_pos_end = cursor.pos();
if (cellstart(cursor.pos())) {
if (tabular->column_of_cell(sel_cell_start) >=
tabular->column_of_cell(actcell))
sel_cell_end = actcell;
@ -602,7 +604,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
break;
case LFUN_LEFT:
result = moveLeft(bv);
sel_pos_start = sel_pos_end = cursor.pos;
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
if (hs)
UpdateLocal(bv, false);
@ -611,7 +613,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
{
int ocell = actcell;
moveDown(bv);
sel_pos_end = cursor.pos;
sel_pos_end = cursor.pos();
if ((ocell == sel_cell_end) ||
(tabular->column_of_cell(ocell)>tabular->column_of_cell(actcell)))
sel_cell_end = tabular->GetCellBelow(sel_cell_end);
@ -622,7 +624,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
break;
case LFUN_DOWN:
result= moveDown(bv);
sel_pos_start = sel_pos_end = cursor.pos;
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
if (hs)
UpdateLocal(bv, false);
@ -631,7 +633,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
{
int ocell = actcell;
moveUp(bv);
sel_pos_end = cursor.pos;
sel_pos_end = cursor.pos();
if ((ocell == sel_cell_end) ||
(tabular->column_of_cell(ocell)>tabular->column_of_cell(actcell)))
sel_cell_end = tabular->GetCellAbove(sel_cell_end);
@ -642,7 +644,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
break;
case LFUN_UP:
result= moveUp(bv);
sel_pos_start = sel_pos_end = cursor.pos;
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
if (hs)
UpdateLocal(bv, false);
@ -665,7 +667,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
moveNextCell(bv);
else
movePrevCell(bv);
sel_pos_start = sel_pos_end = cursor.pos;
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
if (hs)
UpdateLocal(bv, false);
@ -749,8 +751,8 @@ void InsetTabular::calculate_width_of_cells(Painter & pain,
void InsetTabular::GetCursorPos(int & x, int & y) const
{
x = cursor.x-top_x;
y = cursor.y;
x = cursor.x() - top_x;
y = cursor.y();
}
@ -769,7 +771,7 @@ void InsetTabular::ToggleInsetCursor(BufferView * bv)
if (cursor_visible)
bv->hideLockedInsetCursor();
else
bv->showLockedInsetCursor(cursor.x, cursor.y, asc, desc);
bv->showLockedInsetCursor(cursor.x(), cursor.y(), asc, desc);
cursor_visible = !cursor_visible;
}
@ -781,8 +783,8 @@ void InsetTabular::ShowInsetCursor(BufferView * bv)
int asc = lyxfont::maxAscent(font);
int desc = lyxfont::maxDescent(font);
bv->fitLockedInsetCursor(cursor.x, cursor.y, asc, desc);
bv->showLockedInsetCursor(cursor.x, cursor.y, asc, desc);
bv->fitLockedInsetCursor(cursor.x(), cursor.y(), asc, desc);
bv->showLockedInsetCursor(cursor.x(), cursor.y(), asc, desc);
cursor_visible = true;
}
}
@ -797,17 +799,20 @@ void InsetTabular::HideInsetCursor(BufferView * bv)
void InsetTabular::setPos(Painter & pain, int x, int y) const
{
cursor.y = cursor.pos = actcell = actrow = actcol = 0;
cursor.y(0);
cursor.pos(0);
actcell = actrow = actcol = 0;
int ly = tabular->GetDescentOfRow(actrow);
// first search the right row
while((ly < y) && (actrow < tabular->rows())) {
cursor.y += tabular->GetDescentOfRow(actrow) +
cursor.y(cursor.y() + tabular->GetDescentOfRow(actrow) +
tabular->GetAscentOfRow(actrow+1) +
tabular->GetAdditionalHeight(tabular->GetCellNumber(actrow+1,
actcol));
tabular->GetAdditionalHeight(tabular->GetCellNumber(actrow + 1,
actcol)));
++actrow;
ly = cursor.y + tabular->GetDescentOfRow(actrow);
ly = cursor.y() + tabular->GetDescentOfRow(actrow);
}
actcell = tabular->GetCellNumber(actrow, actcol);
@ -816,14 +821,14 @@ void InsetTabular::setPos(Painter & pain, int x, int y) const
tabular->GetAdditionalWidth(actcell);
for(; !tabular->IsLastCellInRow(actcell) && (lx < x);
++actcell,lx += tabular->GetWidthOfColumn(actcell) +
tabular->GetAdditionalWidth(actcell-1));
cursor.pos = ((actcell+1) * 2) - 1;
tabular->GetAdditionalWidth(actcell - 1));
cursor.pos(((actcell+1) * 2) - 1);
resetPos(pain);
if ((lx - (tabular->GetWidthOfColumn(actcell)/2)) < x) {
cursor.x = lx + top_x - 2;
cursor.x(lx + top_x - 2);
} else {
--cursor.pos;
cursor.x = lx - tabular->GetWidthOfColumn(actcell) + top_x + 2;
cursor.pos(cursor.pos() - 1);
cursor.x(lx - tabular->GetWidthOfColumn(actcell) + top_x + 2);
}
resetPos(pain);
}
@ -849,20 +854,21 @@ void InsetTabular::resetPos(Painter & pain) const
actcol = tabular->column_of_cell(actcell);
int cell = 0;
actrow = cursor.y = 0;
actrow = 0;
cursor.y(0);
for(; (cell<actcell) && !tabular->IsLastRow(cell); ++cell) {
if (tabular->IsLastCellInRow(cell)) {
cursor.y += tabular->GetDescentOfRow(actrow) +
tabular->GetAscentOfRow(actrow+1) +
tabular->GetAdditionalHeight(cell+1);
cursor.y(cursor.y() + tabular->GetDescentOfRow(actrow) +
tabular->GetAscentOfRow(actrow + 1) +
tabular->GetAdditionalHeight(cell + 1));
++actrow;
}
}
cursor.x = getCellXPos(actcell) + 2;
if (cursor.pos % 2) {
cursor.x(getCellXPos(actcell) + 2);
if (cursor.pos() % 2) {
LyXFont font(LyXFont::ALL_SANE);
cursor.x += tabular->GetCellInset(actcell)->width(pain,font) +
tabular->GetBeginningOfTextInCell(actcell);
cursor.x(cursor.x() + tabular->GetCellInset(actcell)->width(pain,font) +
tabular->GetBeginningOfTextInCell(actcell));
}
if ((!the_locking_inset ||
!the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE)) &&
@ -897,16 +903,16 @@ bool InsetTabular::SetCellDimensions(Painter & pain, int cell, int row)
UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
{
if (!cellstart(cursor.pos)) {
if (!cellstart(cursor.pos())) {
if (tabular->IsLastCell(actcell))
return FINISHED;
++actcell;
++cursor.pos;
cursor.pos(cursor.pos() + 1);
} else if (lock) {
if (ActivateCellInset(bv))
return DISPATCHED;
} else { // before the inset
++cursor.pos;
cursor.pos(cursor.pos() + 1);
}
resetPos(bv->painter());
return DISPATCHED_NOUPDATE;
@ -915,13 +921,13 @@ UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
UpdatableInset::RESULT InsetTabular::moveLeft(BufferView * bv, bool lock)
{
if (!cursor.pos) {
if (!cursor.pos()) {
if (!actcell)
return FINISHED;
cursor.pos = 2;
cursor.pos(2);
}
--cursor.pos;
if (!cellstart(cursor.pos)) {
cursor.pos(cursor.pos() - 1);
if (!cellstart(cursor.pos())) {
--actcell;
} else if (lock) { // behind the inset
if (ActivateCellInset(bv, 0, 0, 0, true))
@ -959,9 +965,9 @@ bool InsetTabular::moveNextCell(BufferView * bv)
if (tabular->IsLastCell(actcell))
return false;
++actcell;
++cursor.pos;
if (!cellstart(cursor.pos))
++cursor.pos;
cursor.pos(cursor.pos() + 1);
if (!cellstart(cursor.pos()))
cursor.pos(cursor.pos() + 1);
resetPos(bv->painter());
return true;
}
@ -972,9 +978,9 @@ bool InsetTabular::movePrevCell(BufferView * bv)
if (!actcell) // first cell
return false;
--actcell;
--cursor.pos;
if (cellstart(cursor.pos))
--cursor.pos;
cursor.pos(cursor.pos() - 1);
if (cellstart(cursor.pos()))
cursor.pos(cursor.pos() - 1);
resetPos(bv->painter());
return true;
}
@ -1041,8 +1047,8 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
sel_row_start = sel_row_end = tabular->row_of_cell(actcell);
}
bv->text->SetUndo(Undo::FINISH,
bv->text->cursor.par->ParFromPos(bv->text->cursor.pos)->previous,
bv->text->cursor.par->ParFromPos(bv->text->cursor.pos)->next);
bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
int row = tabular->row_of_cell(actcell);
int column = tabular->column_of_cell(actcell);
@ -1156,9 +1162,9 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val)
s_start = sel_cell_start;
s_end = sel_cell_end;
}
tabular->SetMultiColumn(s_start, s_end-s_start+1);
tabular->SetMultiColumn(s_start, s_end - s_start + 1);
actcell = s_start;
cursor.pos = 0;
cursor.pos(0);
sel_cell_end = sel_cell_start;
sel_pos_end = sel_pos_start;
UpdateLocal(bv, true);
@ -1226,8 +1232,8 @@ bool InsetTabular::ActivateCellInset(BufferView * bv, int x, int y, int button,
{
// the cursor.pos has to be before the inset so if it isn't now just
// reset the curor pos first!
if (cursor.pos % 2) { // behind the inset
--cursor.pos;
if (cursor.pos() % 2) { // behind the inset
cursor.pos(cursor.pos() - 1);
resetPos(bv->painter());
}
UpdatableInset * inset =
@ -1237,9 +1243,9 @@ bool InsetTabular::ActivateCellInset(BufferView * bv, int x, int y, int button,
x = inset->x() + inset->width(bv->painter(), font);
y = inset->descent(bv->painter(), font);
}
inset_x = cursor.x - top_x + tabular->GetBeginningOfTextInCell(actcell);
inset_y = cursor.y;
inset->Edit(bv, x-inset_x, y-inset_y, button);
inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
inset_y = cursor.y();
inset->Edit(bv, x - inset_x, y - inset_y, button);
if (!the_locking_inset)
return false;
UpdateLocal(bv, true);
@ -1251,12 +1257,12 @@ bool InsetTabular::InsetHit(BufferView * bv, int x, int ) const
InsetText * inset = tabular->GetCellInset(actcell);
int x1 = x + top_x;
if (cursor.pos % 2) { // behind the inset
return (((x+top_x) < cursor.x) &&
((x+top_x) > (cursor.x - inset->width(bv->painter(),
if (cursor.pos() % 2) { // behind the inset
return (((x + top_x) < cursor.x()) &&
((x + top_x) > (cursor.x() - inset->width(bv->painter(),
LyXFont(LyXFont::ALL_SANE)))));
} else {
int x2 = cursor.x + tabular->GetBeginningOfTextInCell(actcell);
int x2 = cursor.x() + tabular->GetBeginningOfTextInCell(actcell);
return ((x1 > x2) &&
(x1 < (x2 + inset->width(bv->painter(),
LyXFont(LyXFont::ALL_SANE)))));

View File

@ -73,7 +73,7 @@ void InsetText::init(Buffer * buf, InsetText const * ins)
the_locking_inset = 0;
buffer = buf;
cursor_visible = false;
cursor.x_fix = -1;
cursor.x_fix(-1);
interline_space = 1;
no_selection = false;
init_inset = true;
@ -87,8 +87,8 @@ void InsetText::init(Buffer * buf, InsetText const * ins)
drawLockedFrame = ins->drawLockedFrame;
}
par->SetInsetOwner(this);
cursor.par = par;
cursor.pos = 0;
cursor.par(par);
cursor.pos(0);
selection_start_cursor = selection_end_cursor = cursor;
frame_color = LColor::insetframe;
locked = false;
@ -211,10 +211,10 @@ void InsetText::draw(Painter & pain, LyXFont const & f,
}
computeBaselines(baseline);
}
if (the_locking_inset && (cursor.pos == inset_pos)) {
if (the_locking_inset && (cursor.pos() == inset_pos)) {
resetPos(pain);
inset_x = cursor.x - top_x + drawTextXOffset;
inset_y = cursor.y + drawTextYOffset;
inset_x = cursor.x() - top_x + drawTextXOffset;
inset_y = cursor.y() + drawTextYOffset;
}
if (drawLockedFrame && locked) {
pain.rectangle(int(x), baseline - ascent(pain, f), insetWidth,
@ -237,12 +237,12 @@ void InsetText::drawRowSelection(Painter & pain, int startpos, int endpos,
return;
int s_start, s_end;
if (selection_start_cursor.pos > selection_end_cursor.pos) {
s_start = selection_end_cursor.pos;
s_end = selection_start_cursor.pos;
if (selection_start_cursor.pos() > selection_end_cursor.pos()) {
s_start = selection_end_cursor.pos();
s_end = selection_start_cursor.pos();
} else {
s_start = selection_start_cursor.pos;
s_end = selection_end_cursor.pos;
s_start = selection_start_cursor.pos();
s_end = selection_end_cursor.pos();
}
if ((s_start > endpos) || (s_end < startpos))
return;
@ -352,7 +352,7 @@ void InsetText::Edit(BufferView * bv, int x, int y, unsigned int button)
setPos(bv->painter(), x, y);
checkAndActivateInset(bv, x, y, button);
selection_start_cursor = selection_end_cursor = cursor;
current_font = real_current_font = GetFont(par, cursor.pos);
current_font = real_current_font = GetFont(par, cursor.pos());
bv->text->FinishUndo();
UpdateLocal(bv, true);
}
@ -379,20 +379,20 @@ bool InsetText::LockInsetInInset(BufferView * bv, UpdatableInset * inset)
lyxerr[Debug::INSETS] << "InsetText::LockInsetInInset(" << inset << "): ";
if (!inset)
return false;
if (inset == par->GetInset(cursor.pos)) {
if (inset == par->GetInset(cursor.pos())) {
lyxerr[Debug::INSETS] << "OK" << endl;
the_locking_inset = inset;
resetPos(bv->painter());
inset_x = cursor.x - top_x + drawTextXOffset;
inset_y = cursor.y + drawTextYOffset;
inset_pos = cursor.pos;
inset_x = cursor.x() - top_x + drawTextXOffset;
inset_y = cursor.y() + drawTextYOffset;
inset_pos = cursor.pos();
return true;
} else if (the_locking_inset && (the_locking_inset == inset)) {
if (cursor.pos == inset_pos) {
if (cursor.pos() == inset_pos) {
lyxerr[Debug::INSETS] << "OK" << endl;
resetPos(bv->painter());
inset_x = cursor.x - top_x + drawTextXOffset;
inset_y = cursor.y + drawTextYOffset;
inset_x = cursor.x() - top_x + drawTextXOffset;
inset_y = cursor.y() + drawTextYOffset;
} else {
lyxerr[Debug::INSETS] << "cursor.pos != inset_pos" << endl;
}
@ -430,9 +430,9 @@ bool InsetText::UpdateInsetInInset(BufferView * bv, Inset * inset)
lyxerr[Debug::INSETS] << "InsetText::UpdateInsetInInset(" << inset <<
")" << endl;
UpdateLocal(bv, true);
if (cursor.pos == inset_pos) {
inset_x = cursor.x - top_x + drawTextXOffset;
inset_y = cursor.y + drawTextYOffset;
if (cursor.pos() == inset_pos) {
inset_x = cursor.x() - top_x + drawTextXOffset;
inset_y = cursor.y() + drawTextYOffset;
}
return true;
}
@ -446,21 +446,20 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
}
no_selection = false;
setPos(bv->painter(), x, y);
cursor.x_fix = -1;
cursor.x_fix(-1);
if (the_locking_inset) {
UpdatableInset
*inset = 0;
if (par->GetChar(cursor.pos) == LyXParagraph::META_INSET)
inset = static_cast<UpdatableInset*>(par->GetInset(cursor.pos));
UpdatableInset * inset = 0;
if (par->GetChar(cursor.pos()) == LyXParagraph::META_INSET)
inset = static_cast<UpdatableInset*>(par->GetInset(cursor.pos()));
if (the_locking_inset == inset) {
the_locking_inset->InsetButtonPress(bv,x-inset_x,y-inset_y,button);
return;
} else if (inset) {
// otherwise unlock the_locking_inset and lock the new inset
the_locking_inset->InsetUnlock(bv);
inset_x = cursor.x - top_x + drawTextXOffset;
inset_y = cursor.y + drawTextYOffset;
inset->InsetButtonPress(bv, x-inset_x, y-inset_y, button);
inset_x = cursor.x() - top_x + drawTextXOffset;
inset_y = cursor.y() + drawTextYOffset;
inset->InsetButtonPress(bv, x - inset_x, y - inset_y, button);
inset->Edit(bv, x - inset_x, y - inset_y, button);
UpdateLocal(bv, true);
return;
@ -470,15 +469,15 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
the_locking_inset = 0;
}
if (bv->the_locking_inset) {
if ((par->GetChar(cursor.pos) == LyXParagraph::META_INSET) &&
par->GetInset(cursor.pos) &&
(par->GetInset(cursor.pos)->Editable() == Inset::HIGHLY_EDITABLE)) {
UpdatableInset *inset =
static_cast<UpdatableInset*>(par->GetInset(cursor.pos));
inset_x = cursor.x - top_x + drawTextXOffset;
inset_y = cursor.y + drawTextYOffset;
inset->InsetButtonPress(bv, x-inset_x, y-inset_y, button);
inset->Edit(bv, x-inset_x, y-inset_y, 0);
if ((par->GetChar(cursor.pos()) == LyXParagraph::META_INSET) &&
par->GetInset(cursor.pos()) &&
(par->GetInset(cursor.pos())->Editable() == Inset::HIGHLY_EDITABLE)) {
UpdatableInset * inset =
static_cast<UpdatableInset*>(par->GetInset(cursor.pos()));
inset_x = cursor.x() - top_x + drawTextXOffset;
inset_y = cursor.y() + drawTextYOffset;
inset->InsetButtonPress(bv, x - inset_x, y - inset_y, button);
inset->Edit(bv, x - inset_x, y - inset_y, 0);
UpdateLocal(bv, true);
}
}
@ -493,15 +492,15 @@ void InsetText::InsetButtonRelease(BufferView * bv, int x, int y, int button)
if (the_locking_inset) {
the_locking_inset->InsetButtonRelease(bv, x-inset_x, y-inset_y,button);
} else {
if (par->GetChar(cursor.pos) == LyXParagraph::META_INSET) {
inset = static_cast<UpdatableInset*>(par->GetInset(cursor.pos));
if (inset->Editable()==Inset::HIGHLY_EDITABLE) {
inset->InsetButtonRelease(bv, x-inset_x, y-inset_y,button);
if (par->GetChar(cursor.pos()) == LyXParagraph::META_INSET) {
inset = static_cast<UpdatableInset*>(par->GetInset(cursor.pos()));
if (inset->Editable() == Inset::HIGHLY_EDITABLE) {
inset->InsetButtonRelease(bv, x - inset_x, y - inset_y,button);
} else {
inset_x = cursor.x - top_x + drawTextXOffset;
inset_y = cursor.y + drawTextYOffset;
inset->InsetButtonRelease(bv, x-inset_x, y-inset_y,button);
inset->Edit(bv, x-inset_x, y-inset_y, button);
inset_x = cursor.x() - top_x + drawTextXOffset;
inset_y = cursor.y() + drawTextYOffset;
inset->InsetButtonRelease(bv, x - inset_x, y - inset_y,button);
inset->Edit(bv, x - inset_x, y - inset_y, button);
}
}
}
@ -556,7 +555,7 @@ InsetText::LocalDispatch(BufferView * bv,
if ((action != LFUN_DOWN) && (action != LFUN_UP) &&
(action != LFUN_DOWNSEL) && (action != LFUN_UPSEL))
cursor.x_fix = -1;
cursor.x_fix(-1);
if (the_locking_inset) {
result = the_locking_inset->LocalDispatch(bv, action, arg);
if (result == DISPATCHED_NOUPDATE)
@ -570,7 +569,7 @@ InsetText::LocalDispatch(BufferView * bv,
switch(action) {
case -1:
case LFUN_RIGHT:
cursor.pos = inset_pos + 1;
cursor.pos(inset_pos + 1);
resetPos(bv->painter());
break;
case LFUN_DOWN:
@ -586,13 +585,13 @@ InsetText::LocalDispatch(BufferView * bv,
// Normal chars
case -1:
bv->text->SetUndo(Undo::INSERT,
bv->text->cursor.par->ParFromPos(bv->text->cursor.pos)->previous,
bv->text->cursor.par->ParFromPos(bv->text->cursor.pos)->next);
bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
cutSelection();
cursor = selection_start_cursor;
par->InsertChar(cursor.pos,arg[0]);
SetCharFont(cursor.pos,current_font);
++cursor.pos;
par->InsertChar(cursor.pos(), arg[0]);
SetCharFont(cursor.pos(), current_font);
cursor.pos(cursor.pos() + 1);
selection_start_cursor = selection_end_cursor = cursor;
UpdateLocal(bv, true);
break;
@ -662,7 +661,7 @@ InsetText::LocalDispatch(BufferView * bv,
}
break;
case LFUN_BACKSPACE:
if (!cursor.pos) {
if (!cursor.pos()) {
if (hasSelection()) {
selection_start_cursor = selection_end_cursor = cursor;
UpdateLocal(bv, false);
@ -673,13 +672,13 @@ InsetText::LocalDispatch(BufferView * bv,
case LFUN_DELETE:
{
bv->text->SetUndo(Undo::DELETE,
bv->text->cursor.par->ParFromPos(bv->text->cursor.pos)->previous,
bv->text->cursor.par->ParFromPos(bv->text->cursor.pos)->next);
bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
bool ret = true;
if (hasSelection()) {
LyXParagraph::size_type i = selection_start_cursor.pos;
for (; i < selection_end_cursor.pos; ++i) {
par->Erase(selection_start_cursor.pos);
LyXParagraph::size_type i = selection_start_cursor.pos();
for (; i < selection_end_cursor.pos(); ++i) {
par->Erase(selection_start_cursor.pos());
}
} else
ret = Delete();
@ -695,8 +694,8 @@ InsetText::LocalDispatch(BufferView * bv,
break;
case LFUN_CUT:
bv->text->SetUndo(Undo::DELETE,
bv->text->cursor.par->ParFromPos(bv->text->cursor.pos)->previous,
bv->text->cursor.par->ParFromPos(bv->text->cursor.pos)->next);
bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
if (cutSelection()) {
// we need update
@ -722,8 +721,8 @@ InsetText::LocalDispatch(BufferView * bv,
case LFUN_PASTE:
{
bv->text->SetUndo(Undo::INSERT,
bv->text->cursor.par->ParFromPos(bv->text->cursor.pos)->previous,
bv->text->cursor.par->ParFromPos(bv->text->cursor.pos)->next);
bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
if (pasteSelection()) {
selection_start_cursor = selection_end_cursor = cursor;
UpdateLocal(bv, true);
@ -733,9 +732,12 @@ InsetText::LocalDispatch(BufferView * bv,
break;
case LFUN_HOME:
bv->text->FinishUndo();
for(; cursor.pos > rows[actrow].pos; --cursor.pos)
cursor.x -= SingleWidth(bv->painter(), par, cursor.pos);
cursor.x -= SingleWidth(bv->painter(), par, cursor.pos);
for(; cursor.pos() > rows[actrow].pos;) {
cursor.x(cursor.x() - SingleWidth(bv->painter(), par, cursor.pos()));
cursor.pos(cursor.pos() - 1);
}
cursor.x(cursor.x() - SingleWidth(bv->painter(), par, cursor.pos()));
if (hasSelection()) {
selection_start_cursor = selection_end_cursor = cursor;
UpdateLocal(bv, false);
@ -750,8 +752,10 @@ InsetText::LocalDispatch(BufferView * bv,
int checkpos = (int)rows[actrow + 1].pos;
if ((actrow + 2) < (int)rows.size())
--checkpos;
for(; cursor.pos < checkpos; ++cursor.pos)
cursor.x += SingleWidth(bv->painter(), par, cursor.pos);
for(; cursor.pos() < checkpos;) {
cursor.x(cursor.x() + SingleWidth(bv->painter(), par, cursor.pos()));
cursor.pos(cursor.pos() + 1);
}
if (hasSelection()) {
selection_start_cursor = selection_end_cursor = cursor;
UpdateLocal(bv, false);
@ -766,12 +770,12 @@ InsetText::LocalDispatch(BufferView * bv,
if (!autoBreakRows)
return DISPATCHED;
bv->text->SetUndo(Undo::INSERT,
bv->text->cursor.par->ParFromPos(bv->text->cursor.pos)->previous,
bv->text->cursor.par->ParFromPos(bv->text->cursor.pos)->next);
par->InsertChar(cursor.pos,LyXParagraph::META_NEWLINE);
SetCharFont(cursor.pos,current_font);
bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
par->InsertChar(cursor.pos(),LyXParagraph::META_NEWLINE);
SetCharFont(cursor.pos(),current_font);
UpdateLocal(bv, true);
++cursor.pos;
cursor.pos(cursor.pos() + 1);
selection_start_cursor = selection_end_cursor = cursor;
resetPos(bv->painter());
break;
@ -803,7 +807,7 @@ InsetText::LocalDispatch(BufferView * bv,
if (current_layout != layout.second) {
bv->text->SetLayout(cursor, selection_start_cursor,
selection_end_cursor, layout.second);
bv->owner()->getToolbar()->combox->select(cursor.par->GetLayout()+1);
bv->owner()->getToolbar()->combox->select(cursor.par()->GetLayout()+1);
UpdateLocal(bv, true);
}
}
@ -899,9 +903,11 @@ LyXFont InsetText::GetFont(LyXParagraph * p, int pos) const
if (layout.labeltype == LABEL_MANUAL
&& pos < BeginningOfMainBody(p)) {
// 1% goes here
return p->GetFontSettings(pos).realize(layout.reslabelfont);
return p->GetFontSettings(buffer->params,
pos).realize(layout.reslabelfont);
} else
return p->GetFontSettings(pos).realize(layout.resfont);
return p->GetFontSettings(buffer->params,
pos).realize(layout.resfont);
} else {
// 5% goes here.
// process layoutfont for pos == -1 and labelfont for pos < -1
@ -924,7 +930,7 @@ LyXFont InsetText::GetFont(LyXParagraph * p, int pos) const
// 99% goes here
layoutfont = layout.font;
}
tmpfont = p->GetFontSettings(pos);
tmpfont = p->GetFontSettings(buffer->params, pos);
tmpfont.realize(layoutfont);
} else{
// 5% goes here.
@ -970,8 +976,8 @@ int InsetText::BeginningOfMainBody(LyXParagraph * p) const
void InsetText::GetCursorPos(int & x, int & y) const
{
x = cursor.x;
y = cursor.y;
x = cursor.x();
y = cursor.y();
}
@ -991,7 +997,7 @@ void InsetText::ToggleInsetCursor(BufferView * bv)
return;
}
LyXFont font = GetDrawFont(par, cursor.pos);
LyXFont font = GetDrawFont(par, cursor.pos());
int asc = lyxfont::maxAscent(font);
int desc = lyxfont::maxDescent(font);
@ -999,7 +1005,7 @@ void InsetText::ToggleInsetCursor(BufferView * bv)
if (cursor_visible)
bv->hideLockedInsetCursor();
else
bv->showLockedInsetCursor(cursor.x, cursor.y, asc, desc);
bv->showLockedInsetCursor(cursor.x(), cursor.y(), asc, desc);
cursor_visible = !cursor_visible;
}
@ -1011,12 +1017,12 @@ void InsetText::ShowInsetCursor(BufferView * bv)
return;
}
if (!cursor_visible) {
LyXFont font = GetDrawFont(par, cursor.pos);
LyXFont font = GetDrawFont(par, cursor.pos());
int asc = lyxfont::maxAscent(font);
int desc = lyxfont::maxDescent(font);
bv->fitLockedInsetCursor(cursor.x, cursor.y, asc, desc);
bv->showLockedInsetCursor(cursor.x, cursor.y, asc, desc);
bv->fitLockedInsetCursor(cursor.x(), cursor.y(), asc, desc);
bv->showLockedInsetCursor(cursor.x(), cursor.y(), asc, desc);
cursor_visible = true;
}
}
@ -1038,32 +1044,33 @@ void InsetText::setPos(Painter & pain, int x, int y) const
x -= drawTextXOffset;
y -= drawTextYOffset;
// search right X-pos x==0 -> top_x
cursor.pos = actrow = 0;
cursor.y = top_baseline;
y += cursor.y;
cursor.pos(0);
actrow = 0;
cursor.y(top_baseline);
y += cursor.y();
for(unsigned int i = 1;
(long(cursor.y + rows[i - 1].desc) < y)
(long(cursor.y() + rows[i - 1].desc) < y)
&& (i < rows.size() - 1); ++i) {
cursor.y = rows[i].baseline;
cursor.pos = rows[i].pos;
cursor.y(rows[i].baseline);
cursor.pos(rows[i].pos);
actrow = i;
}
cursor.y -= top_baseline;
cursor.x = top_x + 2; // 2 = frame width
x += cursor.x;
cursor.y(cursor.y() - top_baseline);
cursor.x(top_x + 2); // 2 = frame width
x += cursor.x();
int swh;
int sw = swh = SingleWidth(pain, par,cursor.pos);
if (par->GetChar(cursor.pos)!=LyXParagraph::META_INSET)
int sw = swh = SingleWidth(pain, par, cursor.pos());
if (par->GetChar(cursor.pos()) != LyXParagraph::META_INSET)
swh /= 2;
int checkpos = rows[actrow + 1].pos;
if ((actrow+2) < (int)rows.size())
if ((actrow + 2) < (int)rows.size())
--checkpos;
while ((cursor.pos < checkpos) && ((cursor.x + swh) < x)) {
cursor.x += sw;
++cursor.pos;
sw = swh = SingleWidth(pain, par,cursor.pos);
if (par->GetChar(cursor.pos)!=LyXParagraph::META_INSET)
while ((cursor.pos() < checkpos) && ((cursor.x() + swh) < x)) {
cursor.x(cursor.x() + sw);
cursor.pos(cursor.pos() + 1);
sw = swh = SingleWidth(pain, par, cursor.pos());
if (par->GetChar(cursor.pos())!=LyXParagraph::META_INSET)
swh /= 2;
}
}
@ -1071,27 +1078,27 @@ void InsetText::setPos(Painter & pain, int x, int y) const
void InsetText::resetPos(Painter & pain) const
{
cursor.par = par;
cursor.par(par);
if (!rows.size())
return;
int old_pos = cursor.pos;
int old_pos = cursor.pos();
cursor.y = top_baseline;
cursor.y(top_baseline);
actrow = 0;
for(unsigned int i = 0;
(i < (rows.size()-1)) && (rows[i].pos <= cursor.pos);
i < (rows.size() - 1) && rows[i].pos <= cursor.pos();
++i) {
cursor.y = rows[i].baseline;
cursor.y(rows[i].baseline);
actrow = i;
}
cursor.y -= top_baseline;
setPos(pain, 0, cursor.y);
cursor.x = top_x + 2; // 2 = frame width
while(cursor.pos < old_pos) {
cursor.x += SingleWidth(pain, par,cursor.pos);
++cursor.pos;
cursor.y(cursor.y() - top_baseline);
setPos(pain, 0, cursor.y());
cursor.x(top_x + 2); // 2 = frame width
while(cursor.pos() < old_pos) {
cursor.x(cursor.x() + SingleWidth(pain, par,cursor.pos()));
cursor.pos(cursor.pos() + 1);
}
}
@ -1099,14 +1106,14 @@ void InsetText::resetPos(Painter & pain) const
UpdatableInset::RESULT
InsetText::moveRight(BufferView * bv, bool activate_inset)
{
if (cursor.pos >= par->Last())
if (cursor.pos() >= par->Last())
return FINISHED;
if (activate_inset && checkAndActivateInset(bv)) {
return DISPATCHED;
}
++cursor.pos;
cursor.pos(cursor.pos() + 1);
resetPos(bv->painter());
real_current_font = current_font = GetFont(par, cursor.pos);
real_current_font = current_font = GetFont(par, cursor.pos());
return DISPATCHED_NOUPDATE;
}
@ -1114,9 +1121,9 @@ InsetText::moveRight(BufferView * bv, bool activate_inset)
UpdatableInset::RESULT
InsetText::moveLeft(BufferView * bv, bool activate_inset)
{
if (cursor.pos <= 0)
if (cursor.pos() <= 0)
return FINISHED;
--cursor.pos;
cursor.pos(cursor.pos() - 1);
resetPos(bv->painter());
if (activate_inset)
if (checkAndActivateInset(bv, -1, -1))
@ -1130,10 +1137,11 @@ InsetText::moveUp(BufferView * bv)
{
if (!actrow)
return FINISHED;
cursor.y = rows[actrow - 1].baseline - top_baseline;
if (cursor.x_fix < 0)
cursor.x_fix = cursor.x;
setPos(bv->painter(), cursor.x_fix-top_x+drawTextXOffset, cursor.y);
cursor.y(rows[actrow - 1].baseline - top_baseline);
if (cursor.x_fix() < 0)
cursor.x_fix(cursor.x());
setPos(bv->painter(),
cursor.x_fix() - top_x + drawTextXOffset, cursor.y());
return DISPATCHED_NOUPDATE;
}
@ -1143,21 +1151,22 @@ InsetText::moveDown(BufferView * bv)
{
if (actrow >= int(rows.size() - 2))
return FINISHED;
cursor.y = rows[actrow + 1].baseline - top_baseline;
if (cursor.x_fix < 0)
cursor.x_fix = cursor.x;
setPos(bv->painter(), cursor.x_fix-top_x+drawTextXOffset, cursor.y);
cursor.y(rows[actrow + 1].baseline - top_baseline);
if (cursor.x_fix() < 0)
cursor.x_fix(cursor.x());
setPos(bv->painter(),
cursor.x_fix() - top_x + drawTextXOffset, cursor.y());
return DISPATCHED_NOUPDATE;
}
bool InsetText::Delete()
{
if ((par->GetChar(cursor.pos)==LyXParagraph::META_INSET) &&
!par->GetInset(cursor.pos)->Deletable()) {
if ((par->GetChar(cursor.pos())==LyXParagraph::META_INSET) &&
!par->GetInset(cursor.pos())->Deletable()) {
return false;
}
par->Erase(cursor.pos);
par->Erase(cursor.pos());
return true;
}
@ -1170,14 +1179,14 @@ bool InsetText::InsertInset(BufferView * bv, Inset * inset)
return false;
}
bv->text->SetUndo(Undo::INSERT,
bv->text->cursor.par->ParFromPos(bv->text->cursor.pos)->previous,
bv->text->cursor.par->ParFromPos(bv->text->cursor.pos)->next);
bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
if (inset->Editable() == Inset::IS_EDITABLE) {
UpdatableInset *i = (UpdatableInset *)inset;
i->setOwner((UpdatableInset *)this);
UpdatableInset * i = static_cast<UpdatableInset *>(inset);
i->setOwner(static_cast<UpdatableInset *>(this));
}
par->InsertChar(cursor.pos, LyXParagraph::META_INSET);
par->InsertInset(cursor.pos, inset);
par->InsertChar(cursor.pos(), LyXParagraph::META_INSET);
par->InsertInset(cursor.pos(), inset);
if (hasSelection()) {
selection_start_cursor = selection_end_cursor = cursor;
} else {
@ -1211,7 +1220,7 @@ void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall)
if (!hasSelection()) {
// Determine basis font
LyXFont layoutfont;
if (cursor.pos < BeginningOfMainBody(par))
if (cursor.pos() < BeginningOfMainBody(par))
layoutfont = GetFont(par, -2);
else
layoutfont = GetFont(par, -1);
@ -1229,12 +1238,12 @@ void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall)
}
int s_start, s_end;
if (selection_start_cursor.pos > selection_end_cursor.pos) {
s_start = selection_end_cursor.pos;
s_end = selection_start_cursor.pos;
if (selection_start_cursor.pos() > selection_end_cursor.pos()) {
s_start = selection_end_cursor.pos();
s_end = selection_start_cursor.pos();
} else {
s_start = selection_start_cursor.pos;
s_end = selection_end_cursor.pos;
s_start = selection_start_cursor.pos();
s_end = selection_end_cursor.pos();
}
LyXFont newfont;
while(s_start < s_end) {
@ -1456,7 +1465,7 @@ void InsetText::UpdateLocal(BufferView * bv, bool flag)
bv->updateInset(this, flag);
if (flag)
resetPos(bv->painter());
bv->owner()->getToolbar()->combox->select(cursor.par->GetLayout()+1);
bv->owner()->getToolbar()->combox->select(cursor.par()->GetLayout()+1);
}
@ -1469,15 +1478,16 @@ bool InsetText::cutSelection()
LyXParagraph * endpar = par;
int start, end;
if (selection_start_cursor.pos > selection_end_cursor.pos) {
start = selection_end_cursor.pos;
end = selection_start_cursor.pos;
if (selection_start_cursor.pos() > selection_end_cursor.pos()) {
start = selection_end_cursor.pos();
end = selection_start_cursor.pos();
} else {
start = selection_start_cursor.pos;
end = selection_end_cursor.pos;
start = selection_start_cursor.pos();
end = selection_end_cursor.pos();
}
return cap.cutSelection(par, &endpar, start, end,buffer->params.textclass);
return cap.cutSelection(par, &endpar,
start, end, buffer->params.textclass);
}
@ -1489,12 +1499,12 @@ bool InsetText::copySelection()
CutAndPaste cap;
int start, end;
if (selection_start_cursor.pos > selection_end_cursor.pos) {
start = selection_end_cursor.pos;
end = selection_start_cursor.pos;
if (selection_start_cursor.pos() > selection_end_cursor.pos()) {
start = selection_end_cursor.pos();
end = selection_start_cursor.pos();
} else {
start = selection_start_cursor.pos;
end = selection_end_cursor.pos;
start = selection_start_cursor.pos();
end = selection_end_cursor.pos();
}
return cap.copySelection(par, par, start, end, buffer->params.textclass);
}
@ -1510,28 +1520,31 @@ bool InsetText::pasteSelection()
_("Sorry."));
return false;
}
LyXParagraph *endpar;
LyXParagraph *actpar = par;
LyXParagraph * endpar;
LyXParagraph * actpar = par;
return cap.pasteSelection(&actpar, &endpar, cursor.pos,
buffer->params.textclass);
int pos = cursor.pos();
bool ret = cap.pasteSelection(&actpar, &endpar, pos,
buffer->params.textclass);
cursor.pos(pos);
return ret;
}
bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
int button)
{
if (par->GetChar(cursor.pos) == LyXParagraph::META_INSET) {
if (par->GetChar(cursor.pos()) == LyXParagraph::META_INSET) {
UpdatableInset * inset =
static_cast<UpdatableInset*>(par->GetInset(cursor.pos));
LyXFont font = GetFont(par, cursor.pos);
static_cast<UpdatableInset*>(par->GetInset(cursor.pos()));
LyXFont font = GetFont(par, cursor.pos());
if (x < 0)
x = inset->width(bv->painter(), font);
if (y < 0)
y = inset->descent(bv->painter(), font);
inset_x = cursor.x - top_x + drawTextXOffset;
inset_y = cursor.y + drawTextYOffset;
inset->Edit(bv, x-inset_x, y-inset_y, button);
inset_x = cursor.x() - top_x + drawTextXOffset;
inset_y = cursor.y() + drawTextYOffset;
inset->Edit(bv, x - inset_x, y - inset_y, button);
if (!the_locking_inset)
return false;
UpdateLocal(bv, true);

View File

@ -281,8 +281,8 @@ void Intl::InitKeyMapper(bool on)
Language2->addto("default");
for (Languages::const_iterator cit = languages.begin();
cit != languages.end(); ++cit) {
Language->addto((*cit).second.lang.c_str());
Language2->addto((*cit).second.lang.c_str());
Language->addto((*cit).second.lang().c_str());
Language2->addto((*cit).second.lang().c_str());
++n;
}

View File

@ -5,13 +5,33 @@
#include <map>
#include "LString.h"
struct Language {
Language() : RightToLeft(false) {}
///
class Language {
public:
///
Language() : RightToLeft_(false) {}
///
Language(string const & l, string const & d, bool rtl)
: lang(l), display(d), RightToLeft(rtl) {}
string lang;
string display;
bool RightToLeft;
: lang_(l), display_(d), RightToLeft_(rtl) {}
///
string const & lang() const {
return lang_;
}
///
string const & display() const {
return display_;
}
///
bool RightToLeft() const {
return RightToLeft_;
}
private:
///
string lang_;
///
string display_;
///
bool RightToLeft_;
};
#if 0

View File

@ -78,8 +78,6 @@ extern FD_form_ref * fd_form_ref;
extern FD_LaTeXOptions * fd_latex_options;
extern FD_form_bullet * fd_form_bullet;
#define XFORMS_CLIPBOARD 1
extern BufferView * current_view; // called too many times in this file...
extern void DeleteSimpleCutBuffer(); /* for the cleanup when exiting */
@ -185,10 +183,11 @@ void ShowMessage(Buffer * buf,
}
#if 0
// only called from this file, LyXView and LyXFunc
char updatetimer = 0;
// only called from BufferView_pimpl and LyXFunc
void FreeUpdateTimer()
{
@ -197,13 +196,13 @@ void FreeUpdateTimer()
updatetimer = 0;
}
// Only called from LyXFunc
void SetUpdateTimer(float time)
{
fl_set_timer(current_view->owner()->getMainForm()->timer_update, time);
updatetimer = 1;
}
#endif
//
@ -1225,28 +1224,6 @@ void MenuInsertRef()
}
#ifndef XFORMS_CLIPBOARD
void MenuPasteSelection(char at)
{
if (!current_view->available())
return;
ascii_type = at;
Atom data_prop = XInternAtom(fl_display,
"LyX_Primary",
false);
if (data_prop == None)
return;
XConvertSelection(fl_display,
XA_PRIMARY, XA_STRING, data_prop,
current_view->owner()->getForm()->window, 0);
XFlush(fl_display);
}
#endif
// candidate for move to LyXView
// This is only used in toolbar.C
void LayoutsCB(int sel, void *)
@ -1476,16 +1453,16 @@ bool UpdateLayoutParagraph()
Buffer * buf = current_view->buffer();
fl_set_input(fd_form_paragraph->input_labelwidth,
current_view->text->cursor.par->GetLabelWidthString().c_str());
current_view->text->cursor.par()->GetLabelWidthString().c_str());
fl_set_button(fd_form_paragraph->radio_align_right, 0);
fl_set_button(fd_form_paragraph->radio_align_left, 0);
fl_set_button(fd_form_paragraph->radio_align_center, 0);
fl_set_button(fd_form_paragraph->radio_align_block, 0);
int align = current_view->text->cursor.par->GetAlign();
int align = current_view->text->cursor.par()->GetAlign();
if (align == LYX_ALIGN_LAYOUT)
align = textclasslist.Style(buf->params.textclass,
current_view->text->cursor.par->GetLayout()).align;
current_view->text->cursor.par()->GetLayout()).align;
switch (align) {
case LYX_ALIGN_RIGHT:
@ -1503,18 +1480,18 @@ bool UpdateLayoutParagraph()
}
fl_set_button(fd_form_paragraph->check_lines_top,
current_view->text->cursor.par->FirstPhysicalPar()->line_top);
current_view->text->cursor.par()->FirstPhysicalPar()->line_top);
fl_set_button(fd_form_paragraph->check_lines_bottom,
current_view->text->cursor.par->FirstPhysicalPar()->line_bottom);
current_view->text->cursor.par()->FirstPhysicalPar()->line_bottom);
fl_set_button(fd_form_paragraph->check_pagebreaks_top,
current_view->text->cursor.par->FirstPhysicalPar()->pagebreak_top);
current_view->text->cursor.par()->FirstPhysicalPar()->pagebreak_top);
fl_set_button(fd_form_paragraph->check_pagebreaks_bottom,
current_view->text->cursor.par->FirstPhysicalPar()->pagebreak_bottom);
current_view->text->cursor.par()->FirstPhysicalPar()->pagebreak_bottom);
fl_set_button(fd_form_paragraph->check_noindent,
current_view->text->cursor.par->FirstPhysicalPar()->noindent);
current_view->text->cursor.par()->FirstPhysicalPar()->noindent);
fl_set_input (fd_form_paragraph->input_space_above, "");
switch (current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.kind()) {
switch (current_view->text->cursor.par()->FirstPhysicalPar()->added_space_top.kind()) {
case VSpace::NONE:
fl_set_choice (fd_form_paragraph->choice_space_above, 1);
break;
@ -1536,13 +1513,13 @@ bool UpdateLayoutParagraph()
case VSpace::LENGTH:
fl_set_choice (fd_form_paragraph->choice_space_above, 7);
fl_set_input (fd_form_paragraph->input_space_above,
current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.length().asString().c_str());
current_view->text->cursor.par()->FirstPhysicalPar()->added_space_top.length().asString().c_str());
break;
}
fl_set_button (fd_form_paragraph->check_space_above,
current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.keep());
current_view->text->cursor.par()->FirstPhysicalPar()->added_space_top.keep());
fl_set_input (fd_form_paragraph->input_space_below, "");
switch (current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.kind()) {
switch (current_view->text->cursor.par()->FirstPhysicalPar()->added_space_bottom.kind()) {
case VSpace::NONE:
fl_set_choice (fd_form_paragraph->choice_space_below,
1);
@ -1571,14 +1548,14 @@ bool UpdateLayoutParagraph()
fl_set_choice (fd_form_paragraph->choice_space_below,
7);
fl_set_input (fd_form_paragraph->input_space_below,
current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.length().asString().c_str());
current_view->text->cursor.par()->FirstPhysicalPar()->added_space_bottom.length().asString().c_str());
break;
}
fl_set_button (fd_form_paragraph->check_space_below,
current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.keep());
current_view->text->cursor.par()->FirstPhysicalPar()->added_space_bottom.keep());
fl_set_button(fd_form_paragraph->check_noindent,
current_view->text->cursor.par->FirstPhysicalPar()->noindent);
current_view->text->cursor.par()->FirstPhysicalPar()->noindent);
if (current_view->buffer()->isReadonly()) {
DisableParagraphLayout();
@ -2375,13 +2352,13 @@ extern "C" void DocumentApplyCB(FL_OBJECT *, long)
new_language = default_language;
if (current_view->available()) {
if (old_language != new_language &&
old_language->RightToLeft == new_language->RightToLeft &&
! current_view->buffer()->isMultiLingual() )
if (old_language != new_language
&& old_language->RightToLeft() == new_language->RightToLeft()
&& !current_view->buffer()->isMultiLingual())
current_view->buffer()->ChangeLanguage(old_language,
new_language);
if (old_language != new_language) {
//current_view->buffer()->redraw();
//current_view->buffer()->redraw();
redo = true;
}
}
@ -2415,8 +2392,8 @@ extern "C" void DocumentApplyCB(FL_OBJECT *, long)
if (!current_view->available())
return;
current_view->text->SetCursor(current_view->text->cursor.par,
current_view->text->cursor.pos);
current_view->text->SetCursor(current_view->text->cursor.par(),
current_view->text->cursor.pos());
current_view->setState();
LyXTextClassList::ClassList::size_type new_class =
@ -2532,10 +2509,9 @@ extern "C" void DocumentApplyCB(FL_OBJECT *, long)
current_view->owner()->getMiniBuffer()->Set(_("Document layout set"));
current_view->buffer()->markDirty();
params->options =
fl_get_input(fd_form_document->input_extra);
}
@ -2647,7 +2623,7 @@ extern "C" void TableApplyCB(FL_OBJECT *, long)
return;
// check for tables in tables
if (current_view->text->cursor.par->table){
if (current_view->text->cursor.par()->table){
WriteAlert(_("Impossible Operation!"),
_("Cannot insert table in table."),
_("Sorry."));
@ -2670,7 +2646,7 @@ extern "C" void TableApplyCB(FL_OBJECT *, long)
current_view->text->BreakParagraph();
current_view->update(-1);
if (current_view->text->cursor.par->Last()) {
if (current_view->text->cursor.par()->Last()) {
current_view->text->CursorLeft();
current_view->text->BreakParagraph();
@ -2681,7 +2657,7 @@ extern "C" void TableApplyCB(FL_OBJECT *, long)
//if (!fl_get_button(fd_form_table->check_latex)){
// insert the new wysiwy table
current_view->text->SetLayout(0); // standard layout
if (current_view->text->cursor.par->footnoteflag ==
if (current_view->text->cursor.par()->footnoteflag ==
LyXParagraph::NO_FOOTNOTE) {
current_view->text
->SetParagraph(0, 0,
@ -2706,15 +2682,15 @@ extern "C" void TableApplyCB(FL_OBJECT *, long)
0);
}
current_view->text->cursor.par->table =
current_view->text->cursor.par()->table =
new LyXTable(xsize, ysize);
Language const * lang =
current_view->text->cursor.par->getParLanguage();
current_view->text->cursor.par()->getParLanguage(current_view->buffer()->params);
LyXFont font(LyXFont::ALL_INHERIT, lang);
for (int i = 0; i < xsize * ysize - 1; ++i) {
current_view->text->cursor.par->InsertChar(0, LyXParagraph::META_NEWLINE);
current_view->text->cursor.par->SetFont(0, font);
current_view->text->cursor.par()->InsertChar(0, LyXParagraph::META_NEWLINE);
current_view->text->cursor.par()->SetFont(0, font);
}
current_view->text->RedoParagraph();
@ -2956,7 +2932,7 @@ extern "C" void FigureApplyCB(FL_OBJECT *, long)
current_view->owner()->getMiniBuffer()->Set(_("Inserting figure..."));
if (fl_get_button(fd_form_figure->radio_inline)
|| current_view->text->cursor.par->table) {
|| current_view->text->cursor.par()->table) {
InsetFig * new_inset = new InsetFig(100, 20, buffer);
current_view->insertInset(new_inset);
current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
@ -2974,7 +2950,7 @@ extern "C" void FigureApplyCB(FL_OBJECT *, long)
current_view->text->BreakParagraph();
current_view->update(-1);
if (current_view->text->cursor.par->Last()) {
if (current_view->text->cursor.par()->Last()) {
current_view->text->CursorLeft();
current_view->text->BreakParagraph();
@ -2984,7 +2960,7 @@ extern "C" void FigureApplyCB(FL_OBJECT *, long)
// The standard layout should always be numer 0;
current_view->text->SetLayout(0);
if (current_view->text->cursor.par->footnoteflag ==
if (current_view->text->cursor.par()->footnoteflag ==
LyXParagraph::NO_FOOTNOTE) {
current_view->text->
SetParagraph(0, 0,

View File

@ -400,8 +400,8 @@ void LyXGUI::create_forms()
combo_language2->addto("No change");
for(Languages::const_iterator cit = languages.begin();
cit != languages.end(); ++cit) {
combo_language->addto((*cit).second.lang.c_str());
combo_language2->addto((*cit).second.lang.c_str());
combo_language->addto((*cit).second.lang().c_str());
combo_language2->addto((*cit).second.lang().c_str());
}
combo_language2->select_text("No change");

106
src/lyxcursor.C Normal file
View File

@ -0,0 +1,106 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#include "lyxcursor.h"
void LyXCursor::par(LyXParagraph * p)
{
par_ = p;
}
LyXParagraph * LyXCursor::par()
{
return par_;
}
LyXParagraph * LyXCursor::par() const
{
return par_;
}
void LyXCursor::pos(LyXParagraph::size_type p)
{
pos_ = p;
}
LyXParagraph::size_type LyXCursor::pos() const
{
return pos_;
}
void LyXCursor::boundary(bool b)
{
boundary_ = b;
}
bool LyXCursor::boundary() const
{
return boundary_;
}
void LyXCursor::x(int n)
{
x_ = n;
}
int LyXCursor::x() const
{
return x_;
}
void LyXCursor::x_fix(int i)
{
x_fix_ = i;
}
int LyXCursor::x_fix() const
{
return x_fix_;
}
void LyXCursor::y(unsigned long i)
{
y_ = i;
}
unsigned long LyXCursor::y() const
{
return y_;
}
void LyXCursor::row(Row * r)
{
row_ = r;
}
Row * LyXCursor::row()
{
return row_;
}
Row * LyXCursor::row() const
{
return row_;
}

View File

@ -18,26 +18,73 @@ struct Row;
/** All these variables should be explained. Matthias?
*/
struct LyXCursor {
class LyXCursor {
public:
///
LyXParagraph * par;
void par(LyXParagraph * p);
///
LyXParagraph::size_type pos;
LyXParagraph * par();
///
bool boundary;
LyXParagraph * par() const;
///
int x;
void pos(LyXParagraph::size_type p);
///
int x_fix;
LyXParagraph::size_type pos() const;
///
unsigned long y;
void boundary(bool b);
///
Row * row;
bool boundary() const;
///
inline bool operator==(const LyXCursor &a) const
{ return a.par == par && a.pos == pos && a.boundary == boundary ; }
inline bool operator!=(const LyXCursor &a) const
{ return a.par != par || a.pos != pos || a.boundary != boundary; }
void x(int i);
///
int x() const;
///
void x_fix(int i);
///
int x_fix() const;
///
void y(unsigned long i);
///
unsigned long y() const;
///
void row(Row * r);
///
Row * row();
///
Row * row() const;
private:
/// The paragraph the cursor is in.
LyXParagraph * par_;
/// The position inside the paragraph
LyXParagraph::size_type pos_;
///
bool boundary_;
///
int x_;
///
int x_fix_;
///
unsigned long y_;
///
Row * row_;
};
///
inline
bool operator==(LyXCursor const & a, LyXCursor const & b)
{
return (a.par() == b.par())
&& (a.pos() == b.pos())
&& a.boundary() == b.boundary();
}
///
inline
bool operator!=(LyXCursor const & a, LyXCursor const & b)
{
return !(a == b);
}
#endif

View File

@ -412,7 +412,7 @@ string LyXFont::stateText(BufferParams * params) const
if (bits == inherit)
ost << _("Default") << ", ";
if (!params || language() != params->language_info)
ost << _("Language: ") << _(language()->display.c_str());
ost << _("Language: ") << _(language()->display().c_str());
#ifdef HAVE_SSTREAM
string buf(ost.str().c_str());
#else
@ -666,7 +666,7 @@ void LyXFont::lyxWriteChanges(LyXFont const & orgfont, ostream & os) const
}
if (orgfont.language() != language()) {
if (language())
os << "\\lang " << language()->lang << "\n";
os << "\\lang " << language()->lang() << "\n";
else
os << "\\lang unknown\n";
}
@ -695,7 +695,7 @@ int LyXFont::latexWriteStartChanges(ostream & os, LyXFont const & base,
} else {
string tmp = '{' +
subst(lyxrc.language_command_begin,
"$$lang", language()->lang);
"$$lang", language()->lang());
os << tmp;
count += tmp.length();
env = true; //We have opened a new environment

View File

@ -325,8 +325,7 @@ public:
///
friend
bool operator!=(LyXFont const & font1, LyXFont const & font2) {
return font1.bits != font2.bits ||
font1.lang != font2.lang;
return !(font1 == font2);
}
/// compares two fonts, ignoring the setting of the Latex part.
@ -527,14 +526,14 @@ Language const * LyXFont::language() const
inline
bool LyXFont::isRightToLeft() const
{
return lang->RightToLeft;
return lang->RightToLeft();
}
inline
bool LyXFont::isVisibleRightToLeft() const
{
return (lang->RightToLeft && latex() != ON);
return (lang->RightToLeft() && latex() != ON);
}

View File

@ -32,13 +32,13 @@ string GetCurrentSelectionAsString(LyXText * lt)
{
string sz;
LyXParagraph * par = lt->cursor.par;
if (lt->selection && lt->sel_cursor.par == par) {
LyXParagraph * par = lt->cursor.par();
if (lt->selection && lt->sel_cursor.par() == par) {
// (selected) and (begin/end in same paragraph)
LyXParagraph::size_type pos =
lt->sel_start_cursor.pos;
lt->sel_start_cursor.pos();
LyXParagraph::size_type endpos =
lt->sel_end_cursor.pos;
lt->sel_end_cursor.pos();
bool fPrevIsSpace = false;
char ch;
while (pos < par->Last() && pos < endpos) {
@ -252,8 +252,8 @@ bool LyXFindReplace::SearchCB(bool fForward)
// (was: LyXText::SearchForward(char const* string) in text2.C )
bool LyXFindReplace::SearchForward(LyXText * lt)
{
LyXParagraph * par = lt->cursor.par;
LyXParagraph::size_type pos = lt->cursor.pos;
LyXParagraph * par = lt->cursor.par();
LyXParagraph::size_type pos = lt->cursor.pos();
while (par && !IsSearchStringInText(par, pos)) {
if (pos < par->Last() - 1)
@ -276,8 +276,8 @@ bool LyXFindReplace::SearchForward(LyXText * lt)
// (was: LyXText::SearchBackward(char const* string) in text2.C )
bool LyXFindReplace::SearchBackward(LyXText * lt)
{
LyXParagraph * par = lt->cursor.par;
int pos = lt->cursor.pos;
LyXParagraph * par = lt->cursor.par();
int pos = lt->cursor.pos();
do {
if (pos > 0)

View File

@ -109,19 +109,15 @@ extern void QuitLyX();
extern void MenuFax(Buffer *);
extern void MenuExport(Buffer *, string const &);
#define XFORMS_CLIPBOARD 1
#ifndef XFORMS_CLIPBOARD
extern void MenuPasteSelection(char at);
#endif
extern LyXAction lyxaction;
// (alkis)
extern tex_accent_struct get_accent(kb_action action);
extern void AutoSave(BufferView *);
#if 0
extern void SetUpdateTimer(float timer = 0.3);
extern void FreeUpdateTimer();
#endif
extern bool PreviewDVI(Buffer *);
extern bool PreviewPostscript(Buffer *);
extern void MenuInsertLabel(char const *);
@ -407,7 +403,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
disable = lyxrc.chktex_command == "none";
break;
case LFUN_LAYOUT_TABLE:
disable = ! owner->view()->text->cursor.par->table;
disable = ! owner->view()->text->cursor.par()->table;
break;
default:
break;
@ -556,12 +552,12 @@ string LyXFunc::Dispatch(int ac,
inset->GetCursorPos(slx, sly);
owner->view()->unlockInset(inset);
owner->view()->menuUndo();
if (owner->view()->text->cursor.par->
IsInset(owner->view()->text->cursor.pos)) {
if (owner->view()->text->cursor.par()->
IsInset(owner->view()->text->cursor.pos())) {
inset = static_cast<UpdatableInset*>(
owner->view()->text->cursor.par->
owner->view()->text->cursor.par()->
GetInset(owner->view()->text->
cursor.pos));
cursor.pos()));
} else {
inset = 0;
}
@ -576,9 +572,9 @@ string LyXFunc::Dispatch(int ac,
owner->view()->unlockInset(inset);
owner->view()->menuRedo();
inset = static_cast<UpdatableInset*>(
owner->view()->text->cursor.par->
owner->view()->text->cursor.par()->
GetInset(owner->view()->text->
cursor.pos));
cursor.pos()));
if (inset)
inset->Edit(owner->view(),slx,sly,0);
return string();
@ -599,7 +595,7 @@ string LyXFunc::Dispatch(int ac,
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_RIGHT:
if (!owner->view()->text->cursor.par->isRightToLeftPar()) {
if (!owner->view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
owner->view()->text->CursorRight();
moveCursorUpdate(false);
owner->getMiniBuffer()->
@ -607,7 +603,7 @@ string LyXFunc::Dispatch(int ac,
}
return string();
case LFUN_LEFT:
if (owner->view()->text->cursor.par->isRightToLeftPar()) {
if (owner->view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
owner->view()->text->CursorRight();
moveCursorUpdate(false);
owner->getMiniBuffer()->
@ -920,11 +916,7 @@ string LyXFunc::Dispatch(int ac,
{
bool asPara = false;
if (argument == "paragraph") asPara = true;
#ifdef XFORMS_CLIPBOARD
owner->view()->pasteClipboard(asPara);
#else
MenuPasteSelection(asPara);
#endif
}
break;
@ -1020,10 +1012,10 @@ string LyXFunc::Dispatch(int ac,
case LFUN_FOOTMELT:
if (owner->view()->available()
&& !owner->view()->text->selection
&& owner->view()->text->cursor.par->footnoteflag
&& owner->view()->text->cursor.par()->footnoteflag
!= LyXParagraph::NO_FOOTNOTE)
{ // only melt footnotes with FOOTMELT, not margins etc
if(owner->view()->text->cursor.par->footnotekind == LyXParagraph::FOOTNOTE)
if(owner->view()->text->cursor.par()->footnotekind == LyXParagraph::FOOTNOTE)
Melt(owner->view());
}
else
@ -1034,10 +1026,10 @@ string LyXFunc::Dispatch(int ac,
case LFUN_MARGINMELT:
if (owner->view()->available()
&& !owner->view()->text->selection
&& owner->view()->text->cursor.par->footnoteflag
&& owner->view()->text->cursor.par()->footnoteflag
!= LyXParagraph::NO_FOOTNOTE) {
// only melt margins
if(owner->view()->text->cursor.par->footnotekind == LyXParagraph::MARGIN)
if(owner->view()->text->cursor.par()->footnotekind == LyXParagraph::MARGIN)
Melt(owner->view());
} else
Margin(owner->view());
@ -1174,7 +1166,7 @@ string LyXFunc::Dispatch(int ac,
SetLayout(layout.second);
owner->getToolbar()->combox->
select(owner->view()->
text->cursor.par->
text->cursor.par()->
GetLayout() + 1);
owner->view()->update(1);
owner->view()->setState();
@ -1279,26 +1271,50 @@ string LyXFunc::Dispatch(int ac,
case LFUN_UPCASE_WORD:
owner->view()->update(-2);
#if 1
//owner->update_timeout.stop();
#else
FreeUpdateTimer();
#endif
owner->view()->text->ChangeWordCase(LyXText::text_uppercase);
owner->view()->update(1);
#if 1
//owner->update_timeout.start();
#else
SetUpdateTimer();
#endif
break;
case LFUN_LOWCASE_WORD:
owner->view()->update(-2);
#if 1
//owner->update_timeout.stop();
#else
FreeUpdateTimer();
#endif
owner->view()->text->ChangeWordCase(LyXText::text_lowercase);
owner->view()->update(1);
#if 1
//owner->update_timeout.start();
#else
SetUpdateTimer();
#endif
break;
case LFUN_CAPITALIZE_WORD:
owner->view()->update(-2);
#if 1
//owner->update_timeout.stop();
#else
FreeUpdateTimer();
#endif
owner->view()->text->ChangeWordCase(LyXText::text_capitalization);
owner->view()->update(1);
#if 1
//owner->update_timeout.start();
#else
SetUpdateTimer();
#endif
break;
case LFUN_INSERT_LABEL:
@ -1361,18 +1377,18 @@ string LyXFunc::Dispatch(int ac,
case LFUN_RIGHT:
{
LyXText * tmptext = owner->view()->text;
bool is_rtl = tmptext->cursor.par->isRightToLeftPar();
bool is_rtl = tmptext->cursor.par()->isRightToLeftPar(owner->buffer()->params);
if(!tmptext->mark_set)
owner->view()->beforeChange();
owner->view()->update(-2);
if (is_rtl)
tmptext->CursorLeft(false);
if (tmptext->cursor.pos < tmptext->cursor.par->Last()
&& tmptext->cursor.par->GetChar(tmptext->cursor.pos)
if (tmptext->cursor.pos() < tmptext->cursor.par()->Last()
&& tmptext->cursor.par()->GetChar(tmptext->cursor.pos())
== LyXParagraph::META_INSET
&& tmptext->cursor.par->GetInset(tmptext->cursor.pos)
&& tmptext->cursor.par->GetInset(tmptext->cursor.pos)->Editable() == Inset::HIGHLY_EDITABLE){
Inset * tmpinset = tmptext->cursor.par->GetInset(tmptext->cursor.pos);
&& tmptext->cursor.par()->GetInset(tmptext->cursor.pos())
&& tmptext->cursor.par()->GetInset(tmptext->cursor.pos())->Editable() == Inset::HIGHLY_EDITABLE){
Inset * tmpinset = tmptext->cursor.par()->GetInset(tmptext->cursor.pos());
setMessage(tmpinset->EditMessage());
tmpinset->Edit(owner->view(), 0, 0, 0);
break;
@ -1390,20 +1406,20 @@ string LyXFunc::Dispatch(int ac,
// This is soooo ugly. Isn`t it possible to make
// it simpler? (Lgb)
LyXText * txt = owner->view()->text;
bool is_rtl = txt->cursor.par->isRightToLeftPar();
bool is_rtl = txt->cursor.par()->isRightToLeftPar(owner->buffer()->params);
if(!txt->mark_set) owner->view()->beforeChange();
owner->view()->update(-2);
if (!is_rtl)
txt->CursorLeft(false);
if (txt->cursor.pos < txt->cursor.par->Last()
&& txt->cursor.par->GetChar(txt->cursor.pos)
if (txt->cursor.pos() < txt->cursor.par()->Last()
&& txt->cursor.par()->GetChar(txt->cursor.pos())
== LyXParagraph::META_INSET
&& txt->cursor.par->GetInset(txt->cursor.pos)
&& txt->cursor.par->GetInset(txt->cursor.pos)->Editable() == Inset::HIGHLY_EDITABLE) {
Inset * tmpinset = txt->cursor.par->GetInset(txt->cursor.pos);
&& txt->cursor.par()->GetInset(txt->cursor.pos())
&& txt->cursor.par()->GetInset(txt->cursor.pos())->Editable() == Inset::HIGHLY_EDITABLE) {
Inset * tmpinset = txt->cursor.par()->GetInset(txt->cursor.pos());
setMessage(tmpinset->EditMessage());
LyXFont font = txt->GetFont(txt->cursor.par,
txt->cursor.pos);
LyXFont font = txt->GetFont(txt->cursor.par(),
txt->cursor.pos());
tmpinset->Edit(owner->view(),
tmpinset->x() + tmpinset->width(owner->view()->painter(),font),
tmpinset->descent(owner->view()->painter(),font),
@ -1513,7 +1529,7 @@ string LyXFunc::Dispatch(int ac,
if(!owner->view()->text->mark_set)
owner->view()->beforeChange();
owner->view()->update(-2);
if (owner->view()->text->cursor.par->isRightToLeftPar())
if (owner->view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params))
owner->view()->text->CursorLeftOneWord();
else
owner->view()->text->CursorRightOneWord();
@ -1526,7 +1542,7 @@ string LyXFunc::Dispatch(int ac,
if(!owner->view()->text->mark_set)
owner->view()->beforeChange();
owner->view()->update(-2);
if (owner->view()->text->cursor.par->isRightToLeftPar())
if (owner->view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params))
owner->view()->text->CursorRightOneWord();
else
owner->view()->text->CursorLeftOneWord();
@ -1559,7 +1575,7 @@ string LyXFunc::Dispatch(int ac,
/* cursor selection ---------------------------- */
case LFUN_RIGHTSEL:
owner->view()->update(-2);
if (owner->view()->text->cursor.par->isRightToLeftPar())
if (owner->view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params))
owner->view()->text->CursorLeft();
else
owner->view()->text->CursorRight();
@ -1570,7 +1586,7 @@ string LyXFunc::Dispatch(int ac,
case LFUN_LEFTSEL:
owner->view()->update(-2);
if (owner->view()->text->cursor.par->isRightToLeftPar())
if (owner->view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params))
owner->view()->text->CursorRight();
else
owner->view()->text->CursorLeft();
@ -1645,7 +1661,7 @@ string LyXFunc::Dispatch(int ac,
case LFUN_WORDRIGHTSEL:
owner->view()->update(-2);
if (owner->view()->text->cursor.par->isRightToLeftPar())
if (owner->view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params))
owner->view()->text->CursorLeftOneWord();
else
owner->view()->text->CursorRightOneWord();
@ -1656,7 +1672,7 @@ string LyXFunc::Dispatch(int ac,
case LFUN_WORDLEFTSEL:
owner->view()->update(-2);
if (owner->view()->text->cursor.par->isRightToLeftPar())
if (owner->view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params))
owner->view()->text->CursorRightOneWord();
else
owner->view()->text->CursorLeftOneWord();
@ -1686,7 +1702,11 @@ string LyXFunc::Dispatch(int ac,
owner->view()->beforeChange();
owner->view()->text->InsertChar(LyXParagraph::META_NEWLINE);
owner->view()->update(1);
#if 1
//owner->update_timeout.callback();
#else
SetUpdateTimer(0.01);
#endif
moveCursorUpdate(false);
break;
@ -1694,7 +1714,7 @@ string LyXFunc::Dispatch(int ac,
{
LyXLayout const & style =
textclasslist.Style(owner->view()->buffer()->params.textclass,
owner->view()->text->cursor.par->GetLayout());
owner->view()->text->cursor.par()->GetLayout());
if (style.free_spacing) {
owner->view()->text->InsertChar(' ');
@ -1722,7 +1742,11 @@ string LyXFunc::Dispatch(int ac,
break;
case LFUN_DELETE:
#if 1
//owner->update_timeout.stop();
#else
FreeUpdateTimer();
#endif
if (!owner->view()->text->selection) {
owner->view()->text->Delete();
owner->view()->text->sel_cursor =
@ -1734,7 +1758,11 @@ string LyXFunc::Dispatch(int ac,
} else {
owner->view()->cut();
}
#if 1
//owner->update_timeout.start();
#else
SetUpdateTimer();
#endif
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
owner->view()->setState();
@ -1746,23 +1774,27 @@ string LyXFunc::Dispatch(int ac,
LyXCursor cursor = owner->view()->text->cursor;
#if 1
//owner->update_timeout.stop();
#else
FreeUpdateTimer();
#endif
if (!owner->view()->text->selection) {
if (cursor.pos == cursor.par->Last()) {
if (cursor.pos() == cursor.par()->Last()) {
owner->view()->text->CursorRight();
cursor = owner->view()->text->cursor;
if (cursor.pos == 0
&& !(cursor.par->added_space_top
if (cursor.pos() == 0
&& !(cursor.par()->added_space_top
== VSpace (VSpace::NONE))) {
owner->view()->text->SetParagraph
(cursor.par->line_top,
cursor.par->line_bottom,
cursor.par->pagebreak_top,
cursor.par->pagebreak_bottom,
(cursor.par()->line_top,
cursor.par()->line_bottom,
cursor.par()->pagebreak_top,
cursor.par()->pagebreak_bottom,
VSpace(VSpace::NONE),
cursor.par->added_space_bottom,
cursor.par->align,
cursor.par->labelwidthstring, 0);
cursor.par()->added_space_bottom,
cursor.par()->align,
cursor.par()->labelwidthstring, 0);
owner->view()->text->CursorLeft();
owner->view()->update (1);
} else {
@ -1781,17 +1813,29 @@ string LyXFunc::Dispatch(int ac,
} else {
owner->view()->cut();
}
#if 1
//owner->update_timeout.start();
#else
SetUpdateTimer();
#endif
}
break;
/* -------> Delete word forward. */
case LFUN_DELETE_WORD_FORWARD:
owner->view()->update(-2);
#if 1
//owner->update_timeout.stop();
#else
FreeUpdateTimer();
#endif
owner->view()->text->DeleteWordForward();
owner->view()->update( 1 );
#if 1
//owner->update_timeout.start();
#else
SetUpdateTimer();
#endif
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
@ -1799,21 +1843,37 @@ string LyXFunc::Dispatch(int ac,
/* -------> Delete word backward. */
case LFUN_DELETE_WORD_BACKWARD:
owner->view()->update(-2);
#if 1
//owner->update_timeout.stop();
#else
FreeUpdateTimer();
#endif
owner->view()->text->DeleteWordBackward();
owner->view()->update( 1 );
#if 1
//owner->update_timeout.start();
#else
SetUpdateTimer();
#endif
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
/* -------> Kill to end of line. */
case LFUN_DELETE_LINE_FORWARD:
#if 1
//owner->update_timeout.stop();
#else
FreeUpdateTimer();
#endif
owner->view()->update(-2);
owner->view()->text->DeleteLineForward();
owner->view()->update( 1 );
#if 1
//owner->update_timeout.start();
#else
SetUpdateTimer();
#endif
moveCursorUpdate(false);
break;
@ -1838,7 +1898,11 @@ string LyXFunc::Dispatch(int ac,
case LFUN_BACKSPACE:
{
#if 1
//owner->update_timeout.stop();
#else
FreeUpdateTimer();
#endif
if (!owner->view()->text->selection) {
if (owner->getIntl()->getTrans()->backspace()) {
owner->view()->text->Backspace();
@ -1852,7 +1916,11 @@ string LyXFunc::Dispatch(int ac,
} else {
owner->view()->cut();
}
#if 1
//owner->update_timeout.start();
#else
SetUpdateTimer();
#endif
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
owner->view()->setState();
}
@ -1864,19 +1932,23 @@ string LyXFunc::Dispatch(int ac,
LyXCursor cursor = owner->view()->text->cursor;
#if 1
//owner->update_timeout.stop();
#else
FreeUpdateTimer();
#endif
if (!owner->view()->text->selection) {
if (cursor.pos == 0
&& !(cursor.par->added_space_top
if (cursor.pos() == 0
&& !(cursor.par()->added_space_top
== VSpace (VSpace::NONE))) {
owner->view()->text->SetParagraph
(cursor.par->line_top,
cursor.par->line_bottom,
cursor.par->pagebreak_top,
cursor.par->pagebreak_bottom,
VSpace(VSpace::NONE), cursor.par->added_space_bottom,
cursor.par->align,
cursor.par->labelwidthstring, 0);
(cursor.par()->line_top,
cursor.par()->line_bottom,
cursor.par()->pagebreak_top,
cursor.par()->pagebreak_bottom,
VSpace(VSpace::NONE), cursor.par()->added_space_bottom,
cursor.par()->align,
cursor.par()->labelwidthstring, 0);
owner->view()->update (1);
} else {
owner->view()->text->Backspace();
@ -1886,7 +1958,11 @@ string LyXFunc::Dispatch(int ac,
}
} else
owner->view()->cut();
#if 1
//owner->update_timeout.start();
#else
SetUpdateTimer();
#endif
}
break;
@ -1895,7 +1971,11 @@ string LyXFunc::Dispatch(int ac,
owner->view()->beforeChange();
owner->view()->text->BreakParagraph(0);
owner->view()->update(1);
#if 1
//owner->update_timeout.callback();
#else
SetUpdateTimer(0.01);
#endif
owner->view()->text->sel_cursor =
owner->view()->text->cursor;
owner->view()->setState();
@ -1908,7 +1988,11 @@ string LyXFunc::Dispatch(int ac,
owner->view()->beforeChange();
owner->view()->text->BreakParagraph(1);
owner->view()->update(1);
#if 1
//owner->update_timeout.callback();
#else
SetUpdateTimer(0.01);
#endif
owner->view()->text->sel_cursor =
owner->view()->text->cursor;
owner->view()->setState();
@ -1925,24 +2009,29 @@ string LyXFunc::Dispatch(int ac,
LyXCursor cursor = owner->view()->text->cursor;
owner->view()->beforeChange();
if (cursor.pos == 0) {
if (cursor.par->added_space_top == VSpace(VSpace::NONE)) {
if (cursor.pos() == 0) {
if (cursor.par()->added_space_top == VSpace(VSpace::NONE)) {
owner->view()->text->SetParagraph
(cursor.par->line_top,
cursor.par->line_bottom,
cursor.par->pagebreak_top,
cursor.par->pagebreak_bottom,
VSpace(VSpace::DEFSKIP), cursor.par->added_space_bottom,
cursor.par->align,
cursor.par->labelwidthstring, 1);
owner->view()->update(1);
(cursor.par()->line_top,
cursor.par()->line_bottom,
cursor.par()->pagebreak_top,
cursor.par()->pagebreak_bottom,
VSpace(VSpace::DEFSKIP), cursor.par()->added_space_bottom,
cursor.par()->align,
cursor.par()->labelwidthstring, 1);
//owner->view()->update(1);
}
}
else {
owner->view()->text->BreakParagraph(0);
owner->view()->update(1);
//owner->view()->update(1);
}
#if 1
owner->view()->update(1);
//owner->update_timeout.callback();
#else
SetUpdateTimer(0.01);
#endif
owner->view()->text->sel_cursor = cursor;
owner->view()->setState();
owner->getMiniBuffer()->Set(CurrentState(owner->view()));
@ -1951,7 +2040,7 @@ string LyXFunc::Dispatch(int ac,
case LFUN_PARAGRAPH_SPACING:
{
LyXParagraph * par = owner->view()->text->cursor.par;
LyXParagraph * par = owner->view()->text->cursor.par();
Spacing::Space cur_spacing = par->spacing.getSpace();
float cur_value = 1.0;
if (cur_spacing == Spacing::Other) {
@ -2001,7 +2090,11 @@ string LyXFunc::Dispatch(int ac,
owner->view()->beforeChange();
owner->view()->text->InsertChar('\"'); // This " matches the single quote in the code
owner->view()->update(1);
#if 1
//owner->update_timeout.start();
#else
SetUpdateTimer();
#endif
moveCursorUpdate(false);
break;
@ -2067,13 +2160,13 @@ string LyXFunc::Dispatch(int ac,
case LFUN_CHARATCURSOR:
{
LyXParagraph::size_type pos =
owner->view()->text->cursor.pos;
if(pos < owner->view()->text->cursor.par->size())
owner->view()->text->cursor.pos();
if(pos < owner->view()->text->cursor.par()->size())
//dispatch_buffer = owner->view()->text->
// cursor.par->text[pos];
// cursor.par()->text[pos];
dispatch_buffer =
owner->view()->text->
cursor.par->GetChar(pos);
cursor.par()->GetChar(pos);
else
dispatch_buffer = "EOF";
}
@ -2081,8 +2174,8 @@ string LyXFunc::Dispatch(int ac,
case LFUN_GETXY:
dispatch_buffer =
tostr(owner->view()->text->cursor.x) + ' '
+ tostr(owner->view()->text->cursor.y);
tostr(owner->view()->text->cursor.x()) + ' '
+ tostr(owner->view()->text->cursor.y());
break;
case LFUN_SETXY:
@ -2096,7 +2189,7 @@ string LyXFunc::Dispatch(int ac,
case LFUN_GETLAYOUT:
dispatch_buffer =
tostr(owner->view()->text->cursor.par->layout);
tostr(owner->view()->text->cursor.par()->layout);
break;
case LFUN_GETFONT:
@ -2206,7 +2299,11 @@ string LyXFunc::Dispatch(int ac,
// copied verbatim from do_accent_char
owner->view()->update(1);
#if 1
//owner->update_timeout.start();
#else
SetUpdateTimer();
#endif
owner->view()->text->sel_cursor =
owner->view()->text->cursor;
}
@ -2419,7 +2516,7 @@ string LyXFunc::Dispatch(int ac,
case LFUN_INDEX_INSERT_LAST:
{
// Can't do that at the beginning of a paragraph.
if (owner->view()->text->cursor.pos - 1 < 0)
if (owner->view()->text->cursor.pos() - 1 < 0)
break;
InsetIndex * new_inset = new InsetIndex();
@ -2432,12 +2529,12 @@ string LyXFunc::Dispatch(int ac,
//reh 98/09/21
//get the current word for an argument
LyXParagraph::size_type lastpos =
owner->view()->text->cursor.pos - 1;
owner->view()->text->cursor.pos() - 1;
// Get the current word. note that this must be done
// before inserting the inset, or the inset will
// break the word
string curstring(owner->view()
->text->cursor.par->GetWord(lastpos));
->text->cursor.par()->GetWord(lastpos));
//make the new inset and write the current word into it
InsetIndex * new_inset = new InsetIndex();
@ -2453,7 +2550,7 @@ string LyXFunc::Dispatch(int ac,
// move the cursor to the returned value of lastpos
// but only for the auto-insert
owner->view()->text->cursor.pos = lastpos;
owner->view()->text->cursor.pos(lastpos);
}
//put the new inset into the buffer.
@ -2571,7 +2668,11 @@ string LyXFunc::Dispatch(int ac,
// won't break lines correctly. (Asger)
owner->view()->update(1);
}
#if 1
//owner->update_timeout.start();
#else
SetUpdateTimer();
#endif
owner->view()->text->sel_cursor =
owner->view()->text->cursor;
moveCursorUpdate(false);
@ -2591,25 +2692,27 @@ string LyXFunc::Dispatch(int ac,
case LFUN_DATE_INSERT: // jdblair: date-insert cmd
{
char datetmp[32];
int datetmp_len;
time_t now_time_t;
struct tm *now_tm;
static string arg;
struct tm * now_tm;
now_time_t = time(NULL);
time_t now_time_t = time(NULL);
now_tm = localtime(&now_time_t);
(void)setlocale(LC_TIME, "");
setlocale(LC_TIME, "");
string arg;
if (!argument.empty())
arg = argument;
else if (arg.empty())
else
arg = lyxrc.date_insert_format;
datetmp_len = (int) strftime(datetmp, 32, arg.c_str(), now_tm);
char datetmp[32];
int datetmp_len = strftime(datetmp, 32, arg.c_str(), now_tm);
for (int i = 0; i < datetmp_len; i++) {
owner->view()->text->InsertChar(datetmp[i]);
owner->view()->update(1);
}
#if 1
//owner->update_timeout.start();
#else
SetUpdateTimer();
#endif
owner->view()->text->sel_cursor = owner->view()->text->cursor;
moveCursorUpdate(false);
}
@ -2663,7 +2766,11 @@ string LyXFunc::Dispatch(int ac,
}
owner->view()->update(1);
#if 1
//owner->update_timeout.start();
#else
SetUpdateTimer();
#endif
owner->view()->text->sel_cursor =
owner->view()->text->cursor;
@ -3111,8 +3218,8 @@ Inset * LyXFunc::getInsetByCode(Inset::Code code)
{
LyXCursor cursor = owner->view()->text->cursor;
Buffer * buffer = owner->view()->buffer();
for (Buffer::inset_iterator it = Buffer::inset_iterator(cursor.par,
cursor.pos);
for (Buffer::inset_iterator it = Buffer::inset_iterator(cursor.par(),
cursor.pos());
it != buffer->inset_iterator_end(); ++it) {
if ((*it)->LyxCode() == code)
return *it;

View File

@ -125,15 +125,17 @@ public:
~LyXParagraph();
///
Language const * getParLanguage() const;
Language const * getParLanguage(BufferParams const &) const;
///
bool isRightToLeftPar() const;
bool isRightToLeftPar(BufferParams const &) const;
///
void ChangeLanguage(Language const * from, Language const * to);
void ChangeLanguage(BufferParams const & bparams,
Language const * from, Language const * to);
///
bool isMultiLingual();
bool isMultiLingual(BufferParams const &);
///
string String(bool label);
string String(BufferParams const &, bool label);
///
string String(size_type beg, size_type end);
@ -155,15 +157,18 @@ public:
void read();
///
LyXParagraph * TeXOnePar(std::ostream &, TexRow & texrow,
LyXParagraph * TeXOnePar(BufferParams const &,
std::ostream &, TexRow & texrow,
bool moving_arg,
std::ostream & foot, TexRow & foot_texrow,
int & foot_count);
///
bool SimpleTeXOnePar(std::ostream &, TexRow & texrow, bool moving_arg);
bool SimpleTeXOnePar(BufferParams const &,
std::ostream &, TexRow & texrow, bool moving_arg);
///
LyXParagraph * TeXEnvironment(std::ostream &, TexRow & texrow,
LyXParagraph * TeXEnvironment(BufferParams const &,
std::ostream &, TexRow & texrow,
std::ostream & foot, TexRow & foot_texrow,
int & foot_count);
///
@ -185,7 +190,7 @@ public:
/** Check if the current paragraph is the last paragraph in a
proof environment */
int GetEndLabel() const;
int GetEndLabel(BufferParams const &) const;
///
Inset * InInset() { return inset_owner; }
///
@ -362,9 +367,11 @@ public:
///
char GetDepth() const;
///
void SetLayout(LyXTextClass::LayoutList::size_type new_layout);
void SetLayout(BufferParams const &,
LyXTextClass::LayoutList::size_type new_layout);
///
void SetOnlyLayout(LyXTextClass::LayoutList::size_type new_layout);
void SetOnlyLayout(BufferParams const &,
LyXTextClass::LayoutList::size_type new_layout);
///
int GetFirstCounter(int i) const;
///
@ -373,14 +380,14 @@ public:
void Erase(size_type pos);
/** the flag determines wether the layout should be copied
*/
void BreakParagraph(size_type pos, int flag);
void BreakParagraph(BufferParams const &, size_type pos, int flag);
///
void BreakParagraphConservative(size_type pos);
void BreakParagraphConservative(BufferParams const &, size_type pos);
/** Get unistantiated font setting. Returns the difference
between the characters font and the layoutfont.
This is what is stored in the fonttable
*/
LyXFont GetFontSettings(size_type pos) const;
LyXFont GetFontSettings(BufferParams const &, size_type pos) const;
///
LyXFont GetFirstFontSettings() const;
@ -391,7 +398,7 @@ public:
attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
LyXFont::TOGGLE.
*/
LyXFont getFont(size_type pos) const;
LyXFont getFont(BufferParams const &, size_type pos) const;
///
char GetChar(size_type pos);
///
@ -423,9 +430,9 @@ public:
///
void CloseFootnote(size_type pos);
/// important for cut and paste
void CopyIntoMinibuffer(size_type pos) const;
void CopyIntoMinibuffer(BufferParams const &, size_type pos) const;
///
void CutIntoMinibuffer(size_type pos);
void CutIntoMinibuffer(BufferParams const &, size_type pos);
///
bool InsertFromMinibuffer(size_type pos);
@ -456,7 +463,7 @@ public:
/** paste this paragraph with the next one
be carefull, this doesent make any check at all
*/
void PasteParagraph();
void PasteParagraph(BufferParams const &);
/// used to remove the error messages
int AutoDeleteInsets();
@ -487,9 +494,10 @@ public:
/* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
I have to set it on each of it's elements */
///
void SetPExtraType(int type, char const * width, char const * widthp);
void SetPExtraType(BufferParams const &,
int type, char const * width, char const * widthp);
///
void UnsetPExtraType();
void UnsetPExtraType(BufferParams const &);
#if 0
///
bool RoffContTableRows(std::ostream &, size_type i, int actcell);
@ -497,11 +505,13 @@ public:
///
bool linuxDocConvertChar(char c, string & sgml_string);
///
void DocBookContTableRows(std::ostream &, string & extra,
void DocBookContTableRows(BufferParams const &,
std::ostream &, string & extra,
int & desc_on, size_type i,
int current_cell_number, int & column);
///
void SimpleDocBookOneTablePar(std::ostream &, string & extra,
void SimpleDocBookOneTablePar(BufferParams const &,
std::ostream &, string & extra,
int & desc_on, int depth);
private:
///
@ -561,18 +571,22 @@ private:
///
InsetList insetlist;
///
LyXParagraph * TeXDeeper(std::ostream &, TexRow & texrow,
LyXParagraph * TeXDeeper(BufferParams const &,
std::ostream &, TexRow & texrow,
std::ostream & foot, TexRow & foot_texrow,
int & foot_count);
///
LyXParagraph * TeXFootnote(std::ostream &, TexRow & texrow,
LyXParagraph * TeXFootnote(BufferParams const &,
std::ostream &, TexRow & texrow,
std::ostream & foot, TexRow & foot_texrow,
int & foot_count,
bool parent_is_rtl);
///
bool SimpleTeXOneTablePar(std::ostream &, TexRow & texrow);
bool SimpleTeXOneTablePar(BufferParams const &,
std::ostream &, TexRow & texrow);
///
bool TeXContTableRows(std::ostream &, size_type i,
bool TeXContTableRows(BufferParams const &,
std::ostream &, size_type i,
int current_cell_number,
int & column, TexRow & texrow);
///
@ -581,7 +595,8 @@ private:
int & column, LyXFont const & font,
LyXLayout const & style);
///
void SimpleTeXSpecialChars(std::ostream &, TexRow & texrow,
void SimpleTeXSpecialChars(BufferParams const &,
std::ostream &, TexRow & texrow,
bool moving_arg,
LyXFont & font, LyXFont & running_font,
LyXFont & basefont, bool & open_font,

119
src/lyxrow.C Normal file
View File

@ -0,0 +1,119 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#include "lyxrow.h"
Row::Row()
: par_(0), pos_(0), fill_(0), height_(0),
ascent_of_text_(0), baseline_(0), next_(0), previous_(0)
{}
void Row::par(LyXParagraph * p)
{
par_ = p;
}
LyXParagraph * Row::par()
{
return par_;
}
LyXParagraph * Row::par() const
{
return par_;
}
void Row::pos(LyXParagraph::size_type p)
{
pos_ = p;
}
LyXParagraph::size_type Row::pos() const
{
return pos_;
}
void Row::fill(int f)
{
fill_ = f;
}
int Row::fill() const
{
return fill_;
}
void Row::height(unsigned short h)
{
height_ = h;
}
unsigned short Row::height() const
{
return height_;
}
void Row::ascent_of_text(unsigned short a)
{
ascent_of_text_ = a;
}
unsigned short Row::ascent_of_text() const
{
return ascent_of_text_;
}
void Row::baseline(unsigned int b)
{
baseline_ = b;
}
unsigned int Row::baseline() const
{
return baseline_;
}
void Row::next(Row * r)
{
next_ = r;
}
Row * Row::next() const
{
return next_;
}
void Row::previous(Row * r)
{
previous_ = r;
}
Row * Row::previous() const
{
return previous_;
}

View File

@ -15,29 +15,62 @@
#include "lyxparagraph.h"
///
struct Row {
class Row {
public:
///
LyXParagraph * par;
Row();
///
LyXParagraph::size_type pos;
void par(LyXParagraph * p);
///
LyXParagraph * par();
///
LyXParagraph * par() const;
///
void pos(LyXParagraph::size_type p);
///
LyXParagraph::size_type pos() const;
///
void fill(int f);
///
int fill() const;
///
void height(unsigned short h);
///
unsigned short height() const;
///
void ascent_of_text(unsigned short a);
///
unsigned short ascent_of_text() const;
///
void baseline(unsigned int b);
///
unsigned int baseline() const;
///
void next(Row * r);
///
Row * next() const;
///
void previous(Row * r);
///
Row * previous() const;
private:
///
LyXParagraph * par_;
///
LyXParagraph::size_type pos_;
/** what is missing to a full row can be negative.
Needed for hfills, flushright, block etc. */
mutable int fill;
mutable int fill_;
///
unsigned short height;
unsigned short height_;
///
unsigned short ascent_of_text;
unsigned short ascent_of_text_;
///
unsigned int baseline;
unsigned int baseline_;
///
Row()
: par(0), pos(0), fill(0), height(0),
ascent_of_text(0), baseline(0), next(0), previous(0)
{}
Row * next_;
///
Row * next;
///
Row * previous;
Row * previous_;
};
#endif

View File

@ -56,10 +56,6 @@ public:
/// Destructor
~LyXText();
/// points to Buffer.params
//BufferParams * bparams;
/// points to Buffer
Buffer * buffer;
///
mutable int number_of_rows;
///
@ -108,7 +104,7 @@ public:
/** Get the depth at current cursor position
*/
int GetDepth() const { return cursor.par->GetDepth(); }
int GetDepth() const { return cursor.par()->GetDepth(); }
/** set font over selection and make a total rebreak of those
paragraphs.
@ -488,16 +484,19 @@ public:
/// for external use in lyx_cb.C
void SetCursorParUndo();
///
void RemoveTableRow(LyXCursor * cursor) const;
void RemoveTableRow(LyXCursor & cursor) const;
///
bool IsEmptyTableCell() const;
///
void toggleAppendix();
///
unsigned short paperWidth() const { return paperwidth; }
///
void ComputeBidiTables(Row *row) const;
Buffer const * buffer() const {
return buffer_;
}
///
void ComputeBidiTables(Row * row) const;
/// Maps positions in the visual string to positions in logical string.
inline
@ -533,6 +532,8 @@ public:
private:
///
BufferView * owner_;
/// points to Buffer
Buffer * buffer_;
/// width of the paper
unsigned short paperwidth;
@ -608,14 +609,15 @@ private:
LyXParagraph::size_type NextBreakPoint(Row const * row,
int width) const;
/// returns the minimum space a row needs on the screen in pixel
int Fill(Row const * row, int paperwidth) const;
int Fill(Row * row, int paperwidth) const;
/** returns the minimum space a manual label needs on the
screen in pixel */
int LabelFill(Row const * row) const;
///
LyXParagraph::size_type BeginningOfMainBody(LyXParagraph * par) const;
LyXParagraph::size_type
BeginningOfMainBody(LyXParagraph const * par) const;
/** Returns the left beginning of the text.
This information cannot be taken from the layouts-objekt, because

View File

@ -910,17 +910,17 @@ void Menus::ShowEditMenu(FL_OBJECT * ob, long)
// Table submenu
int SubEditTable = fl_newpup(FL_ObjWin(ob));
if (men->currentView()->available() &&
men->currentView()->text->cursor.par->table &&
men->currentView()->text->cursor.par()->table &&
!tmpbuffer->isReadonly()){
LyXTable *table = men->currentView()->text->cursor.par->table;
LyXTable * table = men->currentView()->text->cursor.par()->table;
fl_addtopup(SubEditTable, _("Table%t"));
if (table->IsMultiColumn(men->currentView()->text->
NumberOfCell(men->currentView()->
text->cursor.par,
text->cursor.par(),
men->currentView()->
text->cursor.pos)))
text->cursor.pos())))
fl_addtopup(SubEditTable, _("|Multicolumn%B%x44%l"));
else
fl_addtopup(SubEditTable, _("|Multicolumn%b%x44%l"));
@ -928,9 +928,9 @@ void Menus::ShowEditMenu(FL_OBJECT * ob, long)
if (table->TopLine(men->currentView()->text->
NumberOfCell(men->currentView()->
text->cursor.par,
text->cursor.par(),
men->currentView()->text->
cursor.pos)))
cursor.pos())))
fl_addtopup(SubEditTable, _("|Line Top%B%x36"));
else
fl_addtopup(SubEditTable, _("|Line Top%b%x36"));
@ -938,9 +938,9 @@ void Menus::ShowEditMenu(FL_OBJECT * ob, long)
if (table->BottomLine(men->currentView()->text->
NumberOfCell(men->currentView()->
text->cursor.par,
text->cursor.par(),
men->currentView()->
text->cursor.pos)))
text->cursor.pos())))
fl_addtopup(SubEditTable, _("|Line Bottom%B%x37"));
else
fl_addtopup(SubEditTable, _("|Line Bottom%b%x37"));
@ -948,9 +948,9 @@ void Menus::ShowEditMenu(FL_OBJECT * ob, long)
if (table->LeftLine(men->currentView()->text->
NumberOfCell(men->currentView()->
text->cursor.par,
text->cursor.par(),
men->currentView()->
text->cursor.pos)))
text->cursor.pos())))
fl_addtopup(SubEditTable, _("|Line Left%B%x38"));
else
fl_addtopup(SubEditTable, _("|Line Left%b%x38"));
@ -958,9 +958,9 @@ void Menus::ShowEditMenu(FL_OBJECT * ob, long)
if (table->RightLine(men->currentView()->text->
NumberOfCell(men->currentView()->
text->cursor.par,
text->cursor.par(),
men->currentView()->
text->cursor.pos)))
text->cursor.pos())))
fl_addtopup(SubEditTable, _("|Line Right%B%x39%l"));
else
fl_addtopup(SubEditTable, _("|Line Right%b%x39%l"));
@ -969,9 +969,9 @@ void Menus::ShowEditMenu(FL_OBJECT * ob, long)
int align =
table->GetAlignment(men->currentView()->text->
NumberOfCell(men->currentView()->
text->cursor.par,
text->cursor.par(),
men->currentView()->
text->cursor.pos));
text->cursor.pos()));
if (align == LYX_ALIGN_LEFT)
fl_addtopup(SubEditTable, _("|Align Left%R%x40"));
else
@ -1633,7 +1633,7 @@ void Menus::ShowLayoutMenu(FL_OBJECT * ob, long)
fl_setpup_mode(LayoutMenu, 10, FL_PUP_CHECK);
// Grey out unavailable entries
if (!men->currentView()->text->cursor.par->table)
if (!men->currentView()->text->cursor.par()->table)
fl_setpup_mode(LayoutMenu, 5, FL_PUP_GREY);
if (tmpbuffer->isReadonly()) {

File diff suppressed because it is too large Load Diff

View File

@ -100,8 +100,8 @@ void LyXScreen::DrawFromTo(int y1, int y2)
while (row != 0 && y < y2) {
text->GetVisibleRow(y, row, y + first);
y += row->height;
row = row->next;
y += row->height();
row = row->next();
}
// maybe we have to clear the screen at the bottom
@ -118,7 +118,8 @@ void LyXScreen::DrawOneRow(Row * row, long y_text)
{
long y = y_text - first;
if (y + row->height > 0 && y - row->height <= long(owner.height())) {
if (y + row->height() > 0
&& y - row->height() <= long(owner.height())) {
// ok there is something visible
text->GetVisibleRow(y, row, y + first);
}
@ -185,12 +186,12 @@ void LyXScreen::ShowCursor()
if (!cursor_visible) {
Cursor_Shape shape = BAR_SHAPE;
if (text->real_current_font.language() !=
text->buffer->params.language_info
text->buffer()->params.language_info
|| text->real_current_font.isVisibleRightToLeft()
!= text->buffer->params.language_info->RightToLeft)
!= text->buffer()->params.language_info->RightToLeft())
shape = (text->real_current_font.isVisibleRightToLeft())
? REVERSED_L_SHAPE : L_SHAPE;
ShowManualCursor(text->cursor.x, text->cursor.y,
ShowManualCursor(text->cursor.x(), text->cursor.y(),
lyxfont::maxAscent(text->real_current_font),
lyxfont::maxDescent(text->real_current_font),
shape);
@ -330,25 +331,25 @@ unsigned long LyXScreen::TopCursorVisible()
{
long newtop = first;
if (text->cursor.y
- text->cursor.row->baseline
+ text->cursor.row->height
if (text->cursor.y()
- text->cursor.row()->baseline()
+ text->cursor.row()->height()
- first >= owner.height()) {
if (text->cursor.row->height < owner.height()
&& text->cursor.row->height > owner.height() / 4)
newtop = text->cursor.y
+ text->cursor.row->height
- text->cursor.row->baseline - owner.height();
if (text->cursor.row()->height() < owner.height()
&& text->cursor.row()->height() > owner.height() / 4)
newtop = text->cursor.y()
+ text->cursor.row()->height()
- text->cursor.row()->baseline() - owner.height();
else
newtop = text->cursor.y
newtop = text->cursor.y()
- 3 * owner.height() / 4; /* the scroll region must be so big!! */
} else if (text->cursor.y - text->cursor.row->baseline < first
} else if (text->cursor.y() - text->cursor.row()->baseline() < first
&& first > 0) {
if (text->cursor.row->height < owner.height()
&& text->cursor.row->height > owner.height() / 4)
newtop = text->cursor.y - text->cursor.row->baseline;
if (text->cursor.row()->height() < owner.height()
&& text->cursor.row()->height() > owner.height() / 4)
newtop = text->cursor.y() - text->cursor.row()->baseline();
else {
newtop = text->cursor.y - owner.height() / 4;
newtop = text->cursor.y() - owner.height() / 4;
newtop = min(newtop, long(first));
}
}
@ -392,7 +393,7 @@ void LyXScreen::Update()
DrawOneRow(text->refresh_row, text->refresh_y);
text->status = LyXText::UNCHANGED;
expose(0, text->refresh_y - first,
owner.workWidth(), text->refresh_row->height);
owner.workWidth(), text->refresh_row->height());
}
break;
case LyXText::UNCHANGED:
@ -407,12 +408,12 @@ void LyXScreen::ToggleSelection(bool kill_selection)
// only if there is a selection
if (!text->selection) return;
long bottom = min(max(text->sel_end_cursor.y
- text->sel_end_cursor.row->baseline
+ text->sel_end_cursor.row->height, first),
long bottom = min(max(text->sel_end_cursor.y()
- text->sel_end_cursor.row()->baseline()
+ text->sel_end_cursor.row()->height(), first),
first + owner.height());
long top = min(max(text->sel_start_cursor.y
- text->sel_start_cursor.row->baseline, first),
long top = min(max(text->sel_start_cursor.y()
- text->sel_start_cursor.row()->baseline(), first),
first + owner.height());
if (kill_selection)
@ -426,15 +427,15 @@ void LyXScreen::ToggleSelection(bool kill_selection)
void LyXScreen::ToggleToggle()
{
if (text->toggle_cursor.par == text->toggle_end_cursor.par
&& text->toggle_cursor.pos == text->toggle_end_cursor.pos)
if (text->toggle_cursor.par() == text->toggle_end_cursor.par()
&& text->toggle_cursor.pos() == text->toggle_end_cursor.pos())
return;
long top = text->toggle_cursor.y
- text->toggle_cursor.row->baseline;
long bottom = text->toggle_end_cursor.y
- text->toggle_end_cursor.row->baseline
+ text->toggle_end_cursor.row->height;
long top = text->toggle_cursor.y()
- text->toggle_cursor.row()->baseline();
long bottom = text->toggle_end_cursor.y()
- text->toggle_end_cursor.row()->baseline()
+ text->toggle_end_cursor.row()->height();
typedef unsigned long ulong;

View File

@ -59,7 +59,7 @@ LSubstring & LSubstring::operator=(string const & s)
LSubstring & LSubstring::operator=(LSubstring const & s)
{
ps->replace(pos, n, string(s, 0, string::npos));
ps->replace(pos, n, s);
return *this;
}

View File

@ -40,6 +40,8 @@ using std::vector;
static int const WIDTH_OF_LINE = 5;
extern BufferView * current_view;
/// Define a few methods for the inner structs
LyXTabular::cellstruct::cellstruct()
@ -1292,10 +1294,10 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
}
// now we have the par we should fill the insets with this!
int cell = 0;
InsetText *inset = GetCellInset(cell);
InsetText * inset = GetCellInset(cell);
int row;
for(int i=0; i < par->Last(); ++i) {
for(int i = 0; i < par->Last(); ++i) {
if (par->IsNewline(i)) {
++cell;
if (cell > GetNumberOfCells()) {
@ -1322,7 +1324,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
par->InsertChar(i, ' ');
}
}
par->CopyIntoMinibuffer(i);
par->CopyIntoMinibuffer(current_view->buffer()->params, i);
inset->par->InsertFromMinibuffer(inset->par->Last());
}
Reinit();

View File

@ -41,12 +41,12 @@ void TexRow::start(LyXParagraph * par, int pos)
void TexRow::newline()
{
RowItem tmp;
tmp.pos = lastpos;
tmp.pos(lastpos);
if (lastpar)
tmp.id = lastpar->id();
tmp.id(lastpar->id());
else
tmp.id = -1;
tmp.rownumber = ++count;
tmp.id(-1);
tmp.rownumber(++count);
rowlist.push_back(tmp);
}
@ -55,7 +55,7 @@ void TexRow::getIdFromRow(int row, int & id, int & pos)
{
RowList::const_iterator cit = rowlist.begin();
for (; cit != rowlist.end(); ++cit) {
if ((*cit).rownumber == row) break;
if ((*cit).rownumber() == row) break;
}
if (cit != rowlist.end()) {
RowList::iterator kit = rowlist.begin();
@ -65,12 +65,12 @@ void TexRow::getIdFromRow(int row, int & id, int & pos)
// same pos.
for(; kit != rowlist.end(); ++kit) {
if (&(*kit) != &(*cit)
&& (*kit).id == (*cit).id
&& (*kit).pos >= (*cit).pos)
(*kit).pos++;
&& (*kit).id() == (*cit).id()
&& (*kit).pos() >= (*cit).pos())
(*kit).pos((*kit).pos() + 1);
}
id = (*cit).id;
pos = (*cit).pos;
id = (*cit).id();
pos = (*cit).pos();
} else {
id = -1;
pos = 0;

View File

@ -24,11 +24,7 @@ class LyXParagraph;
class TexRow {
public:
///
TexRow() {
count = 0;
lastpar = 0;
lastpos = -1;
}
TexRow() : count(0), lastpar(0), lastpos(-1) {}
/// Clears structure
void reset();
@ -46,24 +42,45 @@ public:
TexRow & operator+= (TexRow const &);
/// Returns the number of rows in this texrow
int rows() { return count; }
int rows() const { return count; }
private:
/// Linked list of items
struct RowItem {
class RowItem {
public:
///
RowItem() {
id = -1;
pos = -1;
rownumber = 0;
RowItem() : id_(-1), pos_(-1), rownumber_(0) {}
///
void id(int i) {
id_ = i;
}
///
int id;
int id() const {
return id_;
}
///
int pos;
void pos(int p) {
pos_ = p;
}
///
int rownumber;
int pos() const {
return pos_;
}
///
void rownumber(int r) {
rownumber_ = r;
}
///
int rownumber() const {
return rownumber_;
}
private:
///
int id_;
///
int pos_;
///
int rownumber_;
};
///
unsigned int count;

2572
src/text.C

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -289,10 +289,10 @@ void TransManager::insertVerbatim(string const & str, LyXText * text)
for (int i = 0; i < l; ++i){
if (str[i] == '\"'
&& text->GetFont(text->cursor.par,
text->cursor.pos).latex() == LyXFont::OFF
&& text->GetFont(text->cursor.par,
text->cursor.pos).language()->lang != "hebrew")
&& text->GetFont(text->cursor.par(),
text->cursor.pos()).latex() == LyXFont::OFF
&& text->GetFont(text->cursor.par(),
text->cursor.pos()).language()->lang() != "hebrew")
current_view->insertCorrectQuote();
else
text->InsertChar(str[i]);