Again, mostly shifting stuff around. Some function to anon in the only place they are used, rename the x/y version of edit to editXY, remove a cursorPar() or two, make some #if 0'd chunk of code in insettabular compilable.
Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson or B. Franklin or both...)
Index: BufferView_pimpl.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.509 diff -u -p -r1.509 BufferView_pimpl.C --- BufferView_pimpl.C 13 Feb 2004 11:05:21 -0000 1.509 +++ BufferView_pimpl.C 13 Feb 2004 12:59:53 -0000 @@ -474,13 +474,14 @@ void BufferView::Pimpl::scrollDocView(in int const first = top_y() + height; int const last = top_y() + workarea().workHeight() - height; + bv_->cursor().reset(); LyXText * text = bv_->text(); CursorSlice & cur = bv_->cursor().cursor_.front(); int y = text->cursorY(cur); if (y < first) - text->setCursorFromCoordinates(cur, 0, first); + text->setCursorFromCoordinates(bv_->cursor(), 0, first); else if (y > last) - text->setCursorFromCoordinates(cur, 0, last); + text->setCursorFromCoordinates(bv_->cursor(), 0, last); owner_->updateLayoutChoice(); } @@ -922,18 +923,12 @@ bool BufferView::Pimpl::workAreaDispatch // surrounding LyXText will handle this event. // built temporary path to inset - LyXText * text = bv_->text(); - InsetBase * const inset_hit = text->checkInsetHit(cmd.x, cmd.y); - if (inset_hit) - inset_hit->edit(cur, cmd.x, cmd.y); - else - text->setCursorFromCoordinates(cur.current(), cmd.x, cmd.y); + InsetBase * inset = bv_->text()->editXY(cur, cmd.x, cmd.y); + lyxerr << "hit inset at tip: " << inset << endl; lyxerr << "created temp cursor: " << cur << endl; // Try to dispatch to an non-editable inset near this position DispatchResult res; - InsetBase * inset = cur.nextInset(); - lyxerr << "next inset: " << inset << endl; if (inset) res = inset->dispatch(cur, cmd); @@ -1027,7 +1022,7 @@ bool BufferView::Pimpl::dispatch(FuncReq case LFUN_INSERT_LABEL: { // Try and generate a valid label string const contents = cmd.argument.empty() ? - getPossibleLabel(*bv_) : cmd.argument; + cur.getPossibleLabel() : cmd.argument; InsetCommandParams icp("label", contents); string data = InsetCommandMailer::params2string("label", icp); owner_->getDialogs().show("label", data, 0); Index: cursor.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.C,v retrieving revision 1.58 diff -u -p -r1.58 cursor.C --- cursor.C 13 Feb 2004 11:05:22 -0000 1.58 +++ cursor.C 13 Feb 2004 12:59:53 -0000 @@ -1810,13 +1810,6 @@ void LCursor::handleFont(string const & } -void LCursor::releaseMathCursor() -{ - if (inMathed()) - formula()->insetUnlock(bv()); -} - - bool LCursor::inMathed() const { return formula(); @@ -1936,4 +1929,10 @@ void LCursor::replaceWord(string const & void LCursor::update() { bv().update(); +} + + +string LCursor::getPossibleLabel() +{ + return inMathed() ? "eq:" : text()->getPossibleLabel(*this); } Index: cursor.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.h,v retrieving revision 1.35 diff -u -p -r1.35 cursor.h --- cursor.h 13 Feb 2004 11:05:22 -0000 1.35 +++ cursor.h 13 Feb 2004 12:59:53 -0000 @@ -426,7 +426,6 @@ public: /// split font inset etc void handleFont(std::string const & font); - void releaseMathCursor(); /// are we in mathed? bool inMathed() const; /// are we in texted? @@ -436,6 +435,8 @@ public: void message(std::string const & msg) const; /// display an error message void errorMessage(std::string const & msg) const; + /// + std::string getPossibleLabel(); private: /// moves cursor index one cell to the left Index: cursor_slice.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor_slice.h,v retrieving revision 1.10 diff -u -p -r1.10 cursor_slice.h --- cursor_slice.h 30 Jan 2004 11:40:57 -0000 1.10 +++ cursor_slice.h 13 Feb 2004 12:59:53 -0000 @@ -120,7 +120,7 @@ public: /// friend std::ostream & operator<<(std::ostream &, CursorSlice const &); public: - /// pointer to an inset + /// pointer to 'owning' inset InsetBase * inset_; /// cell index of a position in this inset idx_type idx_; Index: lyx_cb.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_cb.C,v retrieving revision 1.237 diff -u -p -r1.237 lyx_cb.C --- lyx_cb.C 13 Feb 2004 07:30:53 -0000 1.237 +++ lyx_cb.C 13 Feb 2004 12:59:53 -0000 @@ -432,49 +432,6 @@ string getContentsOfAsciiFile(BufferView } -string const getPossibleLabel(BufferView const & bv) -{ - ParagraphList::iterator pit = bv.getLyXText()->cursorPar(); - ParagraphList & plist = bv.getLyXText()->paragraphs(); - - LyXLayout_ptr layout = pit->layout(); - - if (layout->latextype == LATEX_PARAGRAPH && pit != plist.begin()) { - ParagraphList::iterator pit2 = boost::prior(pit); - - LyXLayout_ptr const & layout2 = pit2->layout(); - - if (layout2->latextype != LATEX_PARAGRAPH) { - pit = pit2; - layout = layout2; - } - } - - string text = layout->latexname().substr(0, 3); - if (layout->latexname() == "theorem") - text = "thm"; // Create a correct prefix for prettyref - - text += ':'; - if (layout->latextype == LATEX_PARAGRAPH || - lyxrc.label_init_length < 0) - text.erase(); - - string par_text = pit->asString(*bv.buffer(), false); - for (int i = 0; i < lyxrc.label_init_length; ++i) { - if (par_text.empty()) - break; - string head; - par_text = split(par_text, head, ' '); - // Is it legal to use spaces in labels ? - if (i > 0) - text += '-'; - text += head; - } - - return text; -} - - // This function runs "configure" and then rereads lyx.defaults to // reconfigure the automatic settings. void Reconfigure(BufferView * bv) Index: lyx_cb.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_cb.h,v retrieving revision 1.34 diff -u -p -r1.34 lyx_cb.h --- lyx_cb.h 6 Oct 2003 15:42:20 -0000 1.34 +++ lyx_cb.h 13 Feb 2004 12:59:53 -0000 @@ -35,7 +35,5 @@ void InsertAsciiFile(BufferView * bv, st /// std::string getContentsOfAsciiFile(BufferView * bv, std::string const & f, bool asParagraph); /// -std::string const getPossibleLabel(BufferView const & bv); -/// void Reconfigure(BufferView * bv); #endif Index: lyxrow_funcs.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxrow_funcs.C,v retrieving revision 1.26 diff -u -p -r1.26 lyxrow_funcs.C --- lyxrow_funcs.C 13 Nov 2003 13:43:38 -0000 1.26 +++ lyxrow_funcs.C 13 Feb 2004 12:59:53 -0000 @@ -19,77 +19,6 @@ using lyx::pos_type; -using std::max; -using std::min; -using std::endl; - - -int numberOfSeparators(Paragraph const & par, Row const & row) -{ - pos_type const first = max(row.pos(), par.beginOfBody()); - pos_type const last = row.endpos() - 1; - int n = 0; - for (pos_type p = first; p < last; ++p) { - if (par.isSeparator(p)) - ++n; - } - - return n; -} - - -// This is called _once_ from LyXText and should at least be moved into -// an anonymous namespace there. (Lgb) -int numberOfHfills(Paragraph const & par, Row const & row) -{ - pos_type const last = row.endpos() - 1; - pos_type first = row.pos(); - - // hfill *DO* count at the beginning of paragraphs! - if (first) { - while (first < last && par.isHfill(first)) - ++first; - } - - first = max(first, par.beginOfBody()); - - int n = 0; - - // last, because the end is ignored! - for (pos_type p = first; p < last; ++p) { - if (par.isHfill(p)) - ++n; - } - - return n; -} - - -// This is called _once_ from LyXText and should at least be moved into -// an anonymous namespace there. (Lgb) -int numberOfLabelHfills(Paragraph const & par, Row const & row) -{ - pos_type last = row.endpos() - 1; - pos_type first = row.pos(); - - // hfill *DO* count at the beginning of paragraphs! - if (first) { - while (first < last && par.isHfill(first)) - ++first; - } - - last = min(last, par.beginOfBody()); - int n = 0; - - // last, because the end is ignored - for (pos_type p = first; p < last; ++p) { - if (par.isHfill(p)) - ++n; - } - - return n; -} - bool hfillExpansion(Paragraph const & par, Row const & row, pos_type pos) { Index: lyxrow_funcs.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxrow_funcs.h,v retrieving revision 1.11 diff -u -p -r1.11 lyxrow_funcs.h --- lyxrow_funcs.h 27 Oct 2003 11:44:07 -0000 1.11 +++ lyxrow_funcs.h 13 Feb 2004 12:59:53 -0000 @@ -18,12 +18,6 @@ class Paragraph; class Row; -int numberOfSeparators(Paragraph const & par, Row const & row); - -int numberOfHfills(Paragraph const & par, Row const & row); - -int numberOfLabelHfills(Paragraph const & par, Row const & row); - bool hfillExpansion(Paragraph const & par, Row const & row, lyx::pos_type pos); Index: lyxtext.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v retrieving revision 1.291 diff -u -p -r1.291 lyxtext.h --- lyxtext.h 13 Feb 2004 11:05:22 -0000 1.291 +++ lyxtext.h 13 Feb 2004 12:59:53 -0000 @@ -187,9 +187,9 @@ public: /// void recUndo(par_type first) const; /// - void setCursorFromCoordinates(CursorSlice &, int x, int y); + void setCursorFromCoordinates(LCursor & cur, int x, int y); /// - void edit(LCursor & cur, int x, int y); + InsetBase * editXY(LCursor & cur, int x, int y); /// void cursorUp(LCursor & cur, bool selecting = false); /// @@ -339,7 +339,9 @@ public: bool isFirstRow(ParagraphList::iterator pit, Row const & row) const; /// - double spacing(Paragraph const &) const; + double spacing(Paragraph const & par) const; + /// make a suggestion for a label + std::string getPossibleLabel(LCursor & cur) const; /// DispatchResult moveRight(LCursor & cur); @@ -431,7 +433,9 @@ private: void fixCursorAfterDelete(CursorSlice & cur, CursorSlice const & where); /// delete double space (false) or empty paragraphs (true) around old_cursor - bool deleteEmptyParagraphMechanism(CursorSlice const & old_cursor); + bool deleteEmptyParagraphMechanism( + CursorSlice & cur, + CursorSlice const & old_cursor); /// void setCounter(Buffer const &, ParagraphList::iterator pit); Index: text.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v retrieving revision 1.536 diff -u -p -r1.536 text.C --- text.C 13 Feb 2004 11:05:22 -0000 1.536 +++ text.C 13 Feb 2004 12:59:53 -0000 @@ -60,11 +60,13 @@ using lyx::word_location; using lyx::support::bformat; using lyx::support::contains; using lyx::support::lowercase; +using lyx::support::split; using lyx::support::uppercase; using std::advance; using std::distance; using std::max; +using std::min; using std::endl; using std::string; @@ -79,6 +81,19 @@ extern int const RIGHT_MARGIN = 10; namespace { +int numberOfSeparators(Paragraph const & par, Row const & row) +{ + pos_type const first = max(row.pos(), par.beginOfBody()); + pos_type const last = row.endpos() - 1; + int n = 0; + for (pos_type p = first; p < last; ++p) { + if (par.isSeparator(p)) + ++n; + } + return n; +} + + unsigned int maxParagraphWidth(ParagraphList const & plist) { unsigned int width = 0; @@ -89,6 +104,49 @@ unsigned int maxParagraphWidth(Paragraph return width; } + +int numberOfLabelHfills(Paragraph const & par, Row const & row) +{ + pos_type last = row.endpos() - 1; + pos_type first = row.pos(); + + // hfill *DO* count at the beginning of paragraphs! + if (first) { + while (first < last && par.isHfill(first)) + ++first; + } + + last = min(last, par.beginOfBody()); + int n = 0; + for (pos_type p = first; p < last; ++p) { + if (par.isHfill(p)) + ++n; + } + return n; +} + + +int numberOfHfills(Paragraph const & par, Row const & row) +{ + pos_type const last = row.endpos() - 1; + pos_type first = row.pos(); + + // hfill *DO* count at the beginning of paragraphs! + if (first) { + while (first < last && par.isHfill(first)) + ++first; + } + + first = max(first, par.beginOfBody()); + + int n = 0; + for (pos_type p = first; p < last; ++p) { + if (par.isHfill(p)) + ++n; + } + return n; +} + } // namespace anon @@ -1954,4 +2012,47 @@ string LyXText::currentState(LCursor & c os << -1; #endif return os.str(); +} + + +string LyXText::getPossibleLabel(LCursor & cur) const +{ + ParagraphList & plist = paragraphs(); + ParagraphList::iterator pit = getPar(cur.par()); + + LyXLayout_ptr layout = pit->layout(); + + if (layout->latextype == LATEX_PARAGRAPH && pit != plist.begin()) { + ParagraphList::iterator pit2 = boost::prior(pit); + + LyXLayout_ptr const & layout2 = pit2->layout(); + + if (layout2->latextype != LATEX_PARAGRAPH) { + pit = pit2; + layout = layout2; + } + } + + string text = layout->latexname().substr(0, 3); + if (layout->latexname() == "theorem") + text = "thm"; // Create a correct prefix for prettyref + + text += ':'; + if (layout->latextype == LATEX_PARAGRAPH || + lyxrc.label_init_length < 0) + text.erase(); + + string par_text = pit->asString(*cur.bv().buffer(), false); + for (int i = 0; i < lyxrc.label_init_length; ++i) { + if (par_text.empty()) + break; + string head; + par_text = split(par_text, head, ' '); + // Is it legal to use spaces in labels ? + if (i > 0) + text += '-'; + text += head; + } + + return text; } Index: text2.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v retrieving revision 1.545 diff -u -p -r1.545 text2.C --- text2.C 13 Feb 2004 11:05:24 -0000 1.545 +++ text2.C 13 Feb 2004 12:59:53 -0000 @@ -292,7 +292,7 @@ void LyXText::setLayout(LCursor & cur, s bv()->owner()->dispatch(FuncRequest(LFUN_CUT)); InsetBase * inset = new InsetEnvironment(params, layout); insertInset(cur, inset); - //inset->edit(bv()); + //inset->edit(cur, true); //bv()->owner()->dispatch(FuncRequest(LFUN_PASTE)); return; } @@ -1089,7 +1089,7 @@ bool LyXText::setCursor(LCursor & cur, p { CursorSlice old_cursor = cur.current(); setCursorIntern(cur, par, pos, setfont, boundary); - return deleteEmptyParagraphMechanism(old_cursor); + return deleteEmptyParagraphMechanism(cur.current(), old_cursor); } @@ -1298,23 +1298,24 @@ pos_type LyXText::getColumnNearX(Paragra // x,y are coordinates relative to this LyXText -void LyXText::setCursorFromCoordinates(CursorSlice & cur, int x, int y) +void LyXText::setCursorFromCoordinates(LCursor & cur, int x, int y) { - CursorSlice old_cursor = cur; + CursorSlice old_cursor = cur.current(); ParagraphList::iterator pit; Row const & row = *getRowNearY(y, pit); + lyxerr << "hit row at: " << row.pos() << endl; bool bound = false; int xx = x + xo_; // getRowNearX get absolute x coords pos_type const pos = row.pos() + getColumnNearX(pit, row, xx, bound); cur.par() = parOffset(pit); cur.pos() = pos; cur.boundary() = bound; - deleteEmptyParagraphMechanism(old_cursor); + deleteEmptyParagraphMechanism(cur.current(), old_cursor); } // x,y are absolute screen coordinates -void LyXText::edit(LCursor & cur, int x, int y) +InsetBase * LyXText::editXY(LCursor & cur, int x, int y) { ParagraphList::iterator pit; Row const & row = *getRowNearY(y - yo_, pit); @@ -1328,17 +1329,18 @@ void LyXText::edit(LCursor & cur, int x, // try to descend into nested insets InsetBase * inset = checkInsetHit(x, y); - if (inset) { - // This should be just before or just behind the - // cursor position set above. - BOOST_ASSERT((pos != 0 && inset == pit->getInset(pos - 1)) - || inset == pit->getInset(pos)); - // Make sure the cursor points to the position before - // this inset. - if (inset == pit->getInset(pos - 1)) - --cur.pos(); - inset->edit(cur, x, y); - } + if (!inset) + return 0; + + // This should be just before or just behind the + // cursor position set above. + BOOST_ASSERT((pos != 0 && inset == pit->getInset(pos - 1)) + || inset == pit->getInset(pos)); + // Make sure the cursor points to the position before + // this inset. + if (inset == pit->getInset(pos - 1)) + --cur.pos(); + return inset->editXY(cur, x, y); } @@ -1433,7 +1435,7 @@ bool LyXText::cursorLeft(LCursor & cur, if (cur.par() != 0) { // steps into the paragraph above - setCursor(cur, cur.par() - 1, boost::prior(cursorPar())->size()); + setCursor(cur, cur.par() - 1, getPar(cur.par() - 1)->size()); return true; } @@ -1470,12 +1472,12 @@ void LyXText::cursorUp(LCursor & cur, bo Row const & row = cur.textRow(); int x = cur.x_target(); int y = cursorY(cur.current()) - row.baseline() - 1; - setCursorFromCoordinates(cur.current(), x - xo_, y - yo_); + setCursorFromCoordinates(cur, x - xo_, y - yo_); if (!selecting) { InsetBase * inset_hit = checkInsetHit(cur.x_target(), y); if (inset_hit && isHighlyEditableInset(inset_hit)) - inset_hit->edit(cur, cur.x_target(), y); + inset_hit->editXY(cur, cur.x_target(), y); } } @@ -1485,12 +1487,12 @@ void LyXText::cursorDown(LCursor & cur, Row const & row = cur.textRow(); int x = cur.x_target(); int y = cursorY(cur.current()) - row.baseline() + row.height() + 1; - setCursorFromCoordinates(cur.current(), x - xo_, y - yo_); + setCursorFromCoordinates(cur, x - xo_, y - yo_); if (!selecting) { InsetBase * inset_hit = checkInsetHit(cur.x_target(), y); if (inset_hit && isHighlyEditableInset(inset_hit)) - inset_hit->edit(cur, cur.x_target(), y); + inset_hit->editXY(cur, cur.x_target(), y); } } @@ -1517,13 +1519,12 @@ void LyXText::cursorDownParagraph(LCurso // position. Called by deleteEmptyParagraphMechanism void LyXText::fixCursorAfterDelete(CursorSlice & cur, CursorSlice const & where) { - // if cursor is not in the paragraph where the delete occured, - // do nothing + // do notheing if cursor is not in the paragraph where the + // deletion occured, if (cur.par() != where.par()) return; - // if cursor position is after the place where the delete occured, - // update it + // if cursor position is after the deletion place update it if (cur.pos() > where.pos()) --cur.pos(); @@ -1534,22 +1535,19 @@ void LyXText::fixCursorAfterDelete(Curso } -bool LyXText::deleteEmptyParagraphMechanism(CursorSlice const & old_cursor) +bool LyXText::deleteEmptyParagraphMechanism(CursorSlice & cur, + CursorSlice const & old_cursor) { #warning Disabled as it crashes after the cursor data shift... (Andre) return false; // Would be wrong to delete anything if we have a selection. - if (bv()->cursor().selection()) - return false; - - // Don't do anything if the cursor is invalid - if (old_cursor.par() == -1) - return false; + //if (cur.selection()) + // return false; #if 0 // We allow all kinds of "mumbo-jumbo" when freespacing. - ParagraphList::iterator const old_pit = getPar(old_cursor); + ParagraphList::iterator const old_pit = getPar(old_cursor.par()); if (old_pit->isFreeSpacing()) return false; @@ -1577,8 +1575,7 @@ bool LyXText::deleteEmptyParagraphMechan // MISSING // If the pos around the old_cursor were spaces, delete one of them. - if (old_cursor.par() != cursor().par() - || old_cursor.pos() != cursor().pos()) { + if (old_cursor.par() != cur.par() || old_cursor.pos() != cur.pos()) { // Only if the cursor has really moved if (old_cursor.pos() > 0 @@ -1612,7 +1609,7 @@ bool LyXText::deleteEmptyParagraphMechan return false; // only do our magic if we changed paragraph - if (old_cursor.par() == cursor().par()) + if (old_cursor.par() == cur.par()) return false; // record if we have deleted a paragraph @@ -1640,12 +1637,10 @@ bool LyXText::deleteEmptyParagraphMechan recUndo(parOffset(old_pit), parOffset(endpit) - 1); cursor() = tmpcursor; - // cache cursor pit - ParagraphList::iterator tmppit = cursorPar(); // delete old par paragraphs().erase(old_pit); // update cursor par offset - cursor().par(parOffset(tmppit)); + --cur.par(); redoParagraph(); if (selection_position_was_oldcursor_position) { Index: text3.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v retrieving revision 1.223 diff -u -p -r1.223 text3.C --- text3.C 13 Feb 2004 11:05:25 -0000 1.223 +++ text3.C 13 Feb 2004 12:59:53 -0000 @@ -293,7 +293,7 @@ void LyXText::cursorPrevious(LCursor & c int x = cur.x_target(); int y = bv()->top_y(); - setCursorFromCoordinates(cur.current(), x, y); + setCursorFromCoordinates(cur, x, y); if (cpar == cur.par() && cpos == cur.pos()) { // we have a row which is taller than the workarea. The @@ -313,7 +313,7 @@ void LyXText::cursorNext(LCursor & cur) int x = cur.x_target(); int y = bv()->top_y() + bv()->workHeight(); - setCursorFromCoordinates(cur.current(), x, y); + setCursorFromCoordinates(cur, x, y); if (cpar == cur.par() && cpos == cur.pos()) { // we have a row which is taller than the workarea. The @@ -910,7 +910,7 @@ DispatchResult LyXText::dispatch(LCursor lyxerr << "SETXY: Could not parse coordinates in '" << cmd.argument << std::endl; else - setCursorFromCoordinates(cur.current(), x, y); + setCursorFromCoordinates(cur, x, y); break; } @@ -1092,7 +1092,7 @@ DispatchResult LyXText::dispatch(LCursor break; } CursorSlice old = cur.current(); - setCursorFromCoordinates(cur.current(), cmd.x, cmd.y); + setCursorFromCoordinates(cur, cmd.x, cmd.y); // This is to allow jumping over large insets // FIXME: shouldn't be top-text-specific @@ -1147,8 +1147,7 @@ DispatchResult LyXText::dispatch(LCursor // Clear the selection cur.clearSelection(); - setCursorFromCoordinates(cur.current(), cmd.x - xo_, - cmd.y - yo_); + setCursorFromCoordinates(cur, cmd.x - xo_, cmd.y - yo_); cur.resetAnchor(); finishUndo(); cur.x_target() = cursorX(cur.current()); Index: insets/insetbase.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbase.C,v retrieving revision 1.19 diff -u -p -r1.19 insetbase.C --- insets/insetbase.C 2 Feb 2004 17:32:56 -0000 1.19 +++ insets/insetbase.C 13 Feb 2004 12:59:53 -0000 @@ -35,6 +35,7 @@ DispatchResult InsetBase::dispatch(LCurs DispatchResult InsetBase::priv_dispatch(LCursor &, FuncRequest const &) { + lyxerr << "InsetBase::priv_dispatch" << std::endl; return DispatchResult(false); } @@ -45,10 +46,10 @@ void InsetBase::edit(LCursor &, bool) } -void InsetBase::edit(LCursor & cur, int, int) +InsetBase * InsetBase::editXY(LCursor & cur, int, int) { lyxerr << "InsetBase: edit xy" << std::endl; - edit(cur, true); + return this; } Index: insets/insetbase.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbase.h,v retrieving revision 1.27 diff -u -p -r1.27 insetbase.h --- insets/insetbase.h 2 Feb 2004 17:32:56 -0000 1.27 +++ insets/insetbase.h 13 Feb 2004 12:59:53 -0000 @@ -73,7 +73,7 @@ public: /// cursor enters virtual void edit(LCursor & cur, bool left); /// cursor enters - virtual void edit(LCursor & cur, int x, int y); + virtual InsetBase * editXY(LCursor & cur, int x, int y); /// compute the size of the object returned in dim virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0; Index: insets/insetcollapsable.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.C,v retrieving revision 1.237 diff -u -p -r1.237 insetcollapsable.C --- insets/insetcollapsable.C 13 Feb 2004 11:05:26 -0000 1.237 +++ insets/insetcollapsable.C 13 Feb 2004 12:59:53 -0000 @@ -299,7 +299,7 @@ void InsetCollapsable::edit(LCursor & cu } -void InsetCollapsable::edit(LCursor & cur, int x, int y) +InsetBase * InsetCollapsable::editXY(LCursor & cur, int x, int y) { cur.push(this); //lyxerr << "InsetCollapsable: edit xy" << endl; @@ -309,14 +309,14 @@ void InsetCollapsable::edit(LCursor & cu #warning look here //we are not calling edit(x,y) because there are no coordinates in the //inset yet. I personally think it's ok. (ab) - } else { -// if (y <= yo() + inset.ascent() + button_dim.y2) -// y = yo(); -// else -// y += inset.ascent() - height_collapsed(); - - inset.edit(cur, x, y); + return this; } + +//if (y <= yo() + inset.ascent() + button_dim.y2) +// y = yo(); +//else +// y += inset.ascent() - height_collapsed(); + return inset.editXY(cur, x, y); } Index: insets/insetcollapsable.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.h,v retrieving revision 1.166 diff -u -p -r1.166 insetcollapsable.h --- insets/insetcollapsable.h 13 Feb 2004 11:05:26 -0000 1.166 +++ insets/insetcollapsable.h 13 Feb 2004 12:59:53 -0000 @@ -137,7 +137,7 @@ protected: /// void edit(LCursor & cur, bool left); /// - void edit(LCursor & cur, int x, int y); + InsetBase * editXY(LCursor & cur, int x, int y); private: /// Index: insets/insetexternal.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetexternal.h,v retrieving revision 1.71 diff -u -p -r1.71 insetexternal.h --- insets/insetexternal.h 20 Jan 2004 14:25:14 -0000 1.71 +++ insets/insetexternal.h 13 Feb 2004 12:59:53 -0000 @@ -142,11 +142,12 @@ public: /// InsetExternalParams const & params() const; + /// void setParams(InsetExternalParams const &, Buffer const &); /// void addPreview(lyx::graphics::PreviewLoader &) const; /// - void edit(LCursor & cur, bool); + void edit(LCursor & cur, bool left); protected: /// Index: insets/insetgraphics.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetgraphics.h,v retrieving revision 1.93 diff -u -p -r1.93 insetgraphics.h --- insets/insetgraphics.h 20 Jan 2004 14:25:14 -0000 1.93 +++ insets/insetgraphics.h 13 Feb 2004 12:59:53 -0000 @@ -78,12 +78,10 @@ public: /// void draw(PainterInfo & pi, int x, int y) const; /// - void edit(LCursor & cur, bool); + void edit(LCursor & cur, bool left); protected: /// - virtual - DispatchResult - priv_dispatch(LCursor & cur, FuncRequest const & cmd); + DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd); private: /// friend class InsetGraphicsMailer; Index: insets/insettabular.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v retrieving revision 1.402 diff -u -p -r1.402 insettabular.C --- insets/insettabular.C 13 Feb 2004 11:05:28 -0000 1.402 +++ insets/insettabular.C 13 Feb 2004 12:59:53 -0000 @@ -461,19 +461,18 @@ void InsetTabular::edit(LCursor & cur, b } -void InsetTabular::edit(LCursor & cur, int x, int y) +InsetBase * InsetTabular::editXY(LCursor & cur, int x, int y) { lyxerr << "InsetTabular::edit: " << this << " first cell " << &tabular.cell_info[0][0].inset << endl; - - finishUndo(); - setPos(cur, x, y); clearSelection(); - finishUndo(); - //int xx = cursorx_ - xo_ + tabular.getBeginningOfTextInCell(actcell); cur.push(this); + setPos(cur, x, y); + //int xx = cursorx_ - xo_ + tabular.getBeginningOfTextInCell(actcell); //if (x > xx) // activateCellInset(bv, cell, x - xx, y - cursory_); +#warning wrong! + return this; } @@ -977,7 +976,7 @@ void InsetTabular::setPos(LCursor & cur, //lyxerr << "# InsetTabular::setPos() cursor: " << cur << endl; int const cell = getCell(x + xo_, y + yo_); InsetText const & inset = tabular.getCellInset(cell); - inset.text_.setCursorFromCoordinates(cur.current(), x, y); + inset.text_.setCursorFromCoordinates(cur, x, y); cursory_ = 0; int actcell = 0; int actrow = 0; @@ -1023,7 +1022,7 @@ int InsetTabular::getCellXPos(int cell) void InsetTabular::resetPos(LCursor & cur) const { -#if 0 +#if 1 #ifdef WITH_WARNINGS #warning This should be fixed in the right manner (20011128 Jug) #endif @@ -1033,7 +1032,7 @@ void InsetTabular::resetPos(LCursor & cu BufferView & bv = cur.bv(); int cell = 0; - int actcell = cur.cell(); + int actcell = cur.idx(); int actcol = tabular.column_of_cell(actcell); int actrow = 0; cursory_ = 0; @@ -1054,24 +1053,24 @@ void InsetTabular::resetPos(LCursor & cu cursorx_ = new_x; // cursor.x(getCellXPos(actcell) + offset); if (actcol < tabular.columns() - 1 && scroll(false) && - tabular.getWidthOfTabular() < bv->workWidth()-20) + tabular.getWidthOfTabular() < bv.workWidth()-20) { scroll(bv, 0.0F); updateLocal(cur); } else if (cursorx_ - offset > 20 && cursorx_ - offset + tabular.getWidthOfColumn(actcell) > bv.workWidth() - 20) { - scroll(&bv, - tabular.getWidthOfColumn(actcell) - 20); + scroll(bv, - tabular.getWidthOfColumn(actcell) - 20); updateLocal(cur); } else if (cursorx_ - offset < 20) { - scroll(&bv, 20 - cursorx_ + offset); + scroll(bv, 20 - cursorx_ + offset); updateLocal(cur); } else if (scroll() && xo_ > 20 && - xo_ + tabular.getWidthOfTabular() > bv->workWidth() - 20) { - scroll(&bv, old_x - cursorx_); + xo_ + tabular.getWidthOfTabular() > bv.workWidth() - 20) { + scroll(bv, old_x - cursorx_); updateLocal(cur); } - InsetTabularMailer(*this).updateDialog(bv); + InsetTabularMailer(*this).updateDialog(&bv); in_reset_pos = 0; #endif } @@ -1595,16 +1594,16 @@ void InsetTabular::tabularFeatures(LCurs void InsetTabular::activateCellInset(LCursor & cur, int cell, int x, int y) { - tabular.getCellInset(cell).edit(cur, x, y); cur.idx() = cell; + tabular.getCellInset(cell).editXY(cur, x, y); updateLocal(cur); } void InsetTabular::activateCellInset(LCursor & cur, int cell, bool behind) { - tabular.getCellInset(cell).edit(cur, behind); cur.idx() = cell; + tabular.getCellInset(cell).edit(cur, behind); updateLocal(cur); } Index: insets/insettabular.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.h,v retrieving revision 1.183 diff -u -p -r1.183 insettabular.h --- insets/insettabular.h 13 Feb 2004 11:05:29 -0000 1.183 +++ insets/insettabular.h 13 Feb 2004 12:59:53 -0000 @@ -147,9 +147,9 @@ public: /// set the owning buffer void buffer(Buffer * buf); /// lock cell with given index - void edit(LCursor & cur, bool); + void edit(LCursor & cur, bool left); /// - void edit(LCursor & cur, int, int); + InsetBase * editXY(LCursor & cur, int x, int y); /// can we go further down on mouse click? bool descendable() const { return true; } @@ -160,9 +160,7 @@ public: protected: /// - virtual - DispatchResult - priv_dispatch(LCursor & cur, FuncRequest const & cmd); + DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd); private: /// void lfunMousePress(LCursor & cur, FuncRequest const & cmd); Index: insets/insettext.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v retrieving revision 1.578 diff -u -p -r1.578 insettext.C --- insets/insettext.C 13 Feb 2004 07:30:59 -0000 1.578 +++ insets/insettext.C 13 Feb 2004 12:59:53 -0000 @@ -298,11 +298,11 @@ void InsetText::edit(LCursor & cur, bool } -void InsetText::edit(LCursor & cur, int x, int y) +InsetBase * InsetText::editXY(LCursor & cur, int x, int y) { lyxerr << "InsetText::edit xy" << endl; old_par = -1; - text_.edit(cur, x, y); + return text_.editXY(cur, x, y); //sanitizeEmptyText(cur.bv()); //updateLocal(cur); //dispatch(cur, FuncRequest(LFUN_PARAGRAPH_UPDATE)); Index: insets/insettext.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.h,v retrieving revision 1.247 diff -u -p -r1.247 insettext.h --- insets/insettext.h 6 Feb 2004 16:14:06 -0000 1.247 +++ insets/insettext.h 13 Feb 2004 12:59:53 -0000 @@ -148,7 +148,7 @@ public: /// void edit(LCursor & cur, bool left); /// - void edit(LCursor & cur, int x, int y); + InsetBase * editXY(LCursor & cur, int x, int y); /// int numParagraphs() const { return 1; } Index: mathed/math_hullinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_hullinset.C,v retrieving revision 1.117 diff -u -p -r1.117 math_hullinset.C --- mathed/math_hullinset.C 11 Feb 2004 14:45:44 -0000 1.117 +++ mathed/math_hullinset.C 13 Feb 2004 12:59:53 -0000 @@ -993,7 +993,6 @@ void MathHullInset::insetUnlock(BufferVi if (bv.cursor().inMathed()) { if (bv.cursor().inMacroMode()) bv.cursor().macroModeClose(); - bv.cursor().releaseMathCursor(); } if (bv.buffer()) generatePreview(*bv.buffer()); Index: mathed/math_nestinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_nestinset.C,v retrieving revision 1.93 diff -u -p -r1.93 math_nestinset.C --- mathed/math_nestinset.C 12 Feb 2004 11:39:30 -0000 1.93 +++ mathed/math_nestinset.C 13 Feb 2004 12:59:53 -0000 @@ -744,7 +744,6 @@ MathNestInset::priv_dispatch(LCursor & c revealCodes(cur); cur.bv().stuffClipboard(cur.grabSelection()); } else { - cur.releaseMathCursor(); if (remove_inset) cur.bv().owner()->dispatch(FuncRequest(LFUN_DELETE)); } @@ -767,7 +766,7 @@ void MathNestInset::edit(LCursor & cur, } -void MathNestInset::edit(LCursor & cur, int x, int y) +InsetBase * MathNestInset::editXY(LCursor & cur, int x, int y) { int idx_min = 0; int dist_min = 1000000; @@ -787,8 +786,9 @@ void MathNestInset::edit(LCursor & cur, // hit inside cell for (pos_type i = 0, n = ar.size(); i < n; ++i) if (ar[i]->covers(x, y)) - ar[i].nucleus()->edit(cur, x, y); + return ar[i].nucleus()->editXY(cur, x, y); } + return this; } Index: mathed/math_nestinset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_nestinset.h,v retrieving revision 1.54 diff -u -p -r1.54 math_nestinset.h --- mathed/math_nestinset.h 6 Feb 2004 16:14:06 -0000 1.54 +++ mathed/math_nestinset.h 13 Feb 2004 12:59:53 -0000 @@ -43,7 +43,7 @@ public: /// void edit(LCursor & cur, bool left); /// - void edit(LCursor & cur, int x, int y); + InsetBase * editXY(LCursor & cur, int x, int y); /// order of movement through the cells when pressing the left key bool idxLeft(LCursor &) const;