This patch makes minibuffer work like it does in emacs: it is open when
invoking M-x, and gets closed when the command has been executed.
It may be necessary to remove you session data (.config/LyX/lyx.conf for
linux) so that the toolbar gets the proper flags. This is probably a
problem when upgrading, I am not sure that we have a good solution for that.
Thoughts?
JMarc
>From d62f0050865c36a422752a1d06a7fe297f46cee0 Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date: Sat, 18 Apr 2015 19:10:33 +0200
Subject: [PATCH] Auto feature for minibuffer toolbar
Now the minibuffer toolbar is "auto" by default. It is opened by
command-execute (M-x) and closed when the command is executed.
---
lib/ui/default.ui | 2 +-
src/frontends/qt4/GuiCommandBuffer.cpp | 2 ++
src/frontends/qt4/GuiToolbar.cpp | 9 ++++++---
src/frontends/qt4/GuiToolbar.h | 2 +-
src/frontends/qt4/GuiView.cpp | 17 ++++++-----------
src/frontends/qt4/GuiView.h | 5 +++++
src/frontends/qt4/Toolbars.cpp | 2 ++
src/frontends/qt4/Toolbars.h | 3 ++-
8 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/lib/ui/default.ui b/lib/ui/default.ui
index fa20f1d..34f5651 100644
--- a/lib/ui/default.ui
+++ b/lib/ui/default.ui
@@ -56,5 +56,5 @@ Toolbars
"math" "auto,math,bottom"
"mathmacrotemplate" "auto,mathmacrotemplate,bottom"
"ipa" "auto,ipa,bottom"
- "minibuffer" "off,bottom"
+ "minibuffer" "auto,minibuffer,bottom"
End
diff --git a/src/frontends/qt4/GuiCommandBuffer.cpp b/src/frontends/qt4/GuiCommandBuffer.cpp
index c9ddf4a..0c46714 100644
--- a/src/frontends/qt4/GuiCommandBuffer.cpp
+++ b/src/frontends/qt4/GuiCommandBuffer.cpp
@@ -154,6 +154,8 @@ void GuiCommandBuffer::dispatch()
std::string const cmd_ = fromqstr(cmd);
theSession().lastCommands().add(cmd_);
dispatch(cmd_);
+ view_->resetCommandExecute();
+ view_->updateToolbars();
}
diff --git a/src/frontends/qt4/GuiToolbar.cpp b/src/frontends/qt4/GuiToolbar.cpp
index 15fe640..06adf27 100644
--- a/src/frontends/qt4/GuiToolbar.cpp
+++ b/src/frontends/qt4/GuiToolbar.cpp
@@ -321,16 +321,19 @@ void GuiToolbar::add(ToolbarItem const & item)
}
-void GuiToolbar::update(bool in_math, bool in_table, bool in_review,
- bool in_mathmacrotemplate, bool in_ipa)
+void GuiToolbar::update(bool in_math, bool in_table, bool in_review,
+ bool in_mathmacrotemplate, bool in_ipa, bool command_execute)
{
if (visibility_ & Toolbars::AUTO) {
bool show_it = (in_math && (visibility_ & Toolbars::MATH))
|| (in_table && (visibility_ & Toolbars::TABLE))
|| (in_review && (visibility_ & Toolbars::REVIEW))
|| (in_mathmacrotemplate && (visibility_ & Toolbars::MATHMACROTEMPLATE))
- || (in_ipa && (visibility_ & Toolbars::IPA));
+ || (in_ipa && (visibility_ & Toolbars::IPA))
+ || (command_execute && (visibility_ & Toolbars::MINIBUFFER));
setVisible(show_it);
+ if (show_it && commandBuffer())
+ commandBuffer()->setFocus();
}
// update visible toolbars only
diff --git a/src/frontends/qt4/GuiToolbar.h b/src/frontends/qt4/GuiToolbar.h
index 37ebd8c..679ddff 100644
--- a/src/frontends/qt4/GuiToolbar.h
+++ b/src/frontends/qt4/GuiToolbar.h
@@ -93,7 +93,7 @@ public:
/// Refresh the contents of the bar.
void update(bool in_math, bool in_table, bool review,
- bool in_mathmacrotemplate, bool in_ipa);
+ bool in_mathmacrotemplate, bool in_ipa, bool command_execute);
///
void toggle();
diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp
index a520b4e..bf823b5 100644
--- a/src/frontends/qt4/GuiView.cpp
+++ b/src/frontends/qt4/GuiView.cpp
@@ -475,7 +475,8 @@ QSet<Buffer const *> GuiView::GuiViewPrivate::busyBuffers;
GuiView::GuiView(int id)
- : d(*new GuiViewPrivate(this)), id_(id), closing_(false), busy_(0)
+ : d(*new GuiViewPrivate(this)), id_(id), closing_(false), busy_(0),
+ command_execute_(false)
{
// GuiToolbars *must* be initialised before the menu bar.
normalSizedIcons(); // at least on Mac the default is 32 otherwise, which is huge
@@ -1505,10 +1506,11 @@ void GuiView::updateToolbars()
lyx::getStatus(FuncRequest(LFUN_IN_IPA)).enabled();
for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
- it->second->update(math, table, review, mathmacrotemplate, ipa);
+ it->second->update(math, table, review, mathmacrotemplate, ipa,
+ command_execute_);
} else
for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
- it->second->update(false, false, false, false, false);
+ it->second->update(false, false, false, false, false, false);
}
@@ -3568,14 +3570,7 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
break;
case LFUN_COMMAND_EXECUTE: {
- bool const show_it = cmd.argument() != "off";
- // FIXME: this is a hack, "minibuffer" should not be
- // hardcoded.
- if (GuiToolbar * t = toolbar("minibuffer")) {
- t->setVisible(show_it);
- if (show_it && t->commandBuffer())
- t->commandBuffer()->setFocus();
- }
+ command_execute_ = cmd.argument() != "off";
break;
}
case LFUN_DROP_LAYOUTS_CHOICE:
diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h
index 478e3a1..db454a1 100644
--- a/src/frontends/qt4/GuiView.h
+++ b/src/frontends/qt4/GuiView.h
@@ -84,6 +84,8 @@ public:
/// are we busy ?
bool busy() const;
+ /// No need to keep the minibuffer open anymore
+ void resetCommandExecute() { command_execute_ = false; }
/// \name Generic accessor functions
//@{
@@ -449,6 +451,9 @@ private:
/// functions that call setBusy;
int busy_;
+ /// Request to open the command toolbar if it is "auto"
+ bool command_execute_;
+
};
} // namespace frontend
diff --git a/src/frontends/qt4/Toolbars.cpp b/src/frontends/qt4/Toolbars.cpp
index c961025..20eee93 100644
--- a/src/frontends/qt4/Toolbars.cpp
+++ b/src/frontends/qt4/Toolbars.cpp
@@ -348,6 +348,8 @@ void Toolbars::readToolbarSettings(Lexer & lex)
flag = MATHMACROTEMPLATE;
else if (!compare_ascii_no_case(*cit, "review"))
flag = REVIEW;
+ else if (!compare_ascii_no_case(*cit, "minibuffer"))
+ flag = MINIBUFFER;
else if (!compare_ascii_no_case(*cit, "top"))
flag = TOP;
else if (!compare_ascii_no_case(*cit, "bottom"))
diff --git a/src/frontends/qt4/Toolbars.h b/src/frontends/qt4/Toolbars.h
index 3e6ac57..02d0ebe 100644
--- a/src/frontends/qt4/Toolbars.h
+++ b/src/frontends/qt4/Toolbars.h
@@ -110,7 +110,8 @@ public:
MATHMACROTEMPLATE = 1024, //< show in math macro template
SAMEROW = 2048, //place to the current row, no new line
IPA = 4096, //< show when in IPA inset
- ALLOWAUTO = MATH | TABLE | REVIEW | MATHMACROTEMPLATE | IPA
+ MINIBUFFER = 8192, //< show when command-execute has been invoked
+ ALLOWAUTO = MATH | TABLE | REVIEW | MATHMACROTEMPLATE | IPA | MINIBUFFER
};
typedef std::vector<ToolbarInfo> Infos;
--
2.1.0