dispatch changes ...

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4705 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2002-07-18 20:15:29 +00:00
parent c723c2aeff
commit 98324cb046
22 changed files with 144 additions and 239 deletions

View File

@ -1,3 +1,14 @@
2002-07-18 John Levon <moz@compsoc.man.ac.uk>
* LyXAction.C:
* commandtags.h:
* lyxfunc.C: remove message-push/pop
* lyxserver.C:
* lyxfunc.h:
* lyxfunc.C: rationalise some code by removing verboseDispatch
in favour of a bool argument to dispatch()
2002-07-17 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* lyx_main.C (init): make sure to read symlinks as absolute paths

View File

@ -410,12 +410,6 @@ void LyXAction::init()
{ LFUN_UPCASE_WORD, "word-upcase", "", Noop },
{ LFUN_MESSAGE, "message",
N_("Show message in minibuffer"), NoBuffer },
{ LFUN_MESSAGE_PUSH, "message-push",
N_("Push old message and show this one in minibuffer"),
NoBuffer },
{ LFUN_MESSAGE_POP, "message-pop",
N_("Pop old message and show it in the minibuffer"),
NoBuffer },
{ LFUN_TRANSPOSE_CHARS, "chars-transpose", "", Noop },
{ LFUN_FLOAT_LIST, "float-list", "Insert a float list", Noop },
{ LFUN_ESCAPE, "escape", "", Noop },

View File

