From 74a46e047411135aa83e77fe5be9e9f320cc9b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Vigna?= Date: Thu, 28 Sep 2000 14:05:24 +0000 Subject: [PATCH] Various fixes and some "missing features" from Dekels Mail in insettext/ tabular fixe. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1052 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 18 +++++ src/BufferView.C | 4 +- src/BufferView.h | 2 +- src/BufferView2.C | 21 +----- src/BufferView_pimpl.C | 15 ++-- src/BufferView_pimpl.h | 2 +- src/buffer.C | 7 +- src/buffer.h | 2 +- src/converter.C | 3 +- src/frontends/xforms/FormTabular.C | 5 +- src/insets/insetlabel.C | 3 +- src/insets/insettabular.C | 117 ++++++++++++++++------------- src/insets/insettabular.h | 2 +- src/insets/insettext.C | 3 + src/lyxfunc.C | 17 +++-- src/tabular.C | 90 +++++++++++++++------- src/tabular.h | 32 ++++---- src/text.C | 4 +- src/text2.C | 13 ++++ 19 files changed, 212 insertions(+), 148 deletions(-) diff --git a/ChangeLog b/ChangeLog index eda8d9dc75..f12e72d5b2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2000-09-28 Juergen Vigna + + * src/insets/insettabular.C (update): fixed cursor setting when + the_locking_inset changed. + (draw): made this a bit cleaner. + + * various files: added LyXText Parameter to fitCursor call. + + * src/BufferView.C (fitCursor): added LyXText parameter. + + * src/insets/insettabular.C (draw): small draw fix. + + * src/tabular.C: right setting of left/right celllines. + + * src/tabular.[Ch]: fixed various types in funcions and structures. + * src/insets/insettabular.C: ditto + * src/frontends/xforms/FormTabular.C: ditto + 2000-09-28 Allan Rae * src/paragraph.C (TeXOnePar): fixed output of '\n'. The problem was diff --git a/src/BufferView.C b/src/BufferView.C index e244fb46b3..88cbba5f8f 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -99,9 +99,9 @@ void BufferView::redraw() } -void BufferView::fitCursor() +void BufferView::fitCursor(LyXText * text) { - pimpl_->fitCursor(); + pimpl_->fitCursor(text); } diff --git a/src/BufferView.h b/src/BufferView.h index 444fcaed49..d811704302 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -63,7 +63,7 @@ public: /// void redraw(); /// - void fitCursor(); + void fitCursor(LyXText *); /// void update(); // diff --git a/src/BufferView2.C b/src/BufferView2.C index fd8615a134..ab4e5ca3fc 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -203,9 +203,8 @@ bool BufferView::insertInset(Inset * inset, string const & lout, // if we are in a locking inset we should try to insert the // inset there otherwise this is a illegal function now if (the_locking_inset) { - if (the_locking_inset->InsertInsetAllowed(inset) && - the_locking_inset->InsertInset(this, inset)) - return true; + if (the_locking_inset->InsertInsetAllowed(inset)) + return the_locking_inset->InsertInset(this, inset); return false; } @@ -252,19 +251,6 @@ bool BufferView::insertInset(Inset * inset, string const & lout, } text->InsertInset(this, inset); -#if 1 - // if we enter a text-inset the cursor should be to the left side - // of it! This couldn't happen before as Undo was not handled inside - // inset now after the Undo LyX tries to call inset->Edit(...) again - // 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(buffer()->params)) - text->CursorRight(this); - else - text->CursorLeft(this); - } -#endif update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); text->UnFreezeUndo(); @@ -394,8 +380,7 @@ void BufferView::allFloats(char flag, char figmar) text->SetCursorIntern(this, cursor.par(), cursor.pos()); redraw(); - fitCursor(); - //updateScrollbar(); + fitCursor(text); } #endif diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 53fdc53cc0..bc6b571348 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -208,12 +208,13 @@ void BufferView::Pimpl::redraw() } -bool BufferView::Pimpl::fitCursor() +bool BufferView::Pimpl::fitCursor(LyXText * text) { Assert(screen_); // it is a programming error to call fitCursor // without a valid screen. - bool ret = screen_->FitCursor(bv_->text); - if (ret) updateScrollbar(); + bool ret = screen_->FitCursor(text); + if (ret) + updateScrollbar(); return ret; } @@ -541,7 +542,7 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state) bv_->text->SetSelection(); screen_->ToggleToggle(bv_->text); - fitCursor(); + fitCursor(bv_->text); screen_->ShowCursor(bv_->text); } return; @@ -634,7 +635,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, bv_->text->cursor.x_fix(bv_->text->cursor.x()); owner_->updateLayoutChoice(); - if (fitCursor()) { + if (fitCursor(bv_->text)) { selection_possible = false; } @@ -976,7 +977,7 @@ void BufferView::Pimpl::workAreaExpose() // fitCursor() ensures we don't jump back // to the start of the document on vertical // resize - fitCursor(); + fitCursor(bv_->text); // The main window size has changed, repaint most stuff redraw(); @@ -1052,7 +1053,7 @@ void BufferView::Pimpl::update(BufferView::UpdateCodes f) update(); if ((f & FITCUR)) { - fitCursor(); + fitCursor(bv_->text); } if ((f & CHANGE)) { diff --git a/src/BufferView_pimpl.h b/src/BufferView_pimpl.h index 46e9e3df18..858e809af3 100644 --- a/src/BufferView_pimpl.h +++ b/src/BufferView_pimpl.h @@ -36,7 +36,7 @@ struct BufferView::Pimpl : public Object { /// void redraw(); /// Return true if the cursor was fitted. - bool fitCursor(); + bool fitCursor(LyXText *); /// void redoCurrentBuffer(); /// diff --git a/src/buffer.C b/src/buffer.C index 845b038737..ae13856bad 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -3386,7 +3386,7 @@ int Buffer::runLiterate() // error insets after we ran LaTeX this must be run: if (removedErrorInsets || (res & Literate::ERRORS)){ users->redraw(); - users->fitCursor(); + users->fitCursor(users->text); //users->updateScrollbar(); } AllowInput(users); @@ -3457,7 +3457,7 @@ int Buffer::buildProgram() // must be run: if (removedErrorInsets || (res & Literate::ERRORS)){ users->redraw(); - users->fitCursor(); + users->fitCursor(users->text); //users->updateScrollbar(); } AllowInput(users); @@ -3509,8 +3509,7 @@ int Buffer::runChktex() // error insets after we ran chktex, this must be run: if (removedErrorInsets || res){ users->redraw(); - users->fitCursor(); - //users->updateScrollbar(); + users->fitCursor(users->text); } AllowInput(users); diff --git a/src/buffer.h b/src/buffer.h index ad3249b579..39d57306bd 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -106,7 +106,7 @@ public: /// void redraw() { users->redraw(); - users->fitCursor(); + users->fitCursor(users->text); //users->updateScrollbar(); } diff --git a/src/converter.C b/src/converter.C index cc4bb3a453..81bf1cdba0 100644 --- a/src/converter.C +++ b/src/converter.C @@ -462,8 +462,7 @@ bool Converter::runLaTeX(Buffer * buffer, string const & command) // error insets after we ran LaTeX this must be run: if (a || (result & LaTeX::ERRORS)){ bv->redraw(); - bv->fitCursor(); - //bv->updateScrollbar(); + bv->fitCursor(bv->text); } // check return value from latex.run(). diff --git a/src/frontends/xforms/FormTabular.C b/src/frontends/xforms/FormTabular.C index a77761beb8..2e05c2ad85 100644 --- a/src/frontends/xforms/FormTabular.C +++ b/src/frontends/xforms/FormTabular.C @@ -490,8 +490,9 @@ void FormTabular::SetTabularOptions(FL_OBJECT * ob, long) * tabular = inset_->tabular; int cell, - s, - num = 0; + s; + LyXTabular::Feature + num = LyXTabular::LAST_ACTION; string special, str; diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index df69302a40..72376e4427 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -57,8 +57,7 @@ void InsetLabel::Edit(BufferView * bv, int, int, unsigned int) bv->text->RedoParagraph(bv); if (flag) { bv->redraw(); - bv->fitCursor(); - //bv->updateScrollbar(); + bv->fitCursor(getLyXText(bv)); } else bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); } diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index edb29a69d4..a1a160c1ea 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -53,7 +53,7 @@ using std::swap; struct tabular_features { - int action; + LyXTabular::Feature action; string feature; }; @@ -85,7 +85,6 @@ static tabular_features tabularFeatures[] = { LyXTabular::M_VALIGN_TOP, "m-valign-top" }, { LyXTabular::M_VALIGN_BOTTOM, "m-valign-bottom" }, { LyXTabular::M_VALIGN_CENTER, "m-valign-center" }, - { LyXTabular::DELETE_TABULAR, "delete-tabular" }, { LyXTabular::MULTICOLUMN, "multicolumn" }, { LyXTabular::SET_ALL_LINES, "set-all-lines" }, { LyXTabular::UNSET_ALL_LINES, "unset-all-lines" }, @@ -255,45 +254,18 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline, return; bool dodraw; x += ADD_TO_TABULAR_WIDTH; - if (cleared || (need_update == FULL) || (need_update == CELL)) { + if (cleared) { for(i = 0; i < tabular->rows(); ++i) { nx = int(x); dodraw = ((baseline + tabular->GetDescentOfRow(i)) > 0) && - (baseline - tabular->GetAscentOfRow(i)) < pain.paperHeight(); + (baseline - tabular->GetAscentOfRow(i))columns(); ++j) { if (tabular->IsPartOfMultiColumn(i, j)) continue; cx = nx + tabular->GetBeginningOfTextInCell(cell); - if (hasSelection()) - DrawCellSelection(pain, nx, baseline, i, j, cell); - if (dodraw && !cleared && locked && the_locking_inset) { - if (the_locking_inset == tabular->GetCellInset(cell)) { - LyXText::text_status st = bv->text->status; - do { - bv->text->status = st; - if (need_update == CELL) { - // clear before the inset - pain.fillRectangle( - nx + 1, - baseline - tabular->GetAscentOfRow(i) + 1, - int(cx - nx - 1), - tabular->GetAscentOfRow(i) + - tabular->GetDescentOfRow(i) - 1); - // clear behind the inset - pain.fillRectangle( - int(cx + the_locking_inset->width(bv,font) + 1), - baseline - tabular->GetAscentOfRow(i) + 1, - tabular->GetWidthOfColumn(cell) - - tabular->GetBeginningOfTextInCell(cell) - - the_locking_inset->width(bv,font) - 1, - tabular->GetAscentOfRow(i) + - tabular->GetDescentOfRow(i) - 1); - } - tabular->GetCellInset(cell)->draw( - bv, font, baseline, cx, false); - } while(bv->text->status == LyXText::CHANGED_IN_DRAW); - } - } else if (dodraw) { + if (dodraw) { + if (hasSelection()) + DrawCellSelection(pain, nx, baseline, i, j, cell); tabular->GetCellInset(cell)->draw(bv, font, baseline, cx, cleared); DrawCellLines(pain, nx, baseline, i, cell); @@ -303,7 +275,47 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline, } baseline += tabular->GetDescentOfRow(i) + tabular->GetAscentOfRow(i + 1) + - tabular->GetAdditionalHeight(cell + 1); + tabular->GetAdditionalHeight(cell); + } + } else if (need_update == CELL) { + nx = int(x); + for(i = 0; (cell < actcell) && (i < tabular->rows()); ++i) { + nx = int(x); + for(j = 0; (cell < actcell) && (j < tabular->columns()); ++j) { + if (tabular->IsPartOfMultiColumn(i, j)) + continue; + nx += tabular->GetWidthOfColumn(cell); + ++cell; + } + baseline += tabular->GetDescentOfRow(i) + + tabular->GetAscentOfRow(i + 1) + + tabular->GetAdditionalHeight(cell); + } + if (the_locking_inset == tabular->GetCellInset(cell)) { + cx = nx + tabular->GetBeginningOfTextInCell(cell); + LyXText::text_status st = bv->text->status; + do { + bv->text->status = st; + if (need_update == CELL) { + // clear before the inset + pain.fillRectangle( + nx + 1, + baseline - tabular->GetAscentOfRow(i) + 1, + int(cx - nx - 1), + tabular->GetAscentOfRow(i) + + tabular->GetDescentOfRow(i) - 1); + // clear behind the inset + pain.fillRectangle( + int(cx + the_locking_inset->width(bv,font) + 1), + baseline - tabular->GetAscentOfRow(i) + 1, + tabular->GetWidthOfColumn(cell) - + tabular->GetBeginningOfTextInCell(cell) - + the_locking_inset->width(bv,font) - 1, + tabular->GetAscentOfRow(i) + + tabular->GetDescentOfRow(i) - 1); + } + tabular->GetCellInset(cell)->draw(bv,font,baseline, cx, false); + } while(bv->text->status == LyXText::CHANGED_IN_DRAW); } } x -= ADD_TO_TABULAR_WIDTH; @@ -384,8 +396,12 @@ void InsetTabular::update(BufferView * bv, LyXFont const & font, bool reinit) owner()->update(bv, font, true); return; } - if (the_locking_inset) + if (the_locking_inset) { the_locking_inset->update(bv, font, reinit); + resetPos(bv); + inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell); + inset_y = cursor.y(); + } switch(need_update) { case INIT: case FULL: @@ -815,22 +831,12 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action, if (hs) UpdateLocal(bv, SELECTION, false); break; -#if 0 - case LFUN_LAYOUT_TABLE: - { - dialogs_ = bv->owner()->getDialogs(); - dialogs_->showTabular(this); - } - break; -#else -#warning Jürgen, have a look. Is this correct? (Lgb) case LFUN_LAYOUT_TABULAR: { dialogs_ = bv->owner()->getDialogs(); dialogs_->showTabular(this); } break; -#endif case LFUN_TABULAR_FEATURE: if (!TabularFeatures(bv, arg)) result = UNDISPATCHED; @@ -1197,7 +1203,7 @@ void InsetTabular::SetFont(BufferView * bv, LyXFont const & font, bool tall) bool InsetTabular::TabularFeatures(BufferView * bv, string const & what) { - int action = LyXTabular::LAST_ACTION; + LyXTabular::Feature action = LyXTabular::LAST_ACTION; int i = 0; for(; tabularFeatures[i].action != LyXTabular::LAST_ACTION; ++i) { @@ -1220,7 +1226,8 @@ bool InsetTabular::TabularFeatures(BufferView * bv, string const & what) } -void InsetTabular::TabularFeatures(BufferView * bv, int feature, +void InsetTabular::TabularFeatures(BufferView * bv, + LyXTabular::Feature feature, string const & value) { int i; @@ -1231,6 +1238,7 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, int sel_row_end; int setLines = 0; LyXAlignment setAlign = LYX_ALIGN_LEFT; + LyXTabular::VAlignment setVAlign = LyXTabular::LYX_VALIGN_TOP; int lineSet; bool what; @@ -1249,15 +1257,15 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, break; case LyXTabular::M_VALIGN_TOP: case LyXTabular::VALIGN_TOP: - setAlign=LyXTabular::LYX_VALIGN_TOP; + setVAlign=LyXTabular::LYX_VALIGN_TOP; break; case LyXTabular::M_VALIGN_BOTTOM: case LyXTabular::VALIGN_BOTTOM: - setAlign=LyXTabular::LYX_VALIGN_BOTTOM; + setVAlign=LyXTabular::LYX_VALIGN_BOTTOM; break; case LyXTabular::M_VALIGN_CENTER: case LyXTabular::VALIGN_CENTER: - setAlign=LyXTabular::LYX_VALIGN_CENTER; + setVAlign=LyXTabular::LYX_VALIGN_CENTER; break; default: break; @@ -1422,8 +1430,8 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, case LyXTabular::VALIGN_CENTER: for(i = sel_row_start; i <= sel_row_end; ++i) for(j = sel_col_start; j <= sel_col_end; ++j) - tabular->SetVAlignment(tabular->GetCellNumber(i, j), setAlign, - flag); + tabular->SetVAlignment(tabular->GetCellNumber(i, j), + setVAlign, flag); if (hasSelection()) UpdateLocal(bv, INIT, true); else @@ -1527,6 +1535,9 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, what = !tabular->GetLTNewPage(actcell); tabular->SetLTNewPage(actcell, what); break; + // dummy stuff just to avoid warnings + case LyXTabular::LAST_ACTION: + break; } } diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 6b4701e3cd..6b2513efc5 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -152,7 +152,7 @@ public: /// bool TabularFeatures(BufferView * bv, string const & what); /// - void TabularFeatures(BufferView * bv, int feature, + void TabularFeatures(BufferView * bv, LyXTabular::Feature feature, string const & val = string()); /// int GetActCell() const { return actcell; } diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 298f11edd3..89ce5d7e38 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -1190,10 +1190,13 @@ bool InsetText::InsertInset(BufferView * bv, Inset * inset) UpdatableInset * i = static_cast(inset); i->setOwner(static_cast(this)); } + HideInsetCursor(bv); TEXT(bv)->InsertInset(bv, inset); TEXT(bv)->selection = 0; + bv->fitCursor(TEXT(bv)); UpdateLocal(bv, CURSOR_PAR, true); static_cast(inset)->Edit(bv, 0, 0, 0); + ShowInsetCursor(bv); return true; } diff --git a/src/lyxfunc.C b/src/lyxfunc.C index abda8b84dd..00195488d4 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1081,8 +1081,7 @@ string const LyXFunc::Dispatch(int ac, case LFUN_REMOVEERRORS: if (owner->view()->removeAutoInsets()) { owner->view()->redraw(); - owner->view()->fitCursor(); - //owner->view()->updateScrollbar(); + owner->view()->fitCursor(owner->view()->text); } break; @@ -1565,13 +1564,17 @@ string const LyXFunc::Dispatch(int ac, bool is_rtl = txt->cursor.par()->isRightToLeftPar(owner->buffer()->params); if(!txt->mark_set) owner->view()->beforeChange(); owner->view()->update(BufferView::SELECT|BufferView::FITCUR); + LyXCursor cur = txt->cursor; if (!is_rtl) txt->CursorLeft(owner->view(), false); - 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) { + if ((cur != txt->cursor) && // only if really moved! + 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()); setMessage(tmpinset->EditMessage()); LyXFont font = txt->GetFont(owner->view()->buffer(), diff --git a/src/tabular.C b/src/tabular.C index 25697c118f..268bf4e8c2 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -53,9 +53,9 @@ LyXTabular::cellstruct::cellstruct() multicolumn = LyXTabular::CELL_NORMAL; alignment = LYX_ALIGN_CENTER; valignment = LYX_VALIGN_TOP; - top_line = false; + top_line = true; bottom_line = false; - left_line = false; + left_line = true; right_line = false; usebox = BOX_NONE; rotate = false; @@ -172,6 +172,7 @@ void LyXTabular::Init(int rows_arg, int columns_arg) cell_info[i][j].inset.SetDrawFrame(0, InsetText::LOCKED); cell_info[i][j].cellno = cellno++; } + cell_info[i][columns_-1].right_line = true; } //row_info[i - 1].bottom_line = true; //row_info[0].bottom_line = true; @@ -318,7 +319,7 @@ void LyXTabular::Reinit() } -void LyXTabular::set_row_column_number_info() +void LyXTabular::set_row_column_number_info(bool oldformat) { int c = 0; int column = 0; @@ -359,6 +360,14 @@ void LyXTabular::set_row_column_number_info() for (column = 0; columnalign_special = special; else @@ -734,9 +740,8 @@ bool LyXTabular::SetRightLine(int cell, bool line, bool onlycolumn) } -char LyXTabular::GetAlignment(int cell, bool onlycolumn) const +LyXAlignment LyXTabular::GetAlignment(int cell, bool onlycolumn) const { -#warning Fix return type. (Lgb) if (!onlycolumn && IsMultiColumn(cell)) return cellinfo_of_cell(cell)->alignment; else @@ -744,9 +749,8 @@ char LyXTabular::GetAlignment(int cell, bool onlycolumn) const } -char LyXTabular::GetVAlignment(int cell, bool onlycolumn) const +LyXTabular::VAlignment LyXTabular::GetVAlignment(int cell, bool onlycolumn) const { -#warning Fix return type. (Lgb) if (!onlycolumn && IsMultiColumn(cell)) return cellinfo_of_cell(cell)->valignment; else @@ -1048,6 +1052,38 @@ bool getTokenValue(string const str, const char * token, int & num) } +static +bool getTokenValue(string const str, const char * token, LyXAlignment & num) +{ + int tmp; + bool ret = getTokenValue(str, token, tmp); + num = static_cast(tmp); + return ret; +} + + +static +bool getTokenValue(string const str, const char * token, + LyXTabular::VAlignment & num) +{ + int tmp; + bool ret = getTokenValue(str, token, tmp); + num = static_cast(tmp); + return ret; +} + + +static +bool getTokenValue(string const str, const char * token, + LyXTabular::BoxType & num) +{ + int tmp; + bool ret = getTokenValue(str, token, tmp); + num = static_cast(tmp); + return ret; +} + + static bool getTokenValue(string const str, const char * token, bool & flag) { @@ -1272,7 +1308,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl) getline(is, s1, '"'); is >> ch; // skip '"' getline(is, s2, '"'); - column_info[i].alignment = static_cast(a); + column_info[i].alignment = static_cast(a); column_info[i].left_line = b; column_info[i].right_line = c; column_info[i].p_width = s1; @@ -1289,17 +1325,19 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl) is >> ch; // skip '"' getline(is, s2, '"'); cell_info[i][j].multicolumn = static_cast(a); - cell_info[i][j].alignment = static_cast(b); + cell_info[i][j].alignment = static_cast(b); cell_info[i][j].top_line = static_cast(c); cell_info[i][j].bottom_line = static_cast(d); + cell_info[i][j].left_line = column_info[j].left_line; + cell_info[i][j].right_line = column_info[j].right_line; cell_info[i][j].rotate = static_cast(f); - cell_info[i][j].usebox = static_cast(g); + cell_info[i][j].usebox = static_cast(g); cell_info[i][j].align_special = s1; cell_info[i][j].p_width = s2; } } } - set_row_column_number_info(); + set_row_column_number_info(true); LyXParagraph * par = new LyXParagraph; LyXParagraph * return_par = 0; @@ -1615,9 +1653,8 @@ int LyXTabular::UnsetMultiColumn(int cell) } -void LyXTabular::SetLongTabular(int what) +void LyXTabular::SetLongTabular(bool what) { -#warning Should what be bool? (Lgb) is_long_tabular = what; } @@ -1731,9 +1768,8 @@ void LyXTabular::SetUsebox(int cell, BoxType type) } -int LyXTabular::GetUsebox(int cell) const +LyXTabular::BoxType LyXTabular::GetUsebox(int cell) const { -#warning should the return type change? (Lgb) if (column_info[column_of_cell(cell)].p_width.empty() && !(IsMultiColumn(cell) && !cellinfo_of_cell(cell)->p_width.empty())) return BOX_NONE; @@ -1884,7 +1920,6 @@ bool LyXTabular::IsPartOfMultiColumn(int row, int column) const int LyXTabular::TeXTopHLine(ostream & os, int row) const { -#warning should this return a bool? (Lgb) int const fcell = GetFirstCellInRow(row); int const n = NumberOfCellsInRow(fcell) + fcell; int tmp = 0; @@ -1916,7 +1951,6 @@ int LyXTabular::TeXTopHLine(ostream & os, int row) const int LyXTabular::TeXBottomHLine(ostream & os, int row) const { -#warning should this return a bool? (Lgb) int const fcell = GetFirstCellInRow(row); int const n = NumberOfCellsInRow(fcell) + fcell; int tmp = 0; @@ -2217,15 +2251,15 @@ void LyXTabular::Validate(LaTeXFeatures & features) const } -bool LyXTabular::UseParbox(int cell) const +LyXTabular::BoxType LyXTabular::UseParbox(int cell) const { LyXParagraph * par = GetCellInset(cell)->par; for(; par; par = par->next) { for(int i = 0; i < par->Last(); ++i) { if (par->GetChar(i) == LyXParagraph::META_NEWLINE) - return true; + return BOX_PARBOX; } } - return false; + return BOX_NONE; } diff --git a/src/tabular.h b/src/tabular.h index 3035110f62..53f5474f38 100644 --- a/src/tabular.h +++ b/src/tabular.h @@ -33,7 +33,7 @@ class Buffer; class LyXTabular { public: /// - enum { + enum Feature { /// APPEND_ROW = 0, /// @@ -83,8 +83,6 @@ public: /// M_VALIGN_CENTER, /// - DELETE_TABULAR, - /// MULTICOLUMN, /// SET_ALL_LINES, @@ -218,19 +216,19 @@ public: /// Returns true if a complete update is necessary, otherwise false bool SetRightLine(int cell, bool line, bool onlycolumn=false); /// Returns true if a complete update is necessary, otherwise false - bool SetAlignment(int cell, char align, bool onlycolumn = false); + bool SetAlignment(int cell, LyXAlignment align, bool onlycolumn = false); /// Returns true if a complete update is necessary, otherwise false - bool SetVAlignment(int cell, char align, bool onlycolumn = false); + bool SetVAlignment(int cell, VAlignment align, bool onlycolumn = false); /// bool SetColumnPWidth(int cell, string const & width); /// bool SetMColumnPWidth(int cell, string const & width); /// - bool SetAlignSpecial(int cell, string const & special, int what); + bool SetAlignSpecial(int cell, string const & special, Feature what); /// - char GetAlignment(int cell, bool onlycolumn = false) const; + LyXAlignment GetAlignment(int cell, bool onlycolumn = false) const; /// - char GetVAlignment(int cell, bool onlycolumn = false) const; + VAlignment GetVAlignment(int cell, bool onlycolumn = false) const; /// string const GetPWidth(int cell) const; /// @@ -305,7 +303,7 @@ public: /// int right_column_of_cell(int cell) const; /// - void SetLongTabular(int what); + void SetLongTabular(bool); /// bool IsLongTabular() const; /// @@ -333,7 +331,7 @@ public: /// void SetUsebox(int cell, BoxType); /// - int GetUsebox(int cell) const; + BoxType GetUsebox(int cell) const; // // Long Tabular Options /// @@ -375,9 +373,9 @@ private: ////////////////////////////////////////////////////////////////// /// int multicolumn; /// - int alignment; + LyXAlignment alignment; /// - int valignment; + VAlignment valignment; /// bool top_line; /// @@ -387,7 +385,7 @@ private: ////////////////////////////////////////////////////////////////// /// bool right_line; /// - int usebox; + BoxType usebox; /// bool rotate; /// @@ -425,9 +423,9 @@ private: ////////////////////////////////////////////////////////////////// /// columnstruct(); /// - int alignment; + LyXAlignment alignment; /// - int valignment; + VAlignment valignment; /// bool left_line; /// @@ -482,7 +480,7 @@ private: ////////////////////////////////////////////////////////////////// /// void Reinit(); /// - void set_row_column_number_info(); + void set_row_column_number_info(bool oldformat=false); /// Returns true if a complete update is necessary, otherwise false bool SetWidthOfMulticolCell(int cell, int new_width); /// @@ -500,7 +498,7 @@ private: ////////////////////////////////////////////////////////////////// /// int cells_in_multicolumn(int cell) const; /// - bool UseParbox(int cell) const; + BoxType UseParbox(int cell) const; }; #endif diff --git a/src/text.C b/src/text.C index e9ef5677e6..aa793d5d10 100644 --- a/src/text.C +++ b/src/text.C @@ -3402,7 +3402,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, GetFont(bview->buffer(), row_ptr->par(), 0)); int w = (inset_owner ? inset_owner->width(bview, font) : ww); - int xp = (inset_owner ? x : 0); + int xp = static_cast(inset_owner ? x : 0); pain.line(xp, y_offset + y_top, w, y_offset + y_top, LColor::topline, @@ -3583,7 +3583,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, y_bottom -= lyxfont::ascent('x', GetFont(bview->buffer(), par, par->Last() - 1)); int w = (inset_owner ? inset_owner->width(bview, font) : ww); - int xp = (inset_owner ? x : 0); + int xp = static_cast(inset_owner ? x : 0); pain.line(xp, y_offset + y_bottom, w, y_offset + y_bottom, LColor::topline, Painter::line_solid, diff --git a/src/text2.C b/src/text2.C index e9a3a85fca..24f1f000dc 100644 --- a/src/text2.C +++ b/src/text2.C @@ -2140,6 +2140,19 @@ void LyXText::InsertInset(BufferView * bview, Inset * inset) InsertChar(bview, LyXParagraph::META_INSET); /* just to rebreak and refresh correctly. * The character will not be inserted a * second time */ +#if 1 + // if we enter a text-inset the cursor should be to the left side + // of it! This couldn't happen before as Undo was not handled inside + // inset now after the Undo LyX tries to call inset->Edit(...) again + // and cannot do this as the cursor is behind the inset and GetInset + // does not return the inset! + if (inset->IsTextInset()) { + if (cursor.par()->isRightToLeftPar(bview->buffer()->params)) + CursorRight(bview); + else + CursorLeft(bview); + } +#endif }