// just for test!!!
the_locking_inset = 0;
locked = no_selection = cursor_visible = false;
- cursor.x_fix(-1);
oldcell = -1;
actrow = actcell = 0;
clearSelection();
tabular = new LyXTabular(this, *(tab.tabular));
the_locking_inset = 0;
locked = no_selection = cursor_visible = false;
- cursor.x_fix(-1);
oldcell = -1;
actrow = actcell = 0;
sel_cell_start = sel_cell_end = 0;
return;
Painter & pain = bv->painter();
- int i, j;
+ int i;
+ int j;
int nx;
UpdatableInset::draw(bv, font, baseline, x, cleared);
if (cleared) {
int cell = 0;
float cx;
+ first_visible_cell = -1;
for (i = 0; i < tabular->rows(); ++i) {
nx = int(x);
dodraw = ((baseline + tabular->GetDescentOfRow(i)) > 0) &&
continue;
cx = nx + tabular->GetBeginningOfTextInCell(cell);
if (dodraw) {
+ if (first_visible_cell < 0)
+ first_visible_cell = cell;
if (hasSelection())
DrawCellSelection(pain, nx, baseline, i, j, cell);
tabular->GetCellInset(cell)->draw(bv, font, baseline, cx,
void InsetTabular::DrawCellLines(Painter & pain, int x, int baseline,
int row, int cell) const
{
- int x2 = x + tabular->GetWidthOfColumn(cell);
+ int x2 = x + tabular->GetWidthOfColumn(cell);
bool on_off;
if (!tabular->TopAlreadyDrawed(cell)) {
oldcell = -1;
locked = false;
if (scroll() || hasSelection()) {
+ sel_cell_start = sel_cell_end = 0;
if (scroll()) {
scroll(bv, 0.0F);
- } else {
- sel_cell_start = sel_cell_end = 0;
}
UpdateLocal(bv, FULL, false);
}
}
-UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
+UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv,
+ kb_action action,
string const & arg)
{
// We need to save the value of the_locking_inset as the call to
if ((action < 0) && arg.empty())
return FINISHED;
- if ((action != LFUN_DOWN) && (action != LFUN_UP) &&
- (action != LFUN_DOWNSEL) && (action != LFUN_UPSEL))
- cursor.x_fix(-1);
if (the_locking_inset) {
result=the_locking_inset->LocalDispatch(bv, action, arg);
- if (result == DISPATCHED_NOUPDATE)
+ if (result == DISPATCHED_NOUPDATE) {
+ int sc = scroll();
+ resetPos(bv);
+ if (sc != scroll()) { // inset has been scrolled
+ the_locking_inset->ToggleInsetCursor(bv);
+ UpdateLocal(bv, FULL, false);
+ the_locking_inset->ToggleInsetCursor(bv);
+ }
return result;
- else if (result == DISPATCHED) {
+ } else if (result == DISPATCHED) {
the_locking_inset->ToggleInsetCursor(bv);
UpdateLocal(bv, CELL, false);
the_locking_inset->ToggleInsetCursor(bv);
if (hs)
UpdateLocal(bv, SELECTION, false);
break;
+ case LFUN_NEXT: {
+ int column = actcol;
+ if (the_locking_inset) {
+ UnlockInsetInInset(bv, the_locking_inset);
+ the_locking_inset = 0;
+ }
+ if (bv->text->first + bv->painter().paperHeight() <
+ (top_baseline + tabular->GetHeightOfTabular()))
+ {
+ bv->scrollCB(bv->text->first + bv->painter().paperHeight());
+ UpdateLocal(bv, FULL, false);
+ actcell = tabular->GetCellBelow(first_visible_cell) + column;
+ } else {
+ actcell = tabular->GetFirstCellInRow(tabular->rows() - 1) + column;
+ }
+ resetPos(bv);
+ UpdateLocal(bv, CURSOR, false);
+ break;
+ }
+ case LFUN_PRIOR: {
+ int column = actcol;
+ if (the_locking_inset) {
+ UnlockInsetInInset(bv, the_locking_inset);
+ the_locking_inset = 0;
+ }
+ if (top_baseline < 0) {
+ bv->scrollCB(bv->text->first - bv->painter().paperHeight());
+ UpdateLocal(bv, FULL, false);
+ if (top_baseline > 0)
+ actcell = column;
+ else
+ actcell = tabular->GetCellBelow(first_visible_cell) + column;
+ } else {
+ actcell = column;
+ }
+ resetPos(bv);
+ UpdateLocal(bv, CURSOR, false);
+ break;
+ }
case LFUN_BACKSPACE:
break;
case LFUN_DELETE:
break;
bv->text->SetUndo(bv->buffer(), Undo::DELETE,
#ifndef NEW_INSETS
- 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_
#else
- bv->text->cursor.par()->previous,
- bv->text->cursor.par()->next
+ bv->text->cursor.par()->previous(),
+ bv->text->cursor.par()->next()
#endif
);
cutSelection();
if (hasPasteBuffer()) {
bv->text->SetUndo(bv->buffer(), Undo::INSERT,
#ifndef NEW_INSETS
- 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_
#else
- bv->text->cursor.par()->previous,
- bv->text->cursor.par()->next
+ bv->text->cursor.par()->previous(),
+ bv->text->cursor.par()->next()
#endif
);
pasteSelection(bv);
new_x += offset;
cursor.x(new_x);
// cursor.x(getCellXPos(actcell) + offset);
- if (((cursor.x() - offset) > 20) &&
- ((cursor.x()-offset+tabular->GetWidthOfColumn(actcell)) >
- (bv->workWidth()-20)))
+ if (scroll() && (tabular->GetWidthOfTabular() < bv->workWidth()-20))
+ scroll(bv, 0.0F);
+ else if (the_locking_inset &&
+ (tabular->GetWidthOfColumn(actcell) > bv->workWidth()-20))
+ {
+ int xx = cursor.x() - offset + bv->text->GetRealCursorX(bv);
+ if (xx > (bv->workWidth()-20))
+ scroll(bv, -(xx - bv->workWidth() + 60));
+ else if (xx < 20) {
+ if (xx < 0)
+ xx = -xx + 60;
+ else
+ xx = 60;
+ scroll(bv, xx);
+ }
+ } else if (((cursor.x() - offset) > 20) &&
+ ((cursor.x()-offset+tabular->GetWidthOfColumn(actcell)) >
+ (bv->workWidth()-20)))
{
scroll(bv, -tabular->GetWidthOfColumn(actcell)-20);
UpdateLocal(bv, FULL, false);
if ((!the_locking_inset ||
!the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE)) &&
(actcell != oldcell)) {
- InsetTabular * inset = const_cast<InsetTabular *>(this);
- bv->owner()->getDialogs()->updateTabular(inset);
- oldcell = actcell;
+ InsetTabular * inset = const_cast<InsetTabular *>(this);
+ bv->owner()->getDialogs()->updateTabular(inset);
+ oldcell = actcell;
}
}
string const tmp = tabularFeatures[i].feature;
if (tmp == what.substr(0, tmp.length())) {
- //if (!strncmp(tabularFeatures[i].feature.c_str(), what.c_str(),
+ //if (!compare(tabularFeatures[i].feature.c_str(), what.c_str(),
//tabularFeatures[i].feature.length())) {
action = tabularFeatures[i].action;
break;
}
bv->text->SetUndo(bv->buffer(), Undo::FINISH,
#ifndef NEW_INSETS
- 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_
#else
- bv->text->cursor.par()->previous,
- bv->text->cursor.par()->next
+ bv->text->cursor.par()->previous(),
+ bv->text->cursor.par()->next()
#endif
);
}
-LyXText * InsetTabular::getLyXText(BufferView const * bv) const
+LyXText * InsetTabular::getLyXText(BufferView const * bv, bool const recursive) const
{
if (the_locking_inset)
- return the_locking_inset->getLyXText(bv);
- return Inset::getLyXText(bv);
+ return the_locking_inset->getLyXText(bv, recursive);
+ return Inset::getLyXText(bv, recursive);
}
for (; tabularFeatures[i].action != LyXTabular::LAST_ACTION; ++i) {
string const tmp = tabularFeatures[i].feature;
if (tmp == what.substr(0, tmp.length())) {
- //if (!strncmp(tabularFeatures[i].feature.c_str(), what.c_str(),
+ //if (!compare(tabularFeatures[i].feature.c_str(), what.c_str(),
// tabularFeatures[i].feature.length())) {
action = tabularFeatures[i].action;
break;
string const argument = frontStrip(what.substr(tabularFeatures[i].feature.length()));
- int sel_row_start, sel_row_end;
+ int sel_row_start;
+ int sel_row_end;
int dummy;
bool flag = true;
return false;
delete paste_tabular;
- int sel_col_start, sel_col_end;
- int sel_row_start, sel_row_end;
+ int sel_col_start;
+ int sel_col_end;
+ int sel_row_start;
+ int sel_row_end;
sel_col_start = tabular->column_of_cell(sel_cell_start);
sel_col_end = tabular->column_of_cell(sel_cell_end);
if (!hasSelection())
return false;
- int sel_col_start, sel_col_end;
- int sel_row_start, sel_row_end;
+ int sel_col_start;
+ int sel_col_end;
+ int sel_row_start;
+ int sel_row_end;
sel_col_start = tabular->column_of_cell(sel_cell_start);
sel_col_end = tabular->column_of_cell(sel_cell_end);