@ -284,8 +284,6 @@ enum kb_action {
LFUN_BOOKMARK_GOTO, // Dekel 20010127
LFUN_SELECT_FILE_SYNC, // Levon 20010214
LFUN_MESSAGE, // Lgb 20010408
LFUN_MESSAGE_PUSH, // Lgb 20010410
LFUN_MESSAGE_POP, // Lgb 20010410
LFUN_TRANSPOSE_CHARS, // Lgb 20010425
LFUN_ESCAPE, // 260 // Lgb 20010517
LFUN_HELP_ABOUTLYX, // Edwin 20010712

View File

@ -1,3 +1,10 @@
2002-07-18 John Levon <moz@compsoc.man.ac.uk>
* LyXView.h:
* LyXView.C:
* MiniBuffer.h:
* MiniBuffer.C: remove messagePush/Pop, addSet
2002-07-17 John Levon <moz@compsoc.man.ac.uk>
* LyXView.h:

View File

@ -127,18 +127,6 @@ void LyXView::message(string const & str)
}
void LyXView::messagePush(string const & str)
{
minibuffer_->messagePush(str);
}
void LyXView::messagePop()
{
minibuffer_->messagePop();
}
Menubar * LyXView::getMenubar() const
{
return menubar_.get();

View File

@ -113,10 +113,6 @@ public:
/// display a message in the view
void message(string const &);
/// push a message onto the history, and show it
void messagePush(string const & str);
/// pop the last message pushed
void messagePop();
/// updates the title of the window
void updateWindowTitle();

View File

@ -81,29 +81,6 @@ void MiniBuffer::message(string const & str)
}
void MiniBuffer::messagePush(string const & str)
{
text_stored = text;
message(str);
}
void MiniBuffer::messagePop()
{
if (!text_stored.empty()) {
message(text_stored);
text_stored.erase();
}
}
void MiniBuffer::addSet(string const & s1)
{
string const str = text + ' ' + s1;
message(str);
}
void MiniBuffer::prepareForInput(vector<string> const & completion,
vector<string> & history)
{

View File

@ -38,22 +38,6 @@ public:
/// Displays a text for 6 seconds
void message(string const & str);
/**
* This will display a message for 6 seconds.
* It will remember the previous text that can be restored
* with messagePop. (You can only remember one message.)
*/
void messagePush(string const & str);
/**
* Restore the previous text that was messagePush'ed.
* for 6 seconds
*/
void messagePop();
/// Adds text to the text already displayed for 6 seconds
void addSet(string const &);
/** Makes the minibuffer wait for a string to be inserted.
Waits for a string to be inserted into the minibuffer, when
the string has been inserted the signal stringReady is
@ -126,9 +110,6 @@ protected:
/// This is the text for the message display
string text;
/// This is the last text after a messagePush()
string text_stored;
/**
* This will emit the timeout signal after a message has been
* displayed for 6 seconds.
@ -148,4 +129,5 @@ protected:
///
std::vector<string>::iterator hist_iter;
};
#endif
#endif // MINIBUFFER_H

View File

@ -1,3 +1,9 @@
2002-07-18 John Levon <moz@compsoc.man.ac.uk>
* QtView.C:
* Toolbar_pimpl.C:
* lyx_gui.C: verboseDispatch() is now dispatch()
2002-07-07 Edwin Leuven <leuven@fee.uva.nl>
* QParagraph.[Ch]: Add paragraph dialog

View File

@ -97,7 +97,7 @@ void QtView::update_view_state()
void QtView::activated(int id)
{
getLyXFunc()->verboseDispatch(id, true);
getLyXFunc()->dispatch(id, true);
}

View File

@ -129,7 +129,7 @@ void Toolbar::Pimpl::button_selected(QToolButton * button)
return;
}
owner_->getLyXFunc()->verboseDispatch(cit->second, true);
owner_->getLyXFunc()->dispatch(cit->second, true);
}

View File

@ -108,7 +108,7 @@ void lyx_gui::start(string const & batch, vector<string> files)
// handle the batch commands the user asked for
if (!batch.empty()) {
view.getLyXFunc()->verboseDispatch(batch, false);
view.getLyXFunc()->dispatch(batch);
}
// FIXME: something somewhere is EATING CPU

View File

@ -1,3 +1,12 @@
2002-07-18 John Levon <moz@compsoc.man.ac.uk>
* Menubar_pimpl.C:
* Toolbar_pimpl.C:
* lyx_gui.C:
* XformsView.C: remove initMiniBuffer(), verboseDispatch()
* xfont_loader.C: remove call to messagePush(),Pop()
2002-07-17 Dekel Tsur <dekelts@tau.ac.il>
* FormFiledialog.C: Add missing #include

View File

@ -582,7 +582,7 @@ void Menubar::Pimpl::MenuCallback(FL_OBJECT * ob, long button)
// If the action value is too low, then it is not a
// valid action, but something else.
if (choice >= action_offset + 1) {
view->getLyXFunc()->verboseDispatch(choice - action_offset, true);
view->getLyXFunc()->dispatch(choice - action_offset, true);
} else {
lyxerr[Debug::GUI]
<< "MenuCallback: ignoring bogus action "

View File

@ -223,7 +223,7 @@ void ToolbarCB(FL_OBJECT * ob, long ac)
{
XFormsView * owner = static_cast<XFormsView *>(ob->u_vdata);
owner->getLyXFunc()->verboseDispatch(int(ac), true);
owner->getLyXFunc()->dispatch(int(ac), true);
}

View File

@ -64,10 +64,10 @@ XFormsView::XFormsView(int width, int height)
fl_set_form_atclose(getForm(), C_XFormsView_atCloseMainFormCB, 0);
// Connect the minibuffer signals
minibuffer_->inputReady.connect(boost::bind(&LyXFunc::miniDispatch, getLyXFunc(), _1));
minibuffer_->timeout.connect(boost::bind(&LyXFunc::initMiniBuffer, getLyXFunc()));
minibuffer_->inputReady.connect(boost::bind(&XFormsView::dispatch, this, _1));
view_state_changed.connect(boost::bind(&XFormsView::update_view_state, this));
view_state_changed.connect(boost::bind(&XFormsView::show_view_state, this));
minibuffer_->timeout.connect(boost::bind(&XFormsView::show_view_state, this));
// Make sure the buttons are disabled if needed.
updateToolbar();
@ -82,13 +82,19 @@ XFormsView::~XFormsView()
}
void XFormsView::dispatch(string const & arg)
{
getLyXFunc()->dispatch(arg, true);
}
/// Redraw the main form.
void XFormsView::redraw()
{
lyxerr[Debug::INFO] << "XFormsView::redraw()" << endl;
fl_redraw_form(getForm());
// This is dangerous, but we know it is safe
XMiniBuffer * m = static_cast<XMiniBuffer *>(getMiniBuffer());
XMiniBuffer * m = static_cast<XMiniBuffer *>(minibuffer_.get());
m->redraw();
}
@ -123,7 +129,7 @@ void XFormsView::show(int x, int y, string const & title)
fl_show_form(form, placement, FL_FULLBORDER, title.c_str());
getLyXFunc()->initMiniBuffer();
show_view_state();
#if FL_VERSION < 1 && (FL_REVISION < 89 || (FL_REVISION == 89 && FL_FIXLEVEL < 5))
InitLyXLookup(fl_get_display(), form_->window);
#endif
@ -201,9 +207,9 @@ void XFormsView::setWindowTitle(string const & title, string const & icon_title)
}
void XFormsView::update_view_state()
void XFormsView::show_view_state()
{
minibuffer_->message(currentState(view()));
minibuffer_->message(getLyXFunc()->view_status_message());
}

View File

@ -53,7 +53,10 @@ public:
/// callback for close event from window manager
static int atCloseMainFormCB(FL_FORM *, void *);
/// dispatch an action
void dispatch(string const & arg);
private:
/**
* setWindowTitle - set title of window
@ -63,7 +66,7 @@ private:
virtual void setWindowTitle(string const & t, string const & it);
/// update the minibuffer state message
void update_view_state();
void show_view_state();
/// makes the main form.
void create_form_form_main(Dialogs & d, int width, int height);

View File

@ -290,7 +290,7 @@ void lyx_gui::start(string const & batch, vector<string> files)
// handle the batch commands the user asked for
if (!batch.empty()) {
view.getLyXFunc()->verboseDispatch(batch, false);
view.getLyXFunc()->dispatch(batch);
}
// enter the event loop

View File

@ -27,9 +27,6 @@
using std::endl;
extern BufferView * current_view;
// The global fontloader
xfont_loader fontloader;
@ -298,8 +295,6 @@ XFontStruct * xfont_loader::doLoad(LyXFont::FONT_FAMILY family,
XFontStruct * fs = 0;
current_view->owner()->messagePush(_("Loading font into X-Server..."));
fs = XLoadQueryFont(fl_get_display(), font.c_str());
if (fs == 0) {
@ -325,8 +320,6 @@ XFontStruct * xfont_loader::doLoad(LyXFont::FONT_FAMILY family,
<< "' matched by\n" << font << endl;
}
current_view->owner()->messagePop();
fontstruct[family][series][shape][size] = fs;
return fs;
}

View File

@ -272,7 +272,7 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym,
lyxerr[Debug::KEY] << "SelfInsert arg[`"
<< argument << "']" << endl;
} else {
verboseDispatch(action, false);
dispatch(action);
}
}
@ -651,8 +651,7 @@ FuncStatus LyXFunc::getStatus(kb_action action,
default:
break;
}
}
else {
} else {
string tc = mathcursor->getLastCode();
switch (action) {
case LFUN_BOLD:
@ -685,99 +684,31 @@ FuncStatus LyXFunc::getStatus(kb_action action,
}
// temporary dispatch method
void LyXFunc::miniDispatch(string const & s)
void LyXFunc::dispatch(string const & s, bool verbose)
{
string s2(frontStrip(strip(s)));
if (!s2.empty()) {
verboseDispatch(s2, true);
}
}
void LyXFunc::verboseDispatch(string const & s, bool show_sc)
{
int action = lyxaction.LookupFunc(frontStrip(s));
int const action = lyxaction.LookupFunc(frontStrip(strip(s)));
if (action == LFUN_UNKNOWN_ACTION) {
string const msg = string(_("Unknown function ("))
+ s + ")";
owner->message(msg);
} else {
verboseDispatch(action, show_sc);
return;
}
dispatch(action, verbose);
}
void LyXFunc::verboseDispatch(int ac, bool show_sc)
void LyXFunc::dispatch(int ac, bool verbose)
{
string argument;
kb_action action;
// get the real action and argument
action = lyxaction.retrieveActionArg(ac, argument);
verboseDispatch(action, argument, show_sc);
kb_action const action = lyxaction.retrieveActionArg(ac, argument);
dispatch(action, argument, verbose);
}
void LyXFunc::verboseDispatch(kb_action action,
string const & argument, bool show_sc)
{
string res = dispatch(action, argument);
string commandshortcut;
if (show_sc && action != LFUN_SELFINSERT) {
// Put name of command and list of shortcuts
// for it in minibuffer
string comname = lyxaction.getActionName(action);
int pseudoaction = action;
bool argsadded = false;
if (!argument.empty()) {
// the pseudoaction is useful for the bindings
pseudoaction =
lyxaction.searchActionArg(action,
argument);
if (pseudoaction == LFUN_UNKNOWN_ACTION) {
pseudoaction = action;
} else {
comname += " " + argument;
argsadded = true;
}
}
string const shortcuts =
toplevel_keymap->findbinding(pseudoaction);
if (!shortcuts.empty()) {
comname += ": " + shortcuts;
} else if (!argsadded && !argument.empty()) {
comname += " " + argument;
}
if (!comname.empty()) {
comname = strip(comname);
commandshortcut = "(" + comname + ')';
}
}
if (res.empty()) {
if (!commandshortcut.empty()) {
owner->getMiniBuffer()->addSet(commandshortcut);
}
} else {
owner->getMiniBuffer()->addSet(' ' + commandshortcut);
}
}
string const LyXFunc::dispatch(kb_action action, string argument)
void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
{
lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << action
<<"] arg[" << argument << "]" << endl;
@ -1511,7 +1442,7 @@ string const LyXFunc::dispatch(kb_action action, string argument)
while (!argument.empty()) {
string first;
argument = split(argument, first, ';');
verboseDispatch(first, false);
dispatch(first);
}
}
break;
@ -1588,14 +1519,6 @@ string const LyXFunc::dispatch(kb_action action, string argument)
owner->message(argument);
break;
case LFUN_MESSAGE_PUSH:
owner->messagePush(argument);
break;
case LFUN_MESSAGE_POP:
owner->messagePop();
break;
case LFUN_FORKS_SHOW:
owner->getDialogs()->showForks();
break;
@ -1626,18 +1549,63 @@ string const LyXFunc::dispatch(kb_action action, string argument)
} // end of switch
exit_with_message:
string const res = getMessage();
if (!res.empty())
owner->message(_(res));
owner->updateMenubar();
owner->updateToolbar();
return res;
string const & msg = getMessage();
sendDispatchMessage(msg, action, argument, verbose);
}
void LyXFunc::sendDispatchMessage(string const & msg, kb_action action, string const & arg, bool verbose)
{
owner->updateMenubar();
owner->updateToolbar();
if (action == LFUN_SELFINSERT || !verbose) {
lyxerr[Debug::ACTION] << "dispatch msg is " << msg << endl;
if (!msg.empty())
owner->message(msg);
return;
}
string dispatch_msg(msg);
if (!dispatch_msg.empty())
dispatch_msg += " ";
string comname = lyxaction.getActionName(action);
int pseudoaction = action;
bool argsadded = false;
if (!arg.empty()) {
// the pseudoaction is useful for the bindings
pseudoaction = lyxaction.searchActionArg(action, arg);
if (pseudoaction == LFUN_UNKNOWN_ACTION) {
pseudoaction = action;
} else {
comname += " " + arg;
argsadded = true;
}
}
string const shortcuts = toplevel_keymap->findbinding(pseudoaction);
if (!shortcuts.empty()) {
comname += ": " + shortcuts;
} else if (!argsadded && !arg.empty()) {
comname += " " + arg;
}
if (!comname.empty()) {
comname = strip(comname);
dispatch_msg += "(" + comname + ')';
}
lyxerr[Debug::ACTION] << "verbose dispatch msg " << dispatch_msg << endl;
if (!dispatch_msg.empty())
owner->message(dispatch_msg);
}
void LyXFunc::setupLocalKeymap()
{
keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
@ -1907,48 +1875,21 @@ void LyXFunc::setStatusMessage(string const & m) const
}
void LyXFunc::initMiniBuffer()
string const LyXFunc::view_status_message()
{
string text = _("Welcome to LyX!");
// When meta-fake key is pressed, show the key sequence so far + "M-".
if (wasMetaKey()) {
text = keyseq.print();
text += "M-";
return keyseq.print() + "M-";
}
// Else, when a non-complete key sequence is pressed,
// show the available options.
if (keyseq.length() > 0 && !keyseq.deleted()) {
text = keyseq.printOptions();
return keyseq.printOptions();
}
// Else, show the buffer state.
else if (owner->view()->available()) {
Buffer * tmpbuf = owner->buffer();
string const nicename =
MakeDisplayPath(tmpbuf->fileName());
// Should we do this instead? (kindo like emacs)
// leaves more room for other information
text = "LyX: ";
text += nicename;
if (tmpbuf->lyxvc.inUse()) {
text += " [";
text += tmpbuf->lyxvc.versionString();
text += ' ';
text += tmpbuf->lyxvc.locker();
if (tmpbuf->isReadonly())
text += " (RO)";
text += ']';
} else if (tmpbuf->isReadonly())
text += " [RO]";
if (!tmpbuf->isLyxClean())
text += _(" (Changed)");
} else {
if (text != _("Welcome to LyX!")) // this is a hack
text = _("* No document open *");
}
owner->message(text);
if (!owner->view()->available())
return _("Welcome to LyX!");
return currentState(owner->view());
}

View File

@ -35,25 +35,16 @@ public:
LyXFunc(LyXView *);
/// LyX dispatcher, executes lyx actions.
string const dispatch(kb_action ac, string argument = string());
void dispatch(kb_action ac, string argument = string(), bool verbose = false);
/// The same as dispatch, but also shows shortcuts and command
/// name in minibuffer if show_sc is true (more to come?)
void verboseDispatch(kb_action action,
string const & argument,
bool show_sc);
/// Dispatch via a string argument
void dispatch(string const & s, bool verbose = false);
/// Dispatch via a pseudo action, also displaying shortcut/command name
void dispatch(int ac, bool verbose = false);
/// Same as above, using a pseudoaction as argument
void verboseDispatch(int ac, bool show_sc);
/// Same as above, when the command is provided as a string
void verboseDispatch(string const & s, bool show_sc);
///
void miniDispatch(string const & s);
///
void initMiniBuffer();
/// return the status bar state string
string const view_status_message();
///
void processKeySym(LyXKeySymPtr key, key_modifier::state state);
@ -113,6 +104,9 @@ private:
*/
mutable string status_buffer;
/// send a post-dispatch status message
void sendDispatchMessage(string const & msg, kb_action ac, string const & arg, bool verbose);
// I think the following should be moved to BufferView. (Asger)
///

View File

@ -472,7 +472,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
// support currently. (Lgb)
serv->func->verboseDispatch(cmd + ' ' + arg, false);
serv->func->dispatch(cmd + ' ' + arg);
string const rval = serv->func->getMessage();
//modified june 1999 stefano@zool.su.se: