+2000-06-16 Juergen Vigna <jug@sad.it>
+
+ * src/insets/insettabular.C (UpdateLocal):
+ * src/insets/insettext.C (UpdateLocal): fixed mark_dirty problem.
+ (LocalDispatch): Changed all functions to use LyXText.
+
+2000-06-15 Juergen Vigna <jug@sad.it>
+
+ * src/text.C (SetHeightOfRow): call inset::update before requesting
+ any width/height.
+
+ * src/insets/insettext.C (update):
+ * src/insets/insettabular.C (update): added implementation
+
+ * src/insets/lyxinset.h: added update function
+
2000-06-15 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/text.C (SelectNextWord): protect against null pointers with
src/bullet_forms.C
src/bullet_forms_cb.C
src/Chktex.C
-src/cite.C
src/ColorHandler.C
src/combox.C
src/credits.C
bv_->text->SetCursor(bv_, selstartpar, selstartpos);
bv_->text->sel_cursor = bv_->text->cursor;
bv_->text->SetCursor(bv_, selendpar, selendpos);
- bv_->text->SetSelection(bv_);
+ bv_->text->SetSelection();
bv_->text->SetCursor(bv_, par, pos);
} else {
bv_->text->SetCursor(bv_, par, pos);
if (!bv_->text->selection)
update(BufferView::UPDATE); // Maybe an empty line was deleted
- bv_->text->SetSelection(bv_);
+ bv_->text->SetSelection();
screen->ToggleToggle();
fitCursor();
screen->ShowCursor();
bv_->text->CursorHome(bv_);
bv_->text->sel_cursor = bv_->text->cursor;
bv_->text->CursorEnd(bv_);
- bv_->text->SetSelection(bv_);
+ bv_->text->SetSelection();
screen->ToggleSelection(false);
/* This will fit the cursor on the screen
* if necessary */
{
if (collapsed && autocollapse) {
collapsed = false;
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, false);
InsetText::Edit(bv, 0, 0, button);
} else if (!collapsed) {
InsetText::Edit(bv, x, y, button);
collapsed = true;
}
InsetText::InsetUnlock(bv);
- UpdateLocal(bv, false);
-}
-
-
-void InsetCollapsable::UpdateLocal(BufferView * bv, bool flag)
-{
- InsetText::UpdateLocal(bv, flag);
+ UpdateLocal(bv, false, false);
}
if (collapsed) {
collapsed = false;
InsetText::InsetButtonRelease(bv, 0, 0, button);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, false);
} else {
collapsed = true;
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
bv->unlockInset(this);
}
} else if (!collapsed && (x >= button_length) && (y >= button_top_y)) {
///
void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
///
- void UpdateLocal(BufferView *, bool);
- ///
int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
///
UpdatableInset::draw(pain,font,baseline,x);
if (init_inset || (top_x != int(x)) || (top_baseline != baseline)) {
- int ox = top_x;
+// int ox = top_x;
init_inset = false;
top_x = int(x);
top_baseline = baseline;
- if (ox != top_x)
- recomputeTextInsets(pain, font);
+// if (ox != top_x)
+// recomputeTextInsets(pain, font);
calculate_width_of_cells(pain, font);
resetPos(pain);
reinit = true;
}
+void InsetTabular::update(BufferView * bv, LyXFont const & font) const
+{
+ if (init_inset)
+ recomputeTextInsets(bv, font);
+}
+
+
void InsetTabular::DrawCellLines(Painter & pain, int x, int baseline,
int row, int cell) const
{
if (InsetHit(bv, x, y)) {
ActivateCellInset(bv, x, y, button);
}
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, false);
// bv->getOwner()->getPopups().updateFormTabular();
}
if (hasSelection()) {
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
}
no_selection = false;
oldcell = -1;
locked = false;
}
-void InsetTabular::UpdateLocal(BufferView * bv, bool flag)
+void InsetTabular::UpdateLocal(BufferView * bv, bool what, bool mark_dirty)
{
- if (flag)
+ if (what)
calculate_width_of_cells(bv->painter(), LyXFont(LyXFont::ALL_SANE));
- bv->updateInset(this, flag);
- if (flag)
+ bv->updateInset(this, mark_dirty);
+ if (what)
resetPos(bv->painter());
}
return false;
if (the_locking_inset != inset)
return the_locking_inset->UpdateInsetInInset(bv, inset);
- UpdateLocal(bv);
+ UpdateLocal(bv, true, false);
return true;
}
{
if (hasSelection()) {
sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
}
no_selection = false;
sel_pos_end = cursor.pos();
sel_cell_end = actcell;
if (old != sel_pos_end)
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
#if 0
if (ocell != actcell)
bview->getOwner()->getPopups().updateFormTabular();
else if (result == DISPATCHED) {
bool upd = SetCellDimensions(bv->painter(), actcell, actrow);
the_locking_inset->ToggleInsetCursor(bv);
- UpdateLocal(bv, upd);
+ UpdateLocal(bv, upd, false);
the_locking_inset->ToggleInsetCursor(bv);
return result;
} else if (result == FINISHED) {
else
sel_cell_end = actcell;
}
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
break;
case LFUN_RIGHT:
result = moveRight(bv);
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
if (hs)
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
break;
case LFUN_LEFTSEL:
if (tabular->IsFirstCellInRow(actcell) && cellstart(cursor.pos()))
else
sel_cell_end = actcell-1;
}
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
break;
case LFUN_LEFT:
result = moveLeft(bv);
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
if (hs)
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
break;
case LFUN_DOWNSEL:
{
sel_cell_end = tabular->GetCellBelow(sel_cell_end);
else
sel_cell_end = tabular->GetLastCellBelow(sel_cell_end);
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
}
break;
case LFUN_DOWN:
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
if (hs)
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
break;
case LFUN_UPSEL:
{
sel_cell_end = tabular->GetCellAbove(sel_cell_end);
else
sel_cell_end = tabular->GetLastCellAbove(sel_cell_end);
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
}
break;
case LFUN_UP:
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
if (hs)
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
break;
case LFUN_BACKSPACE:
break;
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
if (hs)
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
break;
case LFUN_LAYOUT_TABLE:
{
bool update = (tabular->GetPWidth(actcell) != val);
tabular->SetPWidth(actcell,val);
if (update)
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
}
break;
case LyXTabular::SET_SPECIAL_COLUMN:
// append the row into the tabular
UnlockInsetInInset(bv, the_locking_inset);
tabular->AppendRow(actcell);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
case LyXTabular::APPEND_COLUMN:
// append the column into the tabular
tabular->AppendColumn(actcell);
actcell = tabular->GetCellNumber(row, column);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
case LyXTabular::DELETE_ROW:
tabular->DeleteRow(tabular->row_of_cell(actcell));
if ((row+1) > tabular->rows())
--row;
actcell = tabular->GetCellNumber(row, column);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
case LyXTabular::DELETE_COLUMN:
tabular->DeleteColumn(tabular->column_of_cell(actcell));
if ((column+1) > tabular->columns())
--column;
actcell = tabular->GetCellNumber(row, column);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
case LyXTabular::TOGGLE_LINE_TOP:
lineSet = !tabular->TopLine(actcell);
for(i=sel_row_start; i<=sel_row_end; ++i)
for(j=sel_col_start; j<=sel_col_end; ++j)
tabular->SetTopLine(tabular->GetCellNumber(i,j),lineSet);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
case LyXTabular::TOGGLE_LINE_BOTTOM:
for(i=sel_row_start; i<=sel_row_end; ++i)
for(j=sel_col_start; j<=sel_col_end; ++j)
tabular->SetBottomLine(tabular->GetCellNumber(i,j),lineSet);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
case LyXTabular::TOGGLE_LINE_LEFT:
for(i=sel_row_start; i<=sel_row_end; ++i)
for(j=sel_col_start; j<=sel_col_end; ++j)
tabular->SetLeftLine(tabular->GetCellNumber(i,j),lineSet);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
case LyXTabular::TOGGLE_LINE_RIGHT:
for(i=sel_row_start; i<=sel_row_end; ++i)
for(j=sel_col_start; j<=sel_col_end; ++j)
tabular->SetRightLine(tabular->GetCellNumber(i,j),lineSet);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
case LyXTabular::ALIGN_LEFT:
case LyXTabular::ALIGN_RIGHT:
for(i=sel_row_start; i<=sel_row_end; ++i)
for(j=sel_col_start; j<=sel_col_end; ++j)
tabular->SetAlignment(tabular->GetCellNumber(i,j),setAlign);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
case LyXTabular::MULTICOLUMN:
{
// check wether we are completly in a multicol
if (tabular->IsMultiColumn(actcell)) {
tabular->UnsetMultiColumn(actcell);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
} else {
tabular->SetMultiColumn(actcell, 1);
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, true);
}
return;
}
cursor.pos(0);
sel_cell_end = sel_cell_start;
sel_pos_end = sel_pos_start;
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
}
case LyXTabular::SET_ALL_LINES:
for(i=sel_row_start; i<=sel_row_end; ++i)
for(j=sel_col_start; j<=sel_col_end; ++j)
tabular->SetAllLines(tabular->GetCellNumber(i,j), setLines);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
case LyXTabular::SET_LONGTABULAR:
tabular->SetLongTabular(true);
- UpdateLocal(bv, true); // because this toggles displayed
+ UpdateLocal(bv, true, true); // because this toggles displayed
break;
case LyXTabular::UNSET_LONGTABULAR:
tabular->SetLongTabular(false);
- UpdateLocal(bv, true); // because this toggles displayed
+ UpdateLocal(bv, true, true); // because this toggles displayed
break;
case LyXTabular::SET_ROTATE_TABULAR:
tabular->SetRotateTabular(true);
inset->Edit(bv, x - inset_x, y - inset_y, button);
if (!the_locking_inset)
return false;
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, false);
return true;
}
return w;
}
-void InsetTabular::recomputeTextInsets(Painter & pain, const LyXFont & font) const
+void InsetTabular::recomputeTextInsets(BufferView * bv, const LyXFont & font) const
{
InsetText * inset;
- int cx, cell;
+ int cell;
- cx = top_x;
+// cx = top_x;
for(int j= 0; j < tabular->columns(); ++j) {
for(int i = 0; i < tabular->rows(); ++i) {
if (tabular->IsPartOfMultiColumn(i,j))
continue;
cell = tabular->GetCellNumber(i,j);
inset = tabular->GetCellInset(cell);
- inset->computeTextRows(pain);
- tabular->SetWidthOfCell(cell, inset->width(pain, font));
+ inset->update(bv, font);
+ inset->computeTextRows(bv->painter());
+ tabular->SetWidthOfCell(cell, inset->width(bv->painter(), font));
}
- cell = tabular->GetCellNumber(0, j);
- cx += tabular->GetWidthOfColumn(cell);
+// cell = tabular->GetCellNumber(0, j);
+// cx += tabular->GetWidthOfColumn(cell);
}
}
///
void draw(Painter & pain, const LyXFont &, int , float &) const;
///
+ void update(BufferView *, LyXFont const &) const;
+ ///
const char * EditMessage() const;
///
void Edit(BufferView *, int x, int y, unsigned int);
///
void InsetUnlock(BufferView *);
///
- void UpdateLocal(BufferView *, bool flag = true);
+ void UpdateLocal(BufferView *, bool what, bool mark_dirty);
///
bool LockInsetInInset(BufferView *, UpdatableInset *);
///
///
int GetMaxWidthOfCell(Painter &, int cell) const;
///
- void recomputeTextInsets(Painter &, const LyXFont &) const;
+ void recomputeTextInsets(BufferView *, const LyXFont &) const;
///
/// Private structures and variables
#include "support/textutils.h"
#include "support/LAssert.h"
#include "lyxrow.h"
+#include "lyxrc.h"
+#include "intl.h"
+#include "trans_mgr.h"
using std::ostream;
using std::ifstream;
selection_start_cursor = selection_end_cursor = cursor;
frame_color = LColor::insetframe;
locked = false;
+ old_par = 0;
}
return;
}
}
+ if (!return_par)
+ return_par = par;
+ par = return_par;
if (token != "\\end_inset") {
lex.printError("Missing \\end_inset at this point. "
"Read: `$$Token'");
}
-int InsetText::ascent(Painter & pain, LyXFont const & font) const
+int InsetText::ascent(Painter &, LyXFont const &) const
{
- if (init_inset) {
- text->init(current_view);
- computeTextRows(pain);
- init_inset = false;
- }
long int y_temp = 0;
Row * row = text->GetRowNearY(y_temp);
return row->ascent_of_text() + 2;
}
-int InsetText::descent(Painter & pain, LyXFont const & font) const
+int InsetText::descent(Painter &, LyXFont const &) const
{
- if (init_inset) {
- text->init(current_view);
- computeTextRows(pain);
- init_inset = false;
- }
long int y = 0;
Row * row = text->GetRowNearY(y);
return text->height - row->ascent_of_text() + 2;
int InsetText::width(Painter & pain, LyXFont const &) const
{
- if (init_inset) {
- text->init(current_view);
- computeTextRows(pain);
- init_inset = false;
- }
return std::max(static_cast<long int>(getMaxTextWidth(pain, this)),
text->width);
-// return insetWidth;
}
{
xpos = x;
UpdatableInset::draw(pain, f, baseline, x);
-
+
+#if 0
if (init_inset) {
text->init(current_view);
- computeTextRows(pain);
- init_inset = false;
- }
+ computeTextRows(pain);
+ init_inset = false;
+ }
+#endif
if ((baseline != top_baseline) || (top_x != int(x))) {
top_baseline = baseline;
top_x = int(x);
}
if (the_locking_inset && (text->cursor.pos() == inset_pos)) {
resetPos(pain);
- inset_x = text->cursor.x() - top_x + drawTextXOffset;
- inset_y = text->cursor.y() + drawTextYOffset;
+ inset_x = cx() - top_x + drawTextXOffset;
+ inset_y = cy() + drawTextYOffset;
}
if (drawLockedFrame && locked) {
pain.rectangle(int(x), baseline - ascent(pain, f), width(pain, f),
}
x += TEXT_TO_INSET_OFFSET; // place for border
#if 1
- // Dump all rowinformation:
- long y_dummy = 0;
- Row * tmprow = text->GetRowNearY(y_dummy);
- lyxerr << "Baseline Paragraph Pos Height Ascent Fill\n";
- while (tmprow) {
- lyxerr << tmprow->baseline() << '\t'
- << tmprow->par() << '\t'
- << tmprow->pos() << '\t'
- << tmprow->height() << '\t'
- << tmprow->ascent_of_text() << '\t'
- << tmprow->fill() << '\n';
- tmprow = tmprow->next();
- }
- lyxerr.flush();
long int y = 0;
Row * row = text->GetRowNearY(y);
y += baseline - row->ascent_of_text() + 1;
- text->width = 0;
while (row != 0) {
text->GetVisibleRow(current_view, y, x, row, y);
y += row->height();
}
+void InsetText::update(BufferView * bv, LyXFont const &) const
+{
+ if (init_inset) {
+ text->init(bv);
+ init_inset = false;
+#if 0
+ // Dump all rowinformation:
+ long y_dummy = 0;
+ Row * tmprow = text->GetRowNearY(y_dummy);
+ lyxerr << "Width = " << text->width << endl;
+ lyxerr << "Baseline Paragraph Pos Height Ascent Fill\n";
+ while (tmprow) {
+ lyxerr << tmprow->baseline() << '\t'
+ << tmprow->par() << '\t'
+ << tmprow->pos() << '\t'
+ << tmprow->height() << '\t'
+ << tmprow->ascent_of_text() << '\t'
+ << tmprow->fill() << '\n';
+ tmprow = tmprow->next();
+ }
+ lyxerr.flush();
+#endif
+ }
+}
+
+
void InsetText::drawRowSelection(Painter & pain, int startpos, int endpos,
int row, int baseline, float x) const
{
setPos(bv->painter(), x, y);
checkAndActivateInset(bv, x, y, button);
selection_start_cursor = selection_end_cursor = cursor;
- current_font = real_current_font =GetFont(bv->buffer(), par, cursor.pos());
+ text->sel_cursor = text->cursor;
bv->text->FinishUndo();
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, false);
}
selection_start_cursor = selection_end_cursor = cursor;
no_selection = false;
locked = false;
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, false);
}
lyxerr[Debug::INSETS] << "OK" << endl;
the_locking_inset = inset;
resetPos(bv->painter());
- inset_x = text->cursor.x() - top_x + drawTextXOffset;
- inset_y = text->cursor.y() + drawTextYOffset;
+ inset_x = cx() - top_x + drawTextXOffset;
+ inset_y = cy() + drawTextYOffset;
inset_pos = text->cursor.pos();
return true;
} else if (the_locking_inset && (the_locking_inset == inset)) {
if (text->cursor.pos() == inset_pos) {
lyxerr[Debug::INSETS] << "OK" << endl;
resetPos(bv->painter());
- inset_x = text->cursor.x() - top_x + drawTextXOffset;
- inset_y = text->cursor.y() + drawTextYOffset;
+ inset_x = cx() - top_x + drawTextXOffset;
+ inset_y = cy() + drawTextYOffset;
} else {
lyxerr[Debug::INSETS] << "cursor.pos != inset_pos" << endl;
}
return the_locking_inset->UpdateInsetInInset(bv, inset);
lyxerr[Debug::INSETS] << "InsetText::UpdateInsetInInset(" << inset <<
")" << endl;
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, false);
if (text->cursor.pos() == inset_pos) {
- inset_x = text->cursor.x() - top_x + drawTextXOffset;
- inset_y = text->cursor.y() + drawTextYOffset;
+ inset_x = cx() - top_x + drawTextXOffset;
+ inset_y = cy() + drawTextYOffset;
}
return true;
}
{
if (hasSelection()) {
selection_start_cursor = selection_end_cursor = cursor;
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
}
no_selection = false;
setPos(bv->painter(), x, y);
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);
+ UpdateLocal(bv, true, false);
return;
}
// otherwise only unlock the_locking_inset
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);
+ UpdateLocal(bv, true, false);
}
}
selection_start_cursor = selection_end_cursor = cursor;
setPos(bv->painter(), x, y);
selection_end_cursor = cursor;
if (old != selection_end_cursor)
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
ShowInsetCursor(bv);
}
no_selection = false;
return result;
else if (result == DISPATCHED) {
the_locking_inset->ToggleInsetCursor(bv);
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
the_locking_inset->ToggleInsetCursor(bv);
return result;
} else if (result == FINISHED) {
switch (action) {
// Normal chars
case -1:
- bv->text->SetUndo(bv->buffer(), Undo::INSERT,
- bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
- bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
- cutSelection(bv->buffer());
- cursor = selection_start_cursor;
- par->InsertChar(cursor.pos(), arg[0]);
- SetCharFont(bv->buffer(), cursor.pos(), current_font);
- cursor.pos(cursor.pos() + 1);
- selection_start_cursor = selection_end_cursor = cursor;
- UpdateLocal(bv, true);
+ if (bv->buffer()->isReadonly()) {
+ LyXBell();
+// setErrorMessage(N_("Document is read only"));
+ break;
+ }
+ if (!arg.empty()) {
+ /* Automatically delete the currently selected
+ * text and replace it with what is being
+ * typed in now. Depends on lyxrc settings
+ * "auto_region_delete", which defaults to
+ * true (on). */
+
+ bv->text->SetUndo(bv->buffer(), Undo::INSERT,
+ bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
+ bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
+ if (lyxrc.auto_region_delete) {
+ if (text->selection){
+ text->CutSelection(bv, false);
+ }
+ }
+ text->ClearSelection();
+ for (string::size_type i = 0; i < arg.length(); ++i) {
+ bv->owner()->getIntl()->getTrans()->TranslateAndInsert(arg[i], text);
+ }
+ }
+ UpdateLocal(bv, true, true);
break;
// --- Cursor Movements ---------------------------------------------
case LFUN_RIGHTSEL:
bv->text->FinishUndo();
moveRight(bv, false);
- selection_end_cursor = cursor;
- UpdateLocal(bv, false);
+ text->SetSelection();
+ UpdateLocal(bv, false, false);
break;
case LFUN_RIGHT:
bv->text->FinishUndo();
result = moveRight(bv);
- if (hasSelection()) {
- selection_start_cursor = selection_end_cursor = cursor;
- UpdateLocal(bv, false);
- } else {
- selection_start_cursor = selection_end_cursor = cursor;
- }
+ text->sel_cursor = text->cursor;
+ UpdateLocal(bv, false, false);
break;
case LFUN_LEFTSEL:
bv->text->FinishUndo();
moveLeft(bv, false);
- selection_end_cursor = cursor;
- UpdateLocal(bv, false);
+ text->SetSelection();
+ UpdateLocal(bv, false, false);
break;
case LFUN_LEFT:
bv->text->FinishUndo();
result= moveLeft(bv);
- if (hasSelection()) {
- selection_start_cursor = selection_end_cursor = cursor;
- UpdateLocal(bv, false);
- } else {
- selection_start_cursor = selection_end_cursor = cursor;
- }
+ text->sel_cursor = text->cursor;
+ UpdateLocal(bv, false, false);
break;
case LFUN_DOWNSEL:
bv->text->FinishUndo();
moveDown(bv);
selection_end_cursor = cursor;
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
break;
case LFUN_DOWN:
bv->text->FinishUndo();
result = moveDown(bv);
- if (hasSelection()) {
- selection_start_cursor = selection_end_cursor = cursor;
- UpdateLocal(bv, false);
- } else {
- selection_start_cursor = selection_end_cursor = cursor;
- }
+ text->sel_cursor = text->cursor;
+ UpdateLocal(bv, false, false);
break;
case LFUN_UPSEL:
bv->text->FinishUndo();
moveUp(bv);
selection_end_cursor = cursor;
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
break;
case LFUN_UP:
bv->text->FinishUndo();
result = moveUp(bv);
- if (hasSelection()) {
- selection_start_cursor = selection_end_cursor = cursor;
- UpdateLocal(bv, false);
- } else {
- selection_start_cursor = selection_end_cursor = cursor;
- }
+ text->sel_cursor = text->cursor;
+ UpdateLocal(bv, false, false);
+ break;
+ case LFUN_HOME:
+ bv->text->FinishUndo();
+ text->CursorHome(bv);
+ text->sel_cursor = text->cursor;
+ UpdateLocal(bv, false, false);
+ break;
+ case LFUN_END:
+ text->CursorEnd(bv);
+ text->sel_cursor = text->cursor;
+ UpdateLocal(bv, false, false);
break;
case LFUN_BACKSPACE:
- if (!cursor.pos()) {
- if (hasSelection()) {
- selection_start_cursor = selection_end_cursor = cursor;
- UpdateLocal(bv, false);
- }
- break;
- }
- moveLeft(bv);
+ bv->text->SetUndo(bv->buffer(), Undo::DELETE,
+ bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
+ bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
+ text->Backspace(bv);
+ UpdateLocal(bv, true, true);
+ break;
case LFUN_DELETE:
- {
- bv->text->SetUndo(bv->buffer(), Undo::DELETE,
- 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());
- }
- } else
- ret = Delete();
- if (ret) { // we need update
- selection_start_cursor = selection_end_cursor = cursor;
- UpdateLocal(bv, true);
- } else if (hasSelection()) {
- selection_start_cursor = selection_end_cursor = cursor;
- UpdateLocal(bv, false);
- }
- }
- resetPos(bv->painter());
- break;
+ bv->text->SetUndo(bv->buffer(), Undo::DELETE,
+ bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
+ bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
+ text->Delete(bv);
+ UpdateLocal(bv, true, true);
+ break;
case LFUN_CUT:
bv->text->SetUndo(bv->buffer(), Undo::DELETE,
bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
-
- if (cutSelection(bv->buffer())) {
- // we need update
- cursor = selection_end_cursor = selection_start_cursor;
- UpdateLocal(bv, true);
- } else if (hasSelection()) {
- selection_start_cursor = selection_end_cursor = cursor;
- UpdateLocal(bv, false);
- }
- resetPos(bv->painter());
+ text->CutSelection(bv);
+ UpdateLocal(bv, true, true);
break;
case LFUN_COPY:
bv->text->FinishUndo();
- if (copySelection(bv->buffer())) {
- // we need update
- selection_start_cursor = selection_end_cursor = cursor;
- UpdateLocal(bv, true);
- } else if (hasSelection()) {
- selection_start_cursor = selection_end_cursor = cursor;
- UpdateLocal(bv, false);
- }
+ text->CopySelection(bv);
+ UpdateLocal(bv, true, false);
break;
case LFUN_PASTE:
- {
bv->text->SetUndo(bv->buffer(), Undo::INSERT,
bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
- if (pasteSelection(bv->buffer())) {
- selection_start_cursor = selection_end_cursor = cursor;
- UpdateLocal(bv, true);
- }
- }
- resetPos(bv->painter());
- break;
- case LFUN_HOME:
- bv->text->FinishUndo();
- 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);
- } else {
- selection_start_cursor = selection_end_cursor = cursor;
- }
- resetPos(bv->painter());
+ text->PasteSelection(bv);
+ UpdateLocal(bv, true, true);
break;
- case LFUN_END:
- {
- bv->text->FinishUndo();
- int checkpos = (int)rows[actrow + 1].pos;
- if ((actrow + 2) < (int)rows.size())
- --checkpos;
- 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);
- } else {
- selection_start_cursor = selection_end_cursor = cursor;
- }
- }
- resetPos(bv->painter());
- break;
case LFUN_BREAKPARAGRAPH:
+ if (!autoBreakRows)
+ return DISPATCHED;
+ text->BreakParagraph(bv, 0);
+ UpdateLocal(bv, true, true);
+ break;
case LFUN_BREAKLINE:
if (!autoBreakRows)
return DISPATCHED;
bv->text->SetUndo(bv->buffer(), 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(bv->buffer(), cursor.pos(),current_font);
- UpdateLocal(bv, true);
- cursor.pos(cursor.pos() + 1);
- selection_start_cursor = selection_end_cursor = cursor;
- resetPos(bv->painter());
+ text->InsertChar(bv, LyXParagraph::META_NEWLINE);
+ UpdateLocal(bv, true, true);
break;
case LFUN_LAYOUT:
{
cur_layout = layout.second;
text->SetLayout(bv, layout.second);
bv->owner()->getToolbar()->combox->select(cursor.par()->GetLayout()+1);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
}
}
break;
// the font for drawing may be different from the real font
LyXFont InsetText::GetDrawFont(Buffer const * buf, LyXParagraph * p, int pos) const
{
- return GetFont(buf, p, pos);
+ return text->GetFont(buf, p, pos);
}
return;
}
- LyXFont font = GetDrawFont(bv->buffer(), par, text->cursor.pos());
+ LyXFont font = GetDrawFont(bv->buffer(), cpar(), cpos());
int asc = lyxfont::maxAscent(font);
int desc = lyxfont::maxDescent(font);
- asc = text->cursor.row()->ascent_of_text();
- desc = text->cursor.row()->height() - asc;
if (cursor_visible)
bv->hideLockedInsetCursor();
else
- bv->showLockedInsetCursor(text->cursor.x(), text->cursor.y(),
+ bv->showLockedInsetCursor(cx(), cy(),
asc, desc);
cursor_visible = !cursor_visible;
}
return;
}
if (!cursor_visible) {
- LyXFont font = GetDrawFont(bv->buffer(), par, cursor.pos());
+ LyXFont font = GetDrawFont(bv->buffer(), cpar(), cpos());
int asc = lyxfont::maxAscent(font);
int desc = lyxfont::maxDescent(font);
- asc = text->cursor.row()->ascent_of_text();
- desc = text->cursor.row()->height() - asc;
- bv->fitLockedInsetCursor(text->cursor.x(), text->cursor.y(), asc, desc);
- bv->showLockedInsetCursor(text->cursor.x(), text->cursor.y(), asc, desc);
+
+ bv->fitLockedInsetCursor(cx(), cy(), asc, desc);
+ bv->showLockedInsetCursor(cx(), cy(), asc, desc);
cursor_visible = true;
}
}
UpdatableInset::RESULT
InsetText::moveRight(BufferView * bv, bool activate_inset)
{
- if (cursor.pos() >= par->Last())
+ if (!cpar()->next && (cpos() >= cpar()->Last()))
return FINISHED;
if (activate_inset && checkAndActivateInset(bv)) {
return DISPATCHED;
}
- cursor.pos(cursor.pos() + 1);
- resetPos(bv->painter());
- real_current_font = current_font =GetFont(bv->buffer(), par, cursor.pos());
+ text->CursorRight(bv);
+// real_current_font = current_font = GetFont(bv->buffer(), cpar(), cpos());
return DISPATCHED_NOUPDATE;
}
UpdatableInset::RESULT
InsetText::moveLeft(BufferView * bv, bool activate_inset)
{
- if (cursor.pos() <= 0)
+ if (!cpar()->previous && (cpos() <= 0))
return FINISHED;
- cursor.pos(cursor.pos() - 1);
- resetPos(bv->painter());
+ text->CursorLeft(bv);
if (activate_inset)
if (checkAndActivateInset(bv, -1, -1))
return DISPATCHED;
UpdatableInset::RESULT
InsetText::moveUp(BufferView * bv)
{
- if (!actrow)
+ if (!crow()->previous())
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());
+ text->CursorUp(bv);
return DISPATCHED_NOUPDATE;
}
UpdatableInset::RESULT
InsetText::moveDown(BufferView * bv)
{
- if (actrow >= int(rows.size() - 2))
+ if (!crow()->next())
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());
+ text->CursorDown(bv);
return DISPATCHED_NOUPDATE;
}
} else {
selection_start_cursor = selection_end_cursor = cursor;
}
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
static_cast<UpdatableInset*>(inset)->Edit(bv, 0, 0, 0);
return true;
}
void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall)
{
- // if there is no selection just set the current_font
- if (!hasSelection()) {
- // Determine basis font
- LyXFont layoutfont;
- if (cursor.pos() < BeginningOfMainBody(bv->buffer(), par))
- layoutfont = GetFont(bv->buffer(), par, -2);
- else
- layoutfont = GetFont(bv->buffer(), par, -1);
-
- // Update current font
- real_current_font.update(font, bv->buffer()->params.language_info,
- toggleall);
-
- // Reduce to implicit settings
- current_font = real_current_font;
- current_font.reduce(layoutfont);
- // And resolve it completely
- real_current_font.realize(layoutfont);
- 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();
- } else {
- s_start = selection_start_cursor.pos();
- s_end = selection_end_cursor.pos();
- }
- LyXFont newfont;
- while(s_start < s_end) {
- newfont = GetFont(bv->buffer(), par,s_start);
- newfont.update(font, bv->buffer()->params.language_info, toggleall);
- SetCharFont(bv->buffer(), s_start, newfont);
- ++s_start;
- }
- UpdateLocal(bv, true);
-}
-
-
-void InsetText::SetCharFont(Buffer const * buf, int pos, LyXFont const & f) //
-{
- /* let the insets convert their font */
- LyXFont font(f);
-
- if (par->GetChar(pos) == LyXParagraph::META_INSET) {
- if (par->GetInset(pos))
- font = par->GetInset(pos)->ConvertFont(font);
- }
- LyXLayout const & layout =
- textclasslist.Style(buf->params.textclass,par->GetLayout());
-
- // Get concrete layout font to reduce against
- LyXFont layoutfont;
-
- if (pos < BeginningOfMainBody(buf, par))
- layoutfont = layout.labelfont;
- else
- layoutfont = layout.font;
-
-
- layoutfont.realize((textclasslist.TextClass(buf->params.textclass).
- defaultfont()));
-
- // Now, reduce font against full layout font
- font.reduce(layoutfont);
-
- par->SetFont(pos, font);
+ text->SetFont(bv, font, toggleall);
}
}
-void InsetText::UpdateLocal(BufferView * bv, bool flag)
+void InsetText::UpdateLocal(BufferView * bv, bool what, bool mark_dirty)
{
- if (flag) {
+ if (what) {
text->FullRebreak(bv);
- computeTextRows(bv->painter());
- computeBaselines(top_baseline);
}
- bv->updateInset(this, flag);
- if (flag)
- resetPos(bv->painter());
- bv->owner()->getToolbar()->combox->select(cursor.par()->GetLayout()+1);
+ bv->updateInset(this, mark_dirty);
+// if (flag)
+// resetPos(bv->painter());
+ if (old_par != cpar()) {
+ bv->owner()->getToolbar()->combox->select(cpar()->GetLayout()+1);
+ old_par = cpar();
+ }
}
if (par->GetChar(cursor.pos()) == LyXParagraph::META_INSET) {
UpdatableInset * inset =
static_cast<UpdatableInset*>(par->GetInset(cursor.pos()));
- LyXFont font = GetFont(bv->buffer(), par, cursor.pos());
+ LyXFont font = text->GetFont(bv->buffer(), cpar(), cpos());
if (x < 0)
x = inset->width(bv->painter(), font);
if (y < 0)
inset->Edit(bv, x - inset_x, y - inset_y, button);
if (!the_locking_inset)
return false;
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, false);
return true;
}
return false;
init_inset = true;
}
}
+
+int InsetText::cx() const
+{
+ return text->cursor.x() + top_x + 1;
+}
+
+int InsetText::cy() const
+{
+ long int y_dummy = 0;
+ Row * tmprow = text->GetRowNearY(y_dummy);
+ return text->cursor.y() - tmprow->baseline();
+}
+
+int InsetText::cpos() const
+{
+ return text->cursor.pos();
+}
+
+LyXParagraph * InsetText::cpar() const
+{
+ return text->cursor.par();
+}
+
+Row * InsetText::crow() const
+{
+ return text->cursor.row();
+}
///
void draw(Painter & pain, LyXFont const &, int , float &) const;
///
+ void update(BufferView *, LyXFont const &) const;
+ ///
char const * EditMessage() const;
///
void Edit(BufferView *, int, int, unsigned int);
protected:
///
- void UpdateLocal(BufferView *, bool);
+ void UpdateLocal(BufferView *, bool what, bool mark_dirty);
///
void WriteParagraphData(Buffer const *, std::ostream &) const;
///
///
bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0,
int button = 0);
+ int cx() const;
+ int cy() const;
+ int cpos() const;
+ LyXParagraph * cpar() const;
+ Row * crow() const;
/* Private structures and variables */
///
typedef std::vector<row_struct> RowList;
///
mutable RowList rows;
+ ///
+ LyXParagraph * old_par;
};
#endif
///
virtual void draw(Painter &, LyXFont const &,
int baseline, float & x) const = 0;
+ /// update the inset representation
+ virtual void update(BufferView *, LyXFont const &) const {}
///
virtual LyXFont ConvertFont(LyXFont font);
/// what appears in the minibuffer when opening
bv->text->sel_cursor = bv->text->cursor;
for (int i = 0; i < len; ++i)
bv->text->CursorRight(bv);
- bv->text->SetSelection(bv);
+ bv->text->SetSelection();
}
void LyXFunc::moveCursorUpdate(bool selecting)
{
if (selecting || owner->view()->text->mark_set) {
- owner->view()->text->SetSelection(owner->view());
+ owner->view()->text->SetSelection();
owner->view()->toggleToggle();
}
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
if (owner->view()->available() &&
owner->view()->the_locking_inset) {
UpdatableInset::RESULT result;
- if (action > 1
- || (action == LFUN_UNKNOWN_ACTION
- && keyseq.length >= -1)) {
- if (action == LFUN_UNKNOWN_ACTION
- && argument.empty()) {
+ if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
+ (keyseq.length >= -1)))
+ {
+ if ((action==LFUN_UNKNOWN_ACTION) && argument.empty()){
argument = keyseq.getiso();
}
// Undo/Redo pre 0.13 is a bit tricky for insets.
*/
Row * GetRow(LyXParagraph * par,
LyXParagraph::size_type pos, long & y) const;
+
/** returns the height of a default row, needed for scrollbar
*/
int DefaultHeight() const;
LyXCursor toggle_end_cursor;
/// need the selection cursor:
- void SetSelection(BufferView *);
+ void SetSelection();
///
void ClearSelection() const;
///
font.decSize();
return lyxfont::width(fs, font);
} else if (c == LyXParagraph::META_INSET) {
- Inset * tmpinset= par->GetInset(pos);
- if (tmpinset)
- return par->GetInset(pos)->width(bview->painter(),
- font);
- else
+ Inset * tmpinset = par->GetInset(pos);
+ if (tmpinset) {
+ tmpinset->update(bview, font);
+ return tmpinset->width(bview->painter(), font);
+ } else
return 0;
} else if (IsSeparatorChar(c))
int maxdesc = int(lyxfont::maxDescent(font) *
layout.spacing.getValue() *
spacing_val);
-
int pos_end = RowLast(row_ptr);
-
int labeladdon = 0;
+ int maxwidth = 0;
// Check if any insets are larger
for (pos = row_ptr->pos(); pos <= pos_end; ++pos) {
- if (row_ptr->par()->GetChar(pos) == LyXParagraph::META_INSET) {
- tmpfont = GetFont(bview->buffer(), row_ptr->par(), pos);
- tmpinset = row_ptr->par()->GetInset(pos);
- if (tmpinset) {
- asc = tmpinset->ascent(bview->painter(), tmpfont);
- desc = tmpinset->descent(bview->painter(), tmpfont);
- if (asc > maxasc)
- maxasc = asc;
- if (desc > maxdesc)
- maxdesc = desc;
- }
- }
+ if (row_ptr->par()->GetChar(pos) == LyXParagraph::META_INSET) {
+ tmpfont = GetFont(bview->buffer(), row_ptr->par(), pos);
+ tmpinset = row_ptr->par()->GetInset(pos);
+ if (tmpinset) {
+ tmpinset->update(bview, tmpfont);
+ asc = tmpinset->ascent(bview->painter(), tmpfont);
+ desc = tmpinset->descent(bview->painter(), tmpfont);
+ maxwidth += tmpinset->width(bview->painter(), tmpfont);
+ maxasc = max(maxasc, asc);
+ maxdesc = max(maxdesc, desc);
+ }
+ } else {
+ maxwidth += SingleWidth(bview, row_ptr->par(), pos);
+ }
}
// Check if any custom fonts are larger (Asger)
row_ptr->baseline(maxasc + labeladdon);
height += row_ptr->height();
+ width = maxwidth;
}
SetCursor(bview, cursor.par(), cursor.pos() );
// finally set the selection
- SetSelection(bview);
+ SetSelection();
}
SetCursor(bview, cursor.par(), cursor.pos());
// finally set the selection
- SetSelection(bview);
+ SetSelection();
}
SetCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos());
sel_cursor = cursor;
cursor = tmpcursor;
- SetSelection(bview);
+ SetSelection();
/* -----> Great, CutSelection() gets rid of multiple spaces. */
CutSelection(bview);
SetCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos());
sel_cursor = cursor;
cursor = tmpcursor;
- SetSelection(bview);
+ SetSelection();
CutSelection(bview);
}
}
SetCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos());
sel_cursor = cursor;
cursor = tmpcursor;
- SetSelection(bview);
+ SetSelection();
// What is this test for ??? (JMarc)
if (!selection) {
DeleteWordForward(bview);
LColor::selection);
} else if (sel_start_cursor.row() == row_ptr) {
if (is_rtl)
- pain.fillRectangle(0, y_offset,
+ pain.fillRectangle(x_offset, y_offset,
sel_start_cursor.x(),
row_ptr->height(),
LColor::selection);
row_ptr->height(),
LColor::selection);
else
- pain.fillRectangle(0, y_offset,
+ pain.fillRectangle(x_offset, y_offset,
sel_end_cursor.x(),
row_ptr->height(),
LColor::selection);
} else if (y > long(sel_start_cursor.y())
&& y < long(sel_end_cursor.y())) {
- pain.fillRectangle(0, y_offset,
+ pain.fillRectangle(x_offset, y_offset,
ww, row_ptr->height(),
LColor::selection);
}
sel_end_cursor.row() != row_ptr &&
y > long(sel_start_cursor.y())
&& y < long(sel_end_cursor.y())) {
- pain.fillRectangle(0, y_offset, ww, row_ptr->height(),
+ pain.fillRectangle(x_offset, y_offset, ww, row_ptr->height(),
LColor::selection);
} else if (sel_start_cursor.row() == row_ptr ||
sel_end_cursor.row() == row_ptr) {
#endif
if ( (sel_start_cursor.row() != row_ptr && !is_rtl) ||
(sel_end_cursor.row() != row_ptr && is_rtl))
- pain.fillRectangle(0, y_offset,
+ pain.fillRectangle(x_offset, y_offset,
int(tmpx),
row_ptr->height(),
LColor::selection);
#ifndef NEW_TABULAR
}
#endif
- // Jürgen!!! FIX This! (NOW!!!) (please)
- width = max(x - x_offset, float(width));
}
lastrow = 0;
number_of_rows = 0;
refresh_y = 0;
- height = 0;
+ height = width = 0;
status = LyXText::UNCHANGED;
// set cursor at the very top position
selection = true; /* these setting is necessary
#if 1
// Dump all rowinformation:
Row * tmprow = firstrow;
+ lyxerr << "Width = " << width << endl;
lyxerr << "Baseline Paragraph Pos Height Ascent Fill\n";
while (tmprow) {
lyxerr << tmprow->baseline() << '\t'
false);
UpdateCounters(bview, cursor.row());
ClearSelection();
- SetSelection(bview);
+ SetSelection();
SetCursor(bview, tmpcursor.par(), tmpcursor.pos(), true);
}
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
UpdateCounters(bview, cursor.row());
ClearSelection();
- SetSelection(bview);
+ SetSelection();
SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
}
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
UpdateCounters(bview, cursor.row());
ClearSelection();
- SetSelection(bview);
+ SetSelection();
SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
}
sel_cursor = cursor;
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
ClearSelection();
- SetSelection(bview);
+ SetSelection();
SetCursor(bview, tmpcursor.par(), tmpcursor.pos(), true,
tmpcursor.boundary());
}
* They also delete the corresponding row */
// need the selection cursor:
-void LyXText::SetSelection(BufferView * bview)
+void LyXText::SetSelection()
{
if (!selection) {
last_sel_cursor = sel_cursor;
SetCursor(bview, sel_start_cursor.par(), sel_start_cursor.pos());
sel_cursor = cursor;
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
- SetSelection(bview);
+ SetSelection();
SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
}
SetCursor(bview, sel_start_cursor.par(), sel_start_cursor.pos());
sel_cursor = cursor;
SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos());
- SetSelection(bview);
+ SetSelection();
SetCursor(bview, tmpcursor.par(), tmpcursor.pos());
}
}
-#ifdef USE_OLD_CUT_AND_PASTE
-// this is for the simple cut and paste mechanism
-static LyXParagraph * simple_cut_buffer = 0;
-static char simple_cut_buffer_textclass = 0;
-
-void DeleteSimpleCutBuffer()
-{
- if (!simple_cut_buffer)
- return;
- LyXParagraph * tmppar;
-
- while (simple_cut_buffer) {
- tmppar = simple_cut_buffer;
- simple_cut_buffer = simple_cut_buffer()->next;
- delete tmppar;
- }
- simple_cut_buffer = 0;
-}
-#endif
-
void LyXText::copyEnvironmentType()
{
copylayouttype = cursor.par()->GetLayout();
void LyXText::CutSelection(BufferView * bview, bool doclear)
{
-
// Stuff what we got on the clipboard. Even if there is no selection.
// There is a problem with having the stuffing here in that the
}
/* table stuff -- end */
#endif
-
// make sure that the depth behind the selection are restored, too
LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->Next();
LyXParagraph * undoendpar = endpar;
sel_cursor = cursor;
UpdateCounters(bview, cursor.row());
}
-
+
void LyXText::CopySelection(BufferView * bview)
{
sel_cursor = cursor;
SetCursor(bview, actpar, pos);
- SetSelection(bview);
+ SetSelection();
UpdateCounters(bview, cursor.row());
}
sel_cursor = cursor;
for (int i = 0; string[i]; ++i)
CursorRight(bview);
- SetSelection(bview);
+ SetSelection();
}
SetCursor(bview, cursor.par(), cursor.pos());
sel_cursor = cursor;
SetCursor(bview, par, pos);
- SetSelection(bview);
+ SetSelection();
}
// undo functions
bool LyXText::TextUndo(BufferView * bview)
{
+ if (inset_owner)
+ return false;
// returns false if no undo possible
Undo * undo = bview->buffer()->undostack.pop();
if (undo) {
bool LyXText::TextRedo(BufferView * bview)
{
+ if (inset_owner)
+ return false;
// returns false if no redo possible
Undo * undo = bview->buffer()->redostack.pop();
if (undo) {
bool LyXText::TextHandleUndo(BufferView * bview, Undo * undo)
{
+ if (inset_owner)
+ return false;
// returns false if no undo possible
bool result = false;
if (undo) {
void LyXText::FinishUndo()
{
+ if (inset_owner)
+ return;
// makes sure the next operation will be stored
undo_finished = true;
}
void LyXText::FreezeUndo()
{
+ if (inset_owner)
+ return;
// this is dangerous and for internal use only
undo_frozen = true;
}
void LyXText::UnFreezeUndo()
{
+ if (inset_owner)
+ return;
// this is dangerous and for internal use only
undo_frozen = false;
}
LyXParagraph const * before,
LyXParagraph const * behind) const
{
+ if (inset_owner)
+ return;
if (!undo_frozen)
buf->undostack.push(CreateUndo(buf, kind, before, behind));
buf->redostack.clear();
void LyXText::SetRedo(Buffer * buf, Undo::undo_kind kind,
LyXParagraph const * before, LyXParagraph const * behind)
{
+ if (inset_owner)
+ return;
buf->redostack.push(CreateUndo(buf, kind, before, behind));
}
LyXParagraph const * before,
LyXParagraph const * behind) const
{
+ if (inset_owner)
+ return 0;
+
int before_number = -1;
int behind_number = -1;
if (before)
// appear one by one when undoing.
// EDIT is special since only layout information, not the
// contents of a paragaph are stored.
- if (!undo_finished && kind != Undo::EDIT &&
- kind != Undo::FINISH){
+ if (!undo_finished && (kind != Undo::EDIT) && (kind != Undo::FINISH)){
// check wether storing is needed
if (!buf->undostack.empty() &&
buf->undostack.top()->kind == kind &&
void LyXText::SetCursorParUndo(Buffer * buf)
{
+ if (inset_owner)
+ return;
SetUndo(buf, Undo::FINISH,
cursor.par()->ParFromPos(cursor.pos())->previous,
cursor.par()->ParFromPos(cursor.pos())->next);