* 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
This commit is contained in:
Stefan Schimanski 2008-09-08 00:13:55 +00:00
parent d0bb35a626
commit f6084eaaa9
4 changed files with 28 additions and 21 deletions

View 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
};

View 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

View 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;

View 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)