]> git.lyx.org Git - lyx.git/blobdiff - src/text2.C
bug + spped fixes + small stuff
[lyx.git] / src / text2.C
index e15775524e164ac99ef5fd351930390432dac074..6e4c06c7430308e8da540cb65a07390b29fb1b9d 100644 (file)
@@ -291,11 +291,9 @@ void LyXText::setLayout(string const & layout)
                bv()->owner()->dispatch(FuncRequest(LFUN_ENDSEL));
                bv()->owner()->dispatch(FuncRequest(LFUN_CUT));
                InsetBase * inset = new InsetEnvironment(params, layout);
-               if (bv()->insertInset(inset)) {
-                       //inset->edit(bv());
-                       //bv()->owner()->dispatch(FuncRequest(LFUN_PASTE));
-               } else
-                       delete inset;
+               insertInset(inset);
+               //inset->edit(bv());
+               //bv()->owner()->dispatch(FuncRequest(LFUN_PASTE));
                return;
        }
 
@@ -468,8 +466,7 @@ void LyXText::cursorTop()
 
 void LyXText::cursorBottom()
 {
-       ParagraphList::iterator lastpit =
-               boost::prior(paragraphs().end());
+       ParagraphList::iterator lastpit = boost::prior(paragraphs().end());
        setCursor(lastpit, lastpit->size());
 }
 
@@ -522,7 +519,7 @@ string LyXText::getStringToIndex()
        else if (cur.selBegin().par() != cur.selEnd().par())
                bv()->owner()->message(_("Cannot index more than one paragraph!"));
        else
-               idxstring = selectionAsString(*bv()->buffer(), false);
+               idxstring = cur.selectionAsString(false);
 
        // Reset cursors to their original position.
        cursor() = reset_cursor;
@@ -898,7 +895,7 @@ void LyXText::cutSelection(bool doclear, bool realcut)
        // finished. The solution used currently just works, to make it
        // faster we need to be more clever and probably also have more
        // calls to stuffClipboard. (Lgb)
-       bv()->stuffClipboard(selectionAsString(*bv()->buffer(), true));
+       bv()->stuffClipboard(cur.selectionAsString(true));
 
        // This doesn't make sense, if there is no selection
        if (!cur.selection())
@@ -949,7 +946,7 @@ void LyXText::copySelection()
 {
        LCursor & cur = bv()->cursor();
        // stuff the selection onto the X clipboard, from an explicit copy request
-       bv()->stuffClipboard(selectionAsString(*bv()->buffer(), true));
+       bv()->stuffClipboard(cur.selectionAsString(true));
 
        // this doesnt make sense, if there is no selection
        if (!cur.selection())
@@ -1209,7 +1206,7 @@ void LyXText::setCurrentFont()
        }
 }
 
-
+// x is an absolute screen coord
 // returns the column near the specified x-coordinate of the row
 // x is set to the real beginning of this column
 pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
@@ -1329,7 +1326,8 @@ void LyXText::setCursorFromCoordinates(CursorSlice & cur, int x, int y)
        ParagraphList::iterator pit;
        Row const & row = *getRowNearY(y, pit);
        bool bound = false;
-       pos_type const pos = row.pos() + getColumnNearX(pit, row, x, bound);
+       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;
@@ -1339,10 +1337,11 @@ void LyXText::setCursorFromCoordinates(CursorSlice & cur, int x, int y)
 // x,y are absolute screen coordinates
 void LyXText::edit(LCursor & cur, int x, int y)
 {
-       int xx = x; // is modified by getColumnNearX
        ParagraphList::iterator pit;
-       Row const & row = *getRowNearY(y, pit);
+       Row const & row = *getRowNearY(y - yo_, pit);
        bool bound = false;
+
+       int xx = x; // is modified by getColumnNearX
        pos_type const pos = row.pos() + getColumnNearX(pit, row, xx, bound);
        cur.par() = parOffset(pit);
        cur.pos() = pos;
@@ -1351,11 +1350,12 @@ void LyXText::edit(LCursor & cur, int x, int y)
        // 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.
+               // 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.
+               // Make sure the cursor points to the position before
+               // this inset.
                if (inset == pit->getInset(pos - 1))
                        --cur.pos();
                inset->edit(cur, x, y);