]> git.lyx.org Git - lyx.git/blobdiff - src/text3.C
update no.po
[lyx.git] / src / text3.C
index 48bc0c0a7edcc4c91d81b5052a6ee7b7f0c730ed..c737a2340e888d840a4936f4bdca6c5deda19a30 100644 (file)
@@ -258,12 +258,15 @@ void LyXText::cursorPrevious(BufferView * bv)
 
        int new_y;
        if (cursorrow == bv->text->cursor.row()) {
-               // we have a row which is higher than the workarea so we leave the
-               // cursor on the start of the row and move only the draw up as soon
-               // as we move the cursor or do something while inside the row (it may
-               // span several workarea-heights) we'll move to the top again, but this
-               // is better than just jump down and only display part of the row.
+               // we have a row which is taller than the workarea. The
+               // simplest solution is to move to the previous row instead.
+               cursorUp(bv, true);
+               return;
+               // This is what we used to do, so we wouldn't skip right past
+               // tall rows, but it's not working right now.
+#if 0
                new_y = bv->text->first_y - bv->workHeight();
+#endif
        } else {
                if (inset_owner) {
                        new_y = bv->text->cursor.iy()
@@ -319,12 +322,15 @@ void LyXText::cursorNext(BufferView * bv)
 
        int new_y;
        if (cursorrow == bv->text->cursor.row()) {
-               // we have a row which is higher than the workarea so we leave the
-               // cursor on the start of the row and move only the draw down as soon
-               // as we move the cursor or do something while inside the row (it may
-               // span several workarea-heights) we'll move to the top again, but this
-               // is better than just jump down and only display part of the row.
+               // we have a row which is taller than the workarea. The
+               // simplest solution is to move to the next row instead.
+               cursorDown(bv, true);
+               return;
+               // This is what we used to do, so we wouldn't skip right past
+               // tall rows, but it's not working right now.
+#if 0
                new_y = bv->text->first_y + bv->workHeight();
+#endif
        } else {
                if (inset_owner) {
                        new_y = bv->text->cursor.iy()
@@ -356,6 +362,7 @@ void LyXText::update(BufferView * bv, bool changed)
                bv->update(this, c);
 }
 
+namespace {
 
 void specialChar(LyXText * lt, BufferView * bv, InsetSpecialChar::Kind kind)
 {
@@ -368,6 +375,31 @@ void specialChar(LyXText * lt, BufferView * bv, InsetSpecialChar::Kind kind)
                bv->updateInset(new_inset, true);
 }
 
+void doInsertInset(LyXText * lt, FuncRequest const & cmd,
+                  bool edit, bool pastesel)
+{
+       Inset * inset = createInset(cmd);
+       BufferView * bv = cmd.view();
+       
+       if (inset) {
+               bool gotsel = false;
+               if (lt->selection.set()) {
+                       lt->cutSelection(bv, true, false);
+                       gotsel = true;
+               }
+               if (bv->insertInset(inset)) {
+                       if (edit)
+                               inset->edit(bv);
+                       if (gotsel && pastesel)
+                               bv->owner()->dispatch(FuncRequest(LFUN_PASTESELECTION));
+               }
+               else
+                       delete inset;
+       }
+
+}
+
+}
 
 Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
 {
@@ -1586,12 +1618,10 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
 #if 0
        case LFUN_INSET_LIST:
        case LFUN_INSET_THEOREM:
+       case LFUN_INSET_CAPTION:
 #endif
        case LFUN_INSERT_NOTE:
-       case LFUN_INSERT_URL:
-       case LFUN_INSET_CAPTION:
        case LFUN_INSET_ERT:
-       case LFUN_INSET_EXTERNAL:
        case LFUN_INSET_FLOAT:
        case LFUN_INSET_FOOTNOTE:
        case LFUN_INSET_MARGINAL:
@@ -1600,29 +1630,24 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
        case LFUN_INSET_WIDE_FLOAT:
        case LFUN_INSET_WRAP:
        case LFUN_TABULAR_INSERT:
+               // Open the inset, and move the current selection
+               // inside it.
+               doInsertInset(this, cmd, true, true);
+               break;
+
+       case LFUN_INSERT_URL:
+       case LFUN_INSET_EXTERNAL:
        case LFUN_INDEX_INSERT:
+               // Just open the inset
+               doInsertInset(this, cmd, true, false);
+               break;
+
        case LFUN_INDEX_PRINT:
        case LFUN_PARENTINSERT:
        case LFUN_TOC_INSERT:
-       {
-               Inset * inset = createInset(cmd);
-               if (inset) {
-                       bool gotsel = false;
-                       if (selection.set()) {
-                               cutSelection(bv, true, false);
-                               gotsel = true;
-                       }
-                       if (bv->insertInset(inset)) {
-                               inset->edit(bv);
-                               if (gotsel)
-                                       bv->owner()->dispatch(FuncRequest(LFUN_PASTESELECTION));
-                       }
-                       else
-                               delete inset;
-               }
+               // do nothing fancy
+               doInsertInset(this, cmd, false, false);
                break;
-       }
-
 
        default:
                return Inset::UNDISPATCHED;