the attached patch implements a shortcut which leaves and closes the 
minibuffer. It's hardcoded to M-x[1] and (intentionally) only works when the 
cursor is inside the command buffer. So the behaviour would be

- cursor in main view
=> M-x opens the minibuffer, if necessary, and enters it

- cursor in minbuffer
=> M-x leaves the minibuffer and closes it

OK?

Jürgen

[1] Ideally, it should grab what is defined for "command-execute" and use 
that. But I don't know how to get that information from the frontend side.
Index: src/frontends/qt4/QCommandBuffer.h
===================================================================
--- src/frontends/qt4/QCommandBuffer.h	(Revision 18054)
+++ src/frontends/qt4/QCommandBuffer.h	(Arbeitskopie)
@@ -43,6 +43,8 @@
 	void up();
 	/// down
 	void down();
+	/// leave and hide the command buffer
+	void hideCommandBuffer();
 private:
 	/// owning view
 	GuiView * view_;
Index: src/frontends/qt4/QCommandEdit.h
===================================================================
--- src/frontends/qt4/QCommandEdit.h	(Revision 18054)
+++ src/frontends/qt4/QCommandEdit.h	(Arbeitskopie)
@@ -32,6 +32,8 @@
 	void downPressed();
 	/// complete
 	void tabPressed();
+	/// leave and hide command buffer
+	void hidePressed();
 
 protected:
 	///
Index: src/frontends/qt4/QCommandBuffer.cpp
===================================================================
--- src/frontends/qt4/QCommandBuffer.cpp	(Revision 18054)
+++ src/frontends/qt4/QCommandBuffer.cpp	(Arbeitskopie)
@@ -101,6 +101,7 @@
 	connect(edit_, SIGNAL(tabPressed()), this, SLOT(complete()));
 	connect(edit_, SIGNAL(upPressed()), this, SLOT(up()));
 	connect(edit_, SIGNAL(downPressed()), this, SLOT(down()));
+	connect(edit_, SIGNAL(hidePressed()), this, SLOT(hideCommandBuffer()));
 
 	layout->addWidget(up, 0);
 	layout->addWidget(down, 0);
@@ -214,6 +215,15 @@
 }
 
 
+void QCommandBuffer::hideCommandBuffer()
+{
+	view_->setFocus();
+	edit_->setText(QString());
+	edit_->clearFocus();
+	controller_.hideCommandBuffer();
+}
+
+
 #if 0
 void XMiniBuffer::show_info_suffix(string const & suffix, string const & input)
 {
Index: src/frontends/qt4/QCommandEdit.cpp
===================================================================
--- src/frontends/qt4/QCommandEdit.cpp	(Revision 18054)
+++ src/frontends/qt4/QCommandEdit.cpp	(Arbeitskopie)
@@ -43,6 +43,14 @@
 		downPressed();
 		break;
 
+	case Qt::Key_X:
+		if (e->modifiers() == Qt::AltModifier
+		   || e->modifiers() == Qt::MetaModifier) {
+			// emit signal
+			hidePressed();
+			break;
+		}
+
 	default:
 		QLineEdit::keyPressEvent(e);
 		break;
Index: src/frontends/controllers/ControlCommandBuffer.h
===================================================================
--- src/frontends/controllers/ControlCommandBuffer.h	(Revision 18054)
+++ src/frontends/controllers/ControlCommandBuffer.h	(Arbeitskopie)
@@ -44,6 +44,9 @@
 	/// return the font and depth in the active BufferView as a message.
 	docstring const getCurrentState() const;
 
+	/// hide the command buffer.
+	void hideCommandBuffer() const;
+
 	/// return the possible completions
 	std::vector<std::string> const completions(std::string const & prefix,
 					      std::string & new_prefix);
Index: src/frontends/controllers/ControlCommandBuffer.cpp
===================================================================
--- src/frontends/controllers/ControlCommandBuffer.cpp	(Revision 18054)
+++ src/frontends/controllers/ControlCommandBuffer.cpp	(Arbeitskopie)
@@ -85,6 +85,12 @@
 }
 
 
+void ControlCommandBuffer::hideCommandBuffer() const
+{
+	lv_.getToolbars().display("minibuffer", false);
+}
+
+
 vector<string> const
 ControlCommandBuffer::completions(string const & prefix, string & new_prefix)
 {

Reply via email to