From f6084eaaa99672e593d27a4617e2fcd72e5ca0dc Mon Sep 17 00:00:00 2001 From: Stefan Schimanski Date: Mon, 8 Sep 2008 00:13:55 +0000 Subject: [PATCH] * LFUNs complete and complete-cancel. No key interception anymore. For now you have to bind the two LFUNs yourself. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26330 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/FuncCode.h | 1 + src/LyXAction.cpp | 12 +++++++++++- src/frontends/qt4/GuiView.cpp | 16 ++++++++++++++++ src/frontends/qt4/GuiWorkArea.cpp | 20 -------------------- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/FuncCode.h b/src/FuncCode.h index 1eb752f98a..992a73f5af 100644 --- a/src/FuncCode.h +++ b/src/FuncCode.h @@ -404,6 +404,7 @@ enum FuncCode // 310 LFUN_GRAPHICS_GROUPS_UNIFY, LFUN_SET_GRAPHICS_GROUP, + LFUN_COMPLETION_CANCEL, LFUN_LASTACTION // end of the table }; diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 24015ade53..bcd72be266 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -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 diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index aed3581a85..7d17028c21 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -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; diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index 20d0653f80..230396a0fd 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -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) -- 2.39.2