"math" "auto,math,bottom"
"mathmacrotemplate" "auto,mathmacrotemplate,bottom"
"ipa" "auto,ipa,bottom"
- "minibuffer" "off,bottom"
+ "minibuffer" "auto,minibuffer,bottom"
End
}
-void dispatch(FuncRequest const & action)
+DispatchResult const & dispatch(FuncRequest const & action)
{
LAPPERR(theApp());
return theApp()->dispatch(action);
void dispatch(FuncRequest const & action, DispatchResult & dr)
{
LAPPERR(theApp());
- return theApp()->dispatch(action, dr);
+ theApp()->dispatch(action, dr);
}
bool first_start;
friend FuncStatus getStatus(FuncRequest const & action);
- friend void dispatch(FuncRequest const & action);
+ friend DispatchResult const & dispatch(FuncRequest const & action);
friend void dispatch(FuncRequest const & action, DispatchResult & dr);
friend std::vector<std::string> & theFilesToLoad();
friend BufferList & theBufferList();
FuncStatus getStatus(FuncRequest const & action);
///
-void dispatch(FuncRequest const & action);
+DispatchResult const & dispatch(FuncRequest const & action);
///
void dispatch(FuncRequest const & action, DispatchResult & dr);
/// Every user command is processed here, either invocated from
/// keyboard or from the GUI. All GUI objects, including buttons and
/// menus should use this class and never call kernel functions directly.
- virtual void dispatch(FuncRequest const &) = 0;
+ virtual DispatchResult const & dispatch(FuncRequest const &) = 0;
/// LyX dispatcher: executes lyx actions and returns result.
virtual void dispatch(FuncRequest const &, DispatchResult & dr) = 0;
///
KeyModifier meta_fake_bit;
+ /// The result of last dispatch action
+ DispatchResult dispatch_result_;
+
/// Multiple views container.
/**
* Warning: This must not be a smart pointer as the destruction of the
}
-void GuiApplication::dispatch(FuncRequest const & cmd)
+DispatchResult const & GuiApplication::dispatch(FuncRequest const & cmd)
{
Buffer * buffer = 0;
if (current_view_ && current_view_->currentBufferView()) {
// the buffer may have been closed by one action
if (theBufferList().isLoaded(buffer))
buffer->undo().endUndoGroup();
+
+ d->dispatch_result_ = dr;
+ return d->dispatch_result_;
}
/// \name Methods inherited from Application class
//@{
- void dispatch(FuncRequest const &);
+ DispatchResult const & dispatch(FuncRequest const &);
void dispatch(FuncRequest const &, DispatchResult & dr);
FuncStatus getStatus(FuncRequest const & cmd) const;
void restoreGuiSession();
edit_->setMinimumSize(edit_->sizeHint());
edit_->setFocusPolicy(Qt::ClickFocus);
- connect(edit_, SIGNAL(escapePressed()), this, SLOT(cancel()));
connect(edit_, SIGNAL(returnPressed()), this, SLOT(dispatch()));
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(hideParent()));
+ connect(edit_, SIGNAL(escapePressed()), this, SLOT(hideParent()));
layout->addWidget(upPB, 0);
layout->addWidget(downPB, 0);
}
-void GuiCommandBuffer::cancel()
-{
- view_->setFocus();
- edit_->setText(QString());
-}
-
-
void GuiCommandBuffer::dispatch()
{
- QString const cmd = edit_->text();
- view_->setFocus();
- edit_->setText(QString());
- edit_->clearFocus();
- std::string const cmd_ = fromqstr(cmd);
- theSession().lastCommands().add(cmd_);
- dispatch(cmd_);
+ std::string const cmd = fromqstr(edit_->text());
+ if (!cmd.empty())
+ theSession().lastCommands().add(cmd);
+ DispatchResult const & dr = dispatch(cmd);
+ if (!dr.error()) {
+ view_->setFocus();
+ edit_->setText(QString());
+ edit_->clearFocus();
+ // If the toolbar was "auto", it is not needed anymore
+ view_->resetCommandExecute();
+ }
}
void GuiCommandBuffer::hideParent()
{
view_->setFocus();
+ view_->resetCommandExecute();
edit_->setText(QString());
edit_->clearFocus();
- hide();
}
}
-void GuiCommandBuffer::hide() const
-{
- FuncRequest cmd(LFUN_COMMAND_EXECUTE, "off");
- lyx::dispatch(cmd);
-}
-
-
vector<string> const
GuiCommandBuffer::completions(string const & prefix, string & new_prefix)
{
}
-void GuiCommandBuffer::dispatch(string const & str)
+DispatchResult const & GuiCommandBuffer::dispatch(string const & str)
{
- if (str.empty())
- return;
+ if (str.empty()) {
+ static DispatchResult empty_dr;
+ return empty_dr;
+ }
history_.push_back(trim(str));
history_pos_ = history_.end();
downPB->setEnabled(history_pos_ != history_.end());
FuncRequest func = lyxaction.lookupFunc(str);
func.setOrigin(FuncRequest::COMMANDBUFFER);
- lyx::dispatch(func);
+ return lyx::dispatch(func);
}
} // namespace frontend
class QListWidgetItem;
namespace lyx {
+
+class DispatchResult;
+
namespace frontend {
class GuiView;
GuiCommandBuffer(GuiView * view);
public Q_SLOTS:
- /// cancel command compose
- void cancel();
/// dispatch a command
void dispatch();
/// tab-complete
/// return the font and depth in the active BufferView as a message.
docstring const getCurrentState() const;
- /// hide the command buffer.
- void hide() const;
-
/// open a listbox and show the contents of the list. When reversed
/// is true, the contents of the list is filled bottom-up.
void showList(std::vector<std::string> const & list,
std::string & new_prefix);
/// dispatch a command
- void dispatch(std::string const & str);
+ DispatchResult const & dispatch(std::string const & str);
/// available command names
std::vector<std::string> commands_;
downPressed();
break;
- case Qt::Key_X:
- if (e->modifiers() == Qt::AltModifier
- || e->modifiers() == Qt::MetaModifier) {
- // emit signal
- hidePressed();
- break;
- }
-
default:
QLineEdit::keyPressEvent(e);
break;
void downPressed();
/// complete
void tabPressed();
- /// leave and hide command buffer
- void hidePressed();
protected:
///
void GuiToolbar::update(int context)
{
- if (visibility_ & Toolbars::AUTO)
+ if (visibility_ & Toolbars::AUTO) {
+ bool const was_visible = isVisible();
setVisible(visibility_ & context & Toolbars::ALLOWAUTO);
+ if (isVisible() && !was_visible && commandBuffer())
+ commandBuffer()->setFocus();
+ }
// update visible toolbars only
if (!isVisible())
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
}
+void GuiView::resetCommandExecute()
+{
+ command_execute_ = false;
+ updateToolbars();
+}
+
+
double GuiView::pixelRatio() const
{
#if QT_VERSION >= 0x050000
context |= Toolbars::MATHMACROTEMPLATE;
if (lyx::getStatus(FuncRequest(LFUN_IN_IPA)).enabled())
context |= Toolbars::IPA;
+ if (command_execute_)
+ context |= Toolbars::MINIBUFFER;
for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
it->second->update(context);
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_ = true;
break;
}
case LFUN_DROP_LAYOUTS_CHOICE:
/// are we busy ?
bool busy() const;
+ /// Signal that the any "auto" minibuffer can be closed now.
+ void resetCommandExecute();
/// \name Generic accessor functions
//@{
/// functions that call setBusy;
int busy_;
+ /// Request to open the command toolbar if it is "auto"
+ bool command_execute_;
+
};
} // namespace frontend
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"))
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;