]> git.lyx.org Git - lyx.git/commitdiff
* LFUNs complete and complete-cancel. No key interception anymore. For now you have...
authorStefan Schimanski <sts@lyx.org>
Mon, 8 Sep 2008 00:13:55 +0000 (00:13 +0000)
committerStefan Schimanski <sts@lyx.org>
Mon, 8 Sep 2008 00:13:55 +0000 (00:13 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26330 a592a061-630c-0410-9148-cb99ea01b6c8

src/FuncCode.h
src/LyXAction.cpp
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiWorkArea.cpp

index 1eb752f98ac838d606bd5f819baf77d4d2ab1ede..992a73f5af60d02f0ab8674bc7de884a17b60992 100644 (file)
@@ -404,6 +404,7 @@ enum FuncCode
        // 310
        LFUN_GRAPHICS_GROUPS_UNIFY,
        LFUN_SET_GRAPHICS_GROUP,
+       LFUN_COMPLETION_CANCEL,
        LFUN_LASTACTION                  // end of the table
 };
 
index 24015ade5342675660ccd61bf176dff04af04387..bcd72be2666e39458a56d9fc745ded5fd205120e 100644 (file)
@@ -2997,11 +2997,21 @@ void LyXAction::init()
 /*!
  * \var lyx::FuncCode lyx::LFUN_COMPLETION_COMPLETE
  * \li Action: Try to complete the word or command at the cursor position.
- * \li Syntax: completion-complete
+ * \li Syntax: complete
  * \li Origin: sts, Feb 19 2008
  * \endvar
  */
                { LFUN_COMPLETION_COMPLETE, "complete", SingleParUpdate, Edit },
+
+/*!
+ * \var lyx::FuncCode lyx::LFUN_COMPLETION_CANCEL
+ * \li Action: Try to cancel completion, either the popup or the inline completion
+ * \li Syntax: completion-escape
+ * \li Origin: sts, Sep 07 2008
+ * \endvar
+ */
+               { LFUN_COMPLETION_CANCEL, "completion-cancel", SingleParUpdate, Edit },
+
 /*!
  * \var lyx::FuncCode lyx::LFUN_BRANCH_ACTIVATE
  * \li Action: Activate the branch
index aed3581a85e9f779b877d64350edbb6aef894ed1..7d17028c211a554ac9270d2bd7d105b3495bb319 100644 (file)
@@ -1212,6 +1212,13 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                    enable = false;
                break;
 
+       case LFUN_COMPLETION_CANCEL:
+               if (!d.current_work_area_
+                   || (!d.current_work_area_->completer().popupVisible()
+                       && !d.current_work_area_->completer().inlineVisible()))
+                       enable = false;
+               break;
+
        default:
                return false;
        }
@@ -2006,6 +2013,15 @@ bool GuiView::dispatch(FuncRequest const & cmd)
                                d.current_work_area_->completer().tab();
                        break;
 
+               case LFUN_COMPLETION_CANCEL:
+                       if (d.current_work_area_) {
+                               if (d.current_work_area_->completer().popupVisible())
+                                       d.current_work_area_->completer().hidePopup();
+                               else
+                                       d.current_work_area_->completer().hideInline();
+                       }
+                       break;
+
                default:
                        dispatched = false;
                        break;
index 20d0653f80d9dcb98a2039cfb2bfeb0fc30ffe98..230396a0fd3b35f76cca399448593d0e317e248f 100644 (file)
@@ -845,26 +845,6 @@ void GuiWorkArea::keyPressEvent(QKeyEvent * ev)
                        return;
                }
        }
-       
-       // intercept keys for the completion
-       if ((completer_->popupVisible() || completer_->inlineVisible())
-           && ev->key() == Qt::Key_Tab) {
-               completer_->tab();
-               ev->accept();
-               return;
-       } 
-
-       if (completer_->popupVisible() && ev->key() == Qt::Key_Escape) {
-               completer_->hidePopup();
-               ev->accept();
-               return;
-       }
-
-       if (completer_->inlineVisible() && ev->key() == Qt::Key_Escape) {
-               completer_->hideInline();
-               ev->accept();
-               return;
-       }
 
        // do nothing if there are other events
        // (the auto repeated events come too fast)