]> git.lyx.org Git - lyx.git/blobdiff - src/text3.C
fix reading the author field.
[lyx.git] / src / text3.C
index dd6b10244ae0b11d56059a6d3d07ebcbe7407c4a..869cda8b7bfcb87817bcd63cd30bea3fa6716976 100644 (file)
@@ -23,6 +23,7 @@
 #include "bufferparams.h"
 #include "BufferView.h"
 #include "cursor.h"
+#include "coordcache.h"
 #include "CutAndPaste.h"
 #include "debug.h"
 #include "dispatchresult.h"
@@ -183,42 +184,6 @@ string const freefont2string()
 
 }
 
-
-//takes absolute x,y coordinates
-InsetBase * LyXText::checkInsetHit(int x, int y) const 
-{
-       par_type pit;
-       par_type end;
-
-       getParsInRange(paragraphs(),
-                      bv()->top_y() - yo_,
-                      bv()->top_y() - yo_ + bv()->workHeight(),
-                      pit, end);
-
-       lyxerr << "checkInsetHit: x: " << x << " y: " << y << endl;
-       lyxerr << "  pit: " << pit << " end: " << end << endl;
-       for (; pit != end; ++pit) {
-               InsetList::const_iterator iit = pars_[pit].insetlist.begin();
-               InsetList::const_iterator iend = pars_[pit].insetlist.end();
-               for (; iit != iend; ++iit) {
-                       InsetBase * inset = iit->inset;
-#if 0
-                       lyxerr << "examining inset " << inset
-                               << " xo: " << inset->xo() << "..." << inset->xo() + inset->width()
-                               << " yo: " << inset->yo() - inset->ascent() << "..."
-                               << inset->yo() + inset->descent() << endl;
-#endif
-                       if (inset->covers(x, y)) {
-                               lyxerr << "Hit inset: " << inset << endl;
-                               return inset;
-                       }
-               }
-       }
-       //lyxerr << "No inset hit. " << endl;
-       return 0;
-}
-
-
 bool LyXText::gotoNextInset(LCursor & cur,
        vector<InsetOld_code> const & codes, string const & contents)
 {
@@ -455,17 +420,25 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                break;
 
        case LFUN_BEGINNINGBUF:
-               if (!cur.mark())
-                       cur.clearSelection();
-               cursorTop(cur);
-               finishChange(cur, false);
+               if (cur.size() == 1) {
+                       if (!cur.mark())
+                               cur.clearSelection();
+                       cursorTop(cur);
+                       finishChange(cur, false);
+               } else {
+                       cur.undispatched();
+               }
                break;
 
        case LFUN_ENDBUF:
-               if (!cur.mark())
-                       cur.clearSelection();
-               cursorBottom(cur);
-               finishChange(cur, false);
+               if (cur.size() == 1) {
+                       if (!cur.mark())
+                               cur.clearSelection();
+                       cursorBottom(cur);
+                       finishChange(cur, false);
+               } else {
+                       cur.undispatched();
+               }
                break;
 
        case LFUN_RIGHT:
@@ -1037,7 +1010,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                                cur.insert(new InsetQuotes(c,
                                    bufparams.quotes_language,
                                    InsetQuotes::DoubleQ));
-                       else 
+                       else
                                cur.insert(new InsetQuotes(c, bufparams));
                        cur.posRight();
                }
@@ -1087,42 +1060,6 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                }
                break;
 
