ParagraphList::iterator end;
getParsInRange(paragraphs(),
- bv()->top_y() - yo_,
- bv()->top_y() - yo_ + bv()->workHeight(),
+ bv()->top_y(),
+ bv()->top_y() + bv()->workHeight(),
pit, end);
lyxerr << "checkInsetHit: x: " << x << " y: " << y << endl;
InsetList::iterator iend = pit->insetlist.end();
for ( ; iit != iend; ++iit) {
InsetBase * inset = iit->inset;
- //lyxerr << "examining inset " << inset
- // << " xy: " << inset->x() << "/" << inset->y()
- // << " x: " << inset->x() << "..." << inset->x() + inset->width()
- // << " y: " << inset->y() - inset->ascent() << "..."
- // << inset->y() + inset->descent()
- // << endl;
- if (x >= inset->x()
- && x <= inset->x() + inset->width()
- && y >= inset->y() - inset->ascent()
- && y <= inset->y() + inset->descent())
- {
+#if 1
+ lyxerr << "examining inset " << inset
+ //<< " xo/yo: " << inset->xo() << "/" << inset->yo()
+ << " xo: " << inset->xo() << "..." << inset->xo() + inset->width()
+ << " yo: " << inset->yo() - inset->ascent() << "..."
+ << inset->yo() + inset->descent() << endl;
+#endif
+ if (inset->covers(x, y - bv()->top_y())) {
lyxerr << "Hit inset: " << inset << endl;
return inset;
}
void LyXText::cursorPrevious()
{
LCursor & cur = bv()->cursor();
- RowList::iterator crit = cursorRow();
+ pos_type cpos = cur.pos();
lyx::paroffset_type cpar = cur.par();
- int x = bv()->cursor().x_target() - xo_;
- int y = bv()->top_y() - yo_;
+ int x = bv()->cursor().x_target();
+ int y = bv()->top_y();
setCursorFromCoordinates(x, y);
- if (cpar == cur.par() && crit == cursorRow()) {
+ if (cpar == cur.par() && cpos == cur.pos()) {
// we have a row which is taller than the workarea. The
// simplest solution is to move to the previous row instead.
cursorUp(true);
void LyXText::cursorNext()
{
- RowList::iterator crit = cursorRow();
- ParagraphList::iterator cpar = cursorPar();
+ LCursor & cur = bv()->cursor();
+ pos_type cpos = cur.pos();
+ lyx::paroffset_type cpar = cur.par();
- int x = bv()->cursor().x_target() - xo_;
- int y = bv()->top_y() + bv()->workHeight() - yo_;
+ int x = cur.x_target();
+ int y = bv()->top_y() + bv()->workHeight();
setCursorFromCoordinates(x, y);
- if (cpar == cursorPar() && crit == cursorRow()) {
+ if (cpar == cur.par() && cpos == cur.pos()) {
// we have a row which is taller than the workarea. The
// simplest solution is to move to the next row instead.
cursorDown(true);
namespace {
-void specialChar(LyXText * lt, BufferView * bv, InsetSpecialChar::Kind kind)
+void specialChar(LyXText * text, BufferView * bv, InsetSpecialChar::Kind kind)
{
bv->update();
InsetSpecialChar * new_inset = new InsetSpecialChar(kind);
- replaceSelection(lt);
+ replaceSelection(text);
if (!bv->insertInset(new_inset))
delete new_inset;
else
DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
{
- //lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
+ lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
+ //lyxerr << "*** LyXText::dispatch: cmd: " << cmd << endl;
BufferView * bv = &cur.bv();
if (!cur.mark())
cur.clearSelection();
finishChange(bv, false);
- if (cursorPar() == firstPar() && cursorRow() == firstRow())
+ if (cur.par() == 0 && cursorRow() == firstRow())
return DispatchResult(false, FINISHED_UP);
cursorPrevious();
break;
if (!cur.mark())
cur.clearSelection();
finishChange(bv, false);
- if (cursorPar() == lastPar() && cursorRow() == lastRow())
+ if (cur.par() == cur.lastpar() && cursorRow() == lastRow())
return DispatchResult(false, FINISHED_DOWN);
cursorNext();
break;
case LFUN_BACKSPACE_SKIP:
// Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
if (!cur.selection()) {
- CursorSlice cur = cursor();
+#warning look here
+ //CursorSlice cur = cursor();
backspace();
- anchor() = cur;
+ //anchor() = cur;
} else {
cutSelection(true, false);
}
// When at the beginning of a paragraph, remove
// indentation and add a "defskip" at the top.
// Otherwise, do the same as LFUN_BREAKPARAGRAPH.
- CursorSlice cur = cursor();
+#warning look here
+// CursorSlice cur = cursor();
replaceSelection(bv->getLyXText());
if (cur.pos() == 0) {
- ParagraphParameters & params = getPar(cur)->params();
+ ParagraphParameters & params = getPar(cur.current())->params();
setParagraph(
params.spacing(),
params.align(),
breakParagraph(bv->buffer()->paragraphs(), 0);
}
bv->update();
- anchor() = cur;
+// anchor() = cur;
bv->switchKeyMap();
bv->owner()->view_state_changed();
break;
break;
case LFUN_PASTE:
- cmd.message(_("Paste"));
+ cur.message(_("Paste"));
replaceSelection(bv->getLyXText());
#warning FIXME Check if the arg is in the domain of available selections.
if (isStrUnsignedInt(cmd.argument))
case LFUN_CUT:
cutSelection(true, true);
- cmd.message(_("Cut"));
+ cur.message(_("Cut"));
bv->update();
break;
case LFUN_COPY:
copySelection();
- cmd.message(_("Copy"));
+ cur.message(_("Copy"));
break;
case LFUN_BEGINNINGBUFSEL:
break;
case LFUN_GETXY:
- cmd.message(tostr(cursorX()) + ' ' + tostr(cursorY()));
+ cur.message(tostr(cursorX(cur.current())) + ' '
+ + tostr(cursorY(cur.current())));
break;
case LFUN_SETXY: {
case LFUN_GETFONT:
if (current_font.shape() == LyXFont::ITALIC_SHAPE)
- cmd.message("E");
+ cur.message("E");
else if (current_font.shape() == LyXFont::SMALLCAPS_SHAPE)
- cmd.message("N");
+ cur.message("N");
else
- cmd.message("0");
+ cur.message("0");
break;
case LFUN_GETLAYOUT:
- cmd.message(cursorPar()->layout()->name());
+ cur.message(cursorPar()->layout()->name());
break;
case LFUN_LAYOUT: {
// function list/array with information about what
// functions needs arguments and their type.
if (cmd.argument.empty()) {
- cmd.errorMessage(_("LyX function 'layout' needs an argument."));
+ cur.errorMessage(_("LyX function 'layout' needs an argument."));
break;
}
}
if (!hasLayout) {
- cmd.errorMessage(string(N_("Layout ")) + cmd.argument +
+ cur.errorMessage(string(N_("Layout ")) + cmd.argument +
N_(" not known"));
break;
}
break;
case LFUN_MOUSE_MOTION: {
+#if 0
// Only use motion with button 1
//if (ev.button() != mouse_button::button1)
// return false;
+ // don't set anchor_
+ bv->cursor().cursor_ = cur.cursor_;
if (!bv->buffer())
break;
cursorUp(true);
}
cur.setSelection();
+#endif
break;
}
break;
}
- setCursorFromCoordinates(cmd.x, cmd.y);
+ setCursorFromCoordinates(cur.current(), cmd.x, cmd.y);
cur.resetAnchor();
finishUndo();
- cur.x_target(cursorX() + xo_);
+ cur.x_target() = cursorX(cur.current());
+
+ // set cursor and anchor to this position
+ bv->cursor() = cur;
if (bv->fitCursor())
selection_possible = false;
break;
case LFUN_FINISHED_LEFT:
- lyxerr << "swallow LFUN_FINISHED_LEFT" << endl;
+ lyxerr << "handle LFUN_FINISHED_LEFT" << endl;
+ cur.pop(cur.currentDepth());
+ cur.bv().cursor() = cur;
if (rtl())
cursorLeft(true);
break;
case LFUN_FINISHED_RIGHT:
- lyxerr << "swallow LFUN_FINISHED_RIGHT" << endl;
+ lyxerr << "handle LFUN_FINISHED_RIGHT" << endl;
+ cur.pop(cur.currentDepth());
+ cur.bv().cursor() = cur;
if (!rtl())
cursorRight(true);
break;
case LFUN_FINISHED_UP:
- lyxerr << "swallow LFUN_FINISHED_UP" << endl;
+ lyxerr << "handle LFUN_FINISHED_UP" << endl;
+ cur.pop(cur.currentDepth());
+ cur.bv().cursor() = cur;
cursorUp(true);
break;
case LFUN_FINISHED_DOWN:
- lyxerr << "swallow LFUN_FINISHED_DOWN" << endl;
+ lyxerr << "handle LFUN_FINISHED_DOWN" << endl;
+ cur.pop(cur.currentDepth());
+ cur.bv().cursor() = cur;
cursorDown(true);
break;