-       case LFUN_MOUSE_MOTION: {
-               // Only use motion with button 1
-               //if (cmd.button() != mouse_button::button1)
-               //      return false;
-               // We want to use only motion events for which
-               // the button press event was on the drawing area too.
-               if (!selection_possible) {
-                       lyxerr[Debug::ACTION] << "BufferView::Pimpl::"
-                               "dispatch: no selection possible\n";
-                       lyxerr << "BufferView::Pimpl::dispatch: no selection possible\n";
-                       break;
-               }
-
-               // ignore motions deeper nested than the real anchor
-               LCursor & bvcur = cur.bv().cursor();
-               if (bvcur.selection() && bvcur.anchor_.size() < cur.size())
-                       break;
-
-               CursorSlice old = cur.top();
-               setCursorFromCoordinates(cur, cmd.x, cmd.y);
-
-               // This is to allow jumping over large insets
-               // FIXME: shouldn't be top-text-specific
-               if (isMainText() && cur.top() == old) {
-                       if (cmd.y - bv->top_y() >= bv->workHeight())
-                               cursorDown(cur);
-                       else if (cmd.y - bv->top_y() < 0)
-                               cursorUp(cur);
-               }
-
-               // don't set anchor_
-               bv->cursor().setCursor(cur, true);
-               lyxerr << "MOTION: " << bv->cursor() << endl;
-               break;
-       }
-
        // Single-click on work area
        case LFUN_MOUSE_PRESS: {
                // Right click on a footnote flag opens float menu
@@ -1177,6 +1114,42 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                break;
        }
 
+       case LFUN_MOUSE_MOTION: {
+               // Only use motion with button 1
+               //if (cmd.button() != mouse_button::button1)
+               //      return false;
+               // We want to use only motion events for which
+               // the button press event was on the drawing area too.
+               if (!selection_possible) {
+                       lyxerr[Debug::ACTION] << "BufferView::Pimpl::"
+                               "dispatch: no selection possible\n";
+                       lyxerr << "BufferView::Pimpl::dispatch: no selection possible\n";
+                       break;
+               }
+
+               // ignore motions deeper nested than the real anchor
+               LCursor & bvcur = cur.bv().cursor();
+               if (bvcur.anchor_.hasPart(cur)) {
+                       CursorSlice old = cur.top();
+                       setCursorFromCoordinates(cur, cmd.x, cmd.y);
+
+                       // This is to allow jumping over large insets
+                       // FIXME: shouldn't be top-text-specific
+                       if (isMainText() && cur.top() == old) {
+                               if (cmd.y - bv->top_y() >= bv->workHeight())
+                                       cursorDown(cur);
+                               else if (cmd.y - bv->top_y() < 0)
+                                       cursorUp(cur);
+                       }
+
+                       // don't set anchor_
+                       bv->cursor().setCursor(cur);
+                       bv->cursor().selection() = true;
+                       lyxerr << "MOTION: " << bv->cursor() << endl;
+               }
+               break;
+       }
+
        case LFUN_MOUSE_RELEASE: {
                selection_possible = false;
 
@@ -1435,21 +1408,21 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
        }
 
        case LFUN_FINISHED_LEFT:
-               lyxerr << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
+               lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
                break;
 
        case LFUN_FINISHED_RIGHT:
-               lyxerr << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
+               lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
                ++cur.pos();
                break;
 
        case LFUN_FINISHED_UP:
-               lyxerr << "handle LFUN_FINISHED_UP:\n" << cur << endl;
+               lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_UP:\n" << cur << endl;
                cursorUp(cur);
                break;
 
        case LFUN_FINISHED_DOWN:
-               lyxerr << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
+               lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
                cursorDown(cur);
                break;
 
@@ -1827,8 +1800,6 @@ bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
        case LFUN_DELETE_LINE_FORWARD:
        case LFUN_WORDRIGHT:
        case LFUN_WORDLEFT:
-       case LFUN_ENDBUF:
-       case LFUN_BEGINNINGBUF:
        case LFUN_RIGHT:
        case LFUN_RIGHTSEL:
        case LFUN_LEFT:
@@ -1937,6 +1908,11 @@ bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
                enable = true;
                break;
 
+       case LFUN_ENDBUF:
+       case LFUN_BEGINNINGBUF:
+               enable = true;
+               break;
+
        default:
                enable = false;
                break;