mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
fixes/cleanup to dispatch/getStatus stuff; fixes the bug where unwanted function names appear in minibuffer
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3346 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
b44c7a6767
commit
8b8741cd5d
@ -2624,13 +2624,13 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
|
||||
if (cursor.par()->params().spaceTop() == VSpace(VSpace::NONE)) {
|
||||
lt->setParagraph
|
||||
(bv_,
|
||||
cursor.par()->params().lineTop(),
|
||||
cursor.par()->params().lineTop(),
|
||||
cursor.par()->params().lineBottom(),
|
||||
cursor.par()->params().pagebreakTop(),
|
||||
cursor.par()->params().pagebreakTop(),
|
||||
cursor.par()->params().pagebreakBottom(),
|
||||
VSpace(VSpace::DEFSKIP), cursor.par()->params().spaceBottom(),
|
||||
cursor.par()->params().spacing(),
|
||||
cursor.par()->params().align(),
|
||||
cursor.par()->params().spacing(),
|
||||
cursor.par()->params().align(),
|
||||
cursor.par()->params().labelWidthString(), 1);
|
||||
//update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
||||
}
|
||||
@ -3279,9 +3279,8 @@ void BufferView::Pimpl::specialChar(InsetSpecialChar::Kind kind)
|
||||
update(lt, BufferView::SELECT|BufferView::FITCUR);
|
||||
InsetSpecialChar * new_inset =
|
||||
new InsetSpecialChar(kind);
|
||||
insertInset(new_inset);
|
||||
// Ok, what happens here if we are unable to insert
|
||||
// the inset? Leak it?
|
||||
if (!insertInset(new_inset))
|
||||
delete new_inset;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,43 @@
|
||||
2002-01-12 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
|
||||
|
||||
* LyXAction.[Ch]: move isPseudoAction to the C file, since nobody
|
||||
should need to care about that.
|
||||
|
||||
* lyxfunc.C (verboseDispatch): simplify a bit
|
||||
(getStatus): have a version which takes a pseudoaction, and
|
||||
another which requires a (kb_action,string).
|
||||
|
||||
* LyXAction.C (retrieveActionArg): make it work also when action
|
||||
is not a pseudo-action.
|
||||
(getActionName): simplify a bit
|
||||
(helpText):
|
||||
|
||||
2002-01-11 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
|
||||
|
||||
* lyxfunc.C (verboseDispatch): new families of methods with
|
||||
several ways to specify a command and a bool to indicate whether
|
||||
the command name and shortcut should be displayed in minibuffer
|
||||
(eventually, we could extend that to a finer bitmask like
|
||||
SHORTCUT|CMDNAME|CMDRESULT, or whatever).
|
||||
(dispatch): the pristine dispatch command which just, well,
|
||||
dispatchs! Note it still sets its result to minibuffer; I'm not
|
||||
sure we want that.
|
||||
|
||||
* lyxfunc.h: remove setHintMessage
|
||||
|
||||
* vc-backend.C: use LFUN_MENURELOAD instead of "buffer-reload"
|
||||
|
||||
2002-01-10 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
|
||||
|
||||
* BufferView_pimpl.C (specialChar): delete new inset if we have
|
||||
not been able to insert it.
|
||||
|
||||
* kbmap.C: revert to using int instead of kb_action, since all we
|
||||
are dealing with is pseudo-actions.
|
||||
|
||||
* LyXAction.C (searchActionArg): change to return int instead of
|
||||
kb_action, since the result is a pseudoaction.
|
||||
|
||||
2002-01-12 Dekel Tsur <dekelts@tau.ac.il>
|
||||
|
||||
* buffer.C (insertErtContents): Fix (partially) the font bug.
|
||||
|
@ -42,6 +42,15 @@ using std::endl;
|
||||
// These are globals.
|
||||
LyXAction lyxaction;
|
||||
|
||||
// Small helper function
|
||||
inline
|
||||
bool isPseudoAction(int a)
|
||||
{
|
||||
return a > int(LFUN_LASTACTION);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LyXAction::newFunc(kb_action action, string const & name,
|
||||
string const & helpText, unsigned int attrib)
|
||||
{
|
||||
@ -448,7 +457,7 @@ LyXAction::LyXAction()
|
||||
|
||||
// Search for an existent pseudoaction, return LFUN_UNKNOWN_ACTION
|
||||
// if it doesn't exist.
|
||||
kb_action LyXAction::searchActionArg(kb_action action, string const & arg) const
|
||||
int LyXAction::searchActionArg(kb_action action, string const & arg) const
|
||||
{
|
||||
arg_map::const_iterator pit = lyx_arg_map.find(action);
|
||||
|
||||
@ -476,7 +485,7 @@ kb_action LyXAction::searchActionArg(kb_action action, string const & arg) const
|
||||
<< action << '|'
|
||||
<< arg << "] = " << aci->second << endl;
|
||||
|
||||
return kb_action(aci->second);
|
||||
return aci->second;
|
||||
}
|
||||
|
||||
|
||||
@ -516,12 +525,15 @@ kb_action LyXAction::retrieveActionArg(int pseudo, string & arg) const
|
||||
{
|
||||
arg.erase(); // clear it to be sure.
|
||||
|
||||
if (!isPseudoAction(pseudo))
|
||||
return static_cast<kb_action>(pseudo);
|
||||
|
||||
pseudo_map::const_iterator pit = lyx_pseudo_map.find(pseudo);
|
||||
|
||||
if (pit != lyx_pseudo_map.end()) {
|
||||
lyxerr[Debug::ACTION] << "Found the pseudoaction: ["
|
||||
<< pit->second.action << '|'
|
||||
<< pit->second.arg << '\n';
|
||||
<< pit->second.arg << "]\n";
|
||||
arg = pit->second.arg;
|
||||
return pit->second.action;
|
||||
} else {
|
||||
@ -601,12 +613,11 @@ string const LyXAction::getActionName(int action) const
|
||||
{
|
||||
kb_action ac;
|
||||
string arg;
|
||||
if (isPseudoAction(action)) {
|
||||
ac = retrieveActionArg(action, arg);
|
||||
arg.insert(0, " ");
|
||||
} else
|
||||
ac = static_cast<kb_action>(action);
|
||||
|
||||
ac = retrieveActionArg(action, arg);
|
||||
if (!arg.empty())
|
||||
arg.insert(0, " ");
|
||||
|
||||
info_map::const_iterator iit = lyx_info_map.find(ac);
|
||||
|
||||
if (iit != lyx_info_map.end()) {
|
||||
@ -625,10 +636,7 @@ string const LyXAction::helpText(int pseudoaction) const
|
||||
string help, arg;
|
||||
kb_action action;
|
||||
|
||||
if (isPseudoAction(pseudoaction))
|
||||
action = retrieveActionArg(pseudoaction, arg);
|
||||
else
|
||||
action = static_cast<kb_action>(pseudoaction);
|
||||
action = retrieveActionArg(pseudoaction, arg);
|
||||
|
||||
info_map::const_iterator ici = lyx_info_map.find(action);
|
||||
if (ici != lyx_info_map.end()) {
|
||||
|
@ -63,9 +63,9 @@ public:
|
||||
///
|
||||
LyXAction();
|
||||
|
||||
/** Returns an action tag from a string. Returns kb_action.
|
||||
Include arguments in func_name ONLY if you
|
||||
want to create new pseudo actions. */
|
||||
/** Returns an pseudoaction from a string
|
||||
If you include arguments in func_name, a new psedoaction will be
|
||||
created if needed. */
|
||||
int LookupFunc(string const & func_name) const;
|
||||
|
||||
/** Returns an action tag which name is the most similar to a string.
|
||||
@ -83,11 +83,8 @@ public:
|
||||
kb_action retrieveActionArg(int i, string & arg) const;
|
||||
|
||||
/// Search for an existent pseudoaction, return -1 if it doesn't exist.
|
||||
kb_action searchActionArg(kb_action action, string const & arg) const;
|
||||
int searchActionArg(kb_action action, string const & arg) const;
|
||||
|
||||
/// Check if a value is a pseudo-action.
|
||||
bool isPseudoAction(int) const;
|
||||
|
||||
/// Return the name associated with command
|
||||
string const getActionName(int action) const;
|
||||
|
||||
@ -126,14 +123,4 @@ private:
|
||||
mutable arg_map lyx_arg_map;
|
||||
};
|
||||
|
||||
|
||||
/* -------------------- Inlines ------------------ */
|
||||
|
||||
|
||||
inline
|
||||
bool LyXAction::isPseudoAction(int a) const
|
||||
{
|
||||
return a > int(LFUN_LASTACTION);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -58,7 +58,7 @@ XFormsView::XFormsView(int width, int height)
|
||||
|
||||
// Connect the minibuffer signals
|
||||
minibuffer->stringReady.connect(SigC::slot(getLyXFunc(),
|
||||
&LyXFunc::miniDispatch));
|
||||
&LyXFunc::miniDispatch));
|
||||
minibuffer->timeout.connect(SigC::slot(getLyXFunc(),
|
||||
&LyXFunc::initMiniBuffer));
|
||||
|
||||
|
@ -1,3 +1,13 @@
|
||||
2002-01-12 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
|
||||
|
||||
* Toolbar_pimpl.C (setPixmap): simplify a bit
|
||||
|
||||
2002-01-10 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
|
||||
|
||||
* Toolbar_pimpl.C (ToolbarCB):
|
||||
* Menubar_pimpl.C (MenuCallback): use verboseDispatch instead of
|
||||
dispatch.
|
||||
|
||||
2002-01-12 Allan Rae <rae@lyx.org>
|
||||
|
||||
* FormTabular.C (FormTabular): Fix Purify UMR.
|
||||
|
@ -301,11 +301,13 @@ void FormMathsPanel::insertSymbol(string const & sym) const
|
||||
lv_->getLyXFunc()->dispatch(LFUN_INSERT_MATH, '\\' + sym);
|
||||
}
|
||||
|
||||
void FormMathsPanel::dispatchFunc(string const & funcode) const
|
||||
|
||||
void FormMathsPanel::dispatchFunc(kb_action action) const
|
||||
{
|
||||
lv_->getLyXFunc()->dispatch(funcode);
|
||||
lv_->getLyXFunc()->dispatch(action);
|
||||
}
|
||||
|
||||
|
||||
void FormMathsPanel::mathDisplay() const
|
||||
{
|
||||
lv_->getLyXFunc()->dispatch(LFUN_MATH_DISPLAY);
|
||||
|
@ -12,6 +12,7 @@
|
||||
#ifndef FORM_MATHSPANEL_H
|
||||
#define FORM_MATHSPANEL_H
|
||||
|
||||
#include "commandtags.h"
|
||||
#include <boost/smart_ptr.hpp>
|
||||
|
||||
#ifdef __GNUG_
|
||||
@ -64,7 +65,7 @@ public:
|
||||
/// dispatch a symbol insert
|
||||
void insertSymbol(string const & sym) const;
|
||||
/// dispatch an LFUN:
|
||||
void dispatchFunc(string const & funcode) const;
|
||||
void dispatchFunc(kb_action action) const;
|
||||
private:
|
||||
/// Pointer to the actual instantiation of the ButtonController.
|
||||
virtual xformsBC & bc();
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "form_maths_style.h"
|
||||
|
||||
extern char * latex_mathstyle[];
|
||||
extern char * latex_mathfontcmds[];
|
||||
extern kb_action latex_mathfontcmds[];
|
||||
|
||||
FormMathsStyle::FormMathsStyle(LyXView * lv, Dialogs * d,
|
||||
FormMathsPanel const & p)
|
||||
|
@ -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()->dispatch(choice - action_offset);
|
||||
view->getLyXFunc()->verboseDispatch(choice - action_offset, true);
|
||||
} else {
|
||||
lyxerr[Debug::GUI]
|
||||
<< "MenuCallback: ignoring bogus action "
|
||||
|
@ -302,10 +302,7 @@ void ToolbarCB(FL_OBJECT * ob, long ac)
|
||||
{
|
||||
XFormsView * owner = static_cast<XFormsView *>(ob->u_vdata);
|
||||
|
||||
string res = owner->getLyXFunc()->dispatch(int(ac));
|
||||
if (!res.empty())
|
||||
lyxerr[Debug::GUI] << "ToolbarCB: Function returned: "
|
||||
<< res << endl;
|
||||
owner->getLyXFunc()->verboseDispatch(int(ac), true);
|
||||
}
|
||||
|
||||
|
||||
@ -322,20 +319,15 @@ extern "C" {
|
||||
|
||||
void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height)
|
||||
{
|
||||
string name;
|
||||
string arg;
|
||||
string xpm_name;
|
||||
kb_action act;
|
||||
|
||||
if (lyxaction.isPseudoAction(action)) {
|
||||
act = lyxaction.retrieveActionArg(action, arg);
|
||||
name = lyxaction.getActionName(act);
|
||||
const kb_action act = lyxaction.retrieveActionArg(action, arg);
|
||||
string const name = lyxaction.getActionName(act);
|
||||
if (!arg.empty())
|
||||
xpm_name = subst(name + ' ' + arg, ' ','_');
|
||||
} else {
|
||||
act = (kb_action)action;
|
||||
name = lyxaction.getActionName(action);
|
||||
else
|
||||
xpm_name = name;
|
||||
}
|
||||
|
||||
string fullname = LibFileSearch("images", xpm_name, "xpm");
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#endif
|
||||
|
||||
#include "kbmap.h"
|
||||
#include "commandtags.h"
|
||||
#include "kbsequence.h"
|
||||
#include "debug.h"
|
||||
|
||||
@ -71,7 +72,7 @@ string const kb_keymap::printKey(kb_key const & key) const
|
||||
}
|
||||
|
||||
|
||||
string::size_type kb_keymap::bind(string const & seq, kb_action action)
|
||||
string::size_type kb_keymap::bind(string const & seq, int action)
|
||||
{
|
||||
if (lyxerr.debugging(Debug::KBMAP)) {
|
||||
lyxerr << "BIND: Sequence `"
|
||||
@ -94,7 +95,7 @@ string::size_type kb_keymap::bind(string const & seq, kb_action action)
|
||||
}
|
||||
|
||||
|
||||
kb_action kb_keymap::lookup(unsigned int key,
|
||||
int kb_keymap::lookup(unsigned int key,
|
||||
unsigned int mod, kb_sequence * seq) const
|
||||
{
|
||||
if (table.empty()) {
|
||||
@ -144,7 +145,7 @@ string const kb_keymap::print() const
|
||||
}
|
||||
|
||||
|
||||
void kb_keymap::defkey(kb_sequence * seq, kb_action action, unsigned int r)
|
||||
void kb_keymap::defkey(kb_sequence * seq, int action, unsigned int r)
|
||||
{
|
||||
unsigned int const code = seq->sequence[r];
|
||||
if (code == NoSymbol) return;
|
||||
@ -193,7 +194,7 @@ void kb_keymap::defkey(kb_sequence * seq, kb_action action, unsigned int r)
|
||||
}
|
||||
|
||||
|
||||
string const kb_keymap::findbinding(kb_action act, string const & prefix) const
|
||||
string const kb_keymap::findbinding(int act, string const & prefix) const
|
||||
{
|
||||
string res;
|
||||
if (table.empty()) return res;
|
||||
|
14
src/kbmap.h
14
src/kbmap.h
@ -16,8 +16,6 @@
|
||||
#include <list>
|
||||
#include <boost/smart_ptr.hpp>
|
||||
|
||||
#include "commandtags.h"
|
||||
|
||||
#include "LString.h"
|
||||
|
||||
class kb_sequence;
|
||||
@ -30,7 +28,7 @@ public:
|
||||
* @return 0 on success, or position in string seq where error
|
||||
* occurs.
|
||||
*/
|
||||
string::size_type bind(string const & seq, kb_action action);
|
||||
string::size_type bind(string const & seq, int action);
|
||||
|
||||
/// print all available keysyms
|
||||
string const print() const;
|
||||
@ -42,11 +40,11 @@ public:
|
||||
* @param seq the current key sequence so far
|
||||
* @return the action / LFUN_PREFIX / LFUN_UNKNOWN_ACTION
|
||||
*/
|
||||
kb_action lookup(unsigned int key,
|
||||
unsigned int mod, kb_sequence * seq) const;
|
||||
int lookup(unsigned int key,
|
||||
unsigned int mod, kb_sequence * seq) const;
|
||||
|
||||
/// Given an action, find all keybindings.
|
||||
string const findbinding(kb_action action,
|
||||
string const findbinding(int action,
|
||||
string const & prefix = string()) const;
|
||||
|
||||
/**
|
||||
@ -72,7 +70,7 @@ private:
|
||||
boost::shared_ptr<kb_keymap> table;
|
||||
|
||||
/// Action for !prefix keys
|
||||
kb_action action;
|
||||
int action;
|
||||
};
|
||||
|
||||
|
||||
@ -80,7 +78,7 @@ private:
|
||||
* Define an action for a key sequence.
|
||||
* @param r internal recursion level
|
||||
*/
|
||||
void defkey(kb_sequence * seq, kb_action action, unsigned int r = 0);
|
||||
void defkey(kb_sequence * seq, int action, unsigned int r = 0);
|
||||
|
||||
/// Returns a string of the given key
|
||||
string const printKey(kb_key const & key) const;
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "kbsequence.h"
|
||||
#include "kbmap.h"
|
||||
#include "commandtags.h"
|
||||
#include "debug.h"
|
||||
|
||||
using std::endl;
|
||||
@ -29,7 +30,7 @@ using std::endl;
|
||||
enum { ModsMask = ShiftMask | ControlMask | Mod1Mask };
|
||||
|
||||
|
||||
kb_action kb_sequence::addkey(unsigned int key, unsigned int mod, unsigned int nmod)
|
||||
int kb_sequence::addkey(unsigned int key, unsigned int mod, unsigned int nmod)
|
||||
{
|
||||
// adding a key to a deleted sequence
|
||||
// starts a new sequence
|
||||
|
@ -15,8 +15,6 @@
|
||||
#include <vector>
|
||||
#include "LString.h"
|
||||
|
||||
#include "commandtags.h"
|
||||
|
||||
class kb_keymap;
|
||||
|
||||
/// Holds a key sequence and the current and standard keymaps
|
||||
@ -37,7 +35,7 @@ public:
|
||||
* @param nmod which modifiers to mask out for equality test
|
||||
* @return the action matching this key sequence or LFUN_UNKNOWN_ACTION
|
||||
*/
|
||||
kb_action addkey(unsigned int key, unsigned int mod, unsigned int nmod = 0);
|
||||
int addkey(unsigned int key, unsigned int mod, unsigned int nmod = 0);
|
||||
|
||||
/**
|
||||
* Add a sequence of keys from a string to the sequence
|
||||
|
@ -167,7 +167,7 @@ LyX::LyX(int * argc, char * argv[])
|
||||
|
||||
// otherwise, let the GUI handle the batch command
|
||||
lyxGUI->regBuf(last_loaded);
|
||||
lyxGUI->getLyXView()->getLyXFunc()->dispatch(batch_command);
|
||||
lyxGUI->getLyXView()->getLyXFunc()->verboseDispatch(batch_command, false);
|
||||
|
||||
// fall through...
|
||||
}
|
||||
|
207
src/lyxfunc.C
207
src/lyxfunc.C
@ -158,9 +158,6 @@ MiniBufferController mb_ctrl;
|
||||
|
||||
/* === globals =========================================================== */
|
||||
|
||||
// Initialization of static member var
|
||||
bool LyXFunc::show_sc = true;
|
||||
|
||||
|
||||
LyXFunc::LyXFunc(LyXView * o)
|
||||
: owner(o),
|
||||
@ -325,45 +322,37 @@ void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
|
||||
if (action == LFUN_SELFINSERT) {
|
||||
// This is very X dependent.
|
||||
unsigned int c = keysym;
|
||||
string argument;
|
||||
|
||||
c = kb_keymap::getiso(c);
|
||||
|
||||
if (c > 0)
|
||||
argument = static_cast<char>(c);
|
||||
|
||||
dispatch(LFUN_SELFINSERT, argument);
|
||||
lyxerr[Debug::KEY] << "SelfInsert arg[`"
|
||||
<< argument << "']" << endl;
|
||||
}
|
||||
|
||||
bool tmp_sc = show_sc;
|
||||
show_sc = false;
|
||||
dispatch(action, argument);
|
||||
show_sc = tmp_sc;
|
||||
|
||||
//return 0;
|
||||
else
|
||||
verboseDispatch(action, false);
|
||||
}
|
||||
|
||||
|
||||
FuncStatus LyXFunc::getStatus(int ac) const
|
||||
{
|
||||
return getStatus(ac, string());
|
||||
kb_action action;
|
||||
string argument;
|
||||
action = lyxaction.retrieveActionArg(ac, argument);
|
||||
return getStatus(action, argument);
|
||||
}
|
||||
|
||||
FuncStatus LyXFunc::getStatus(int ac,
|
||||
string const & not_to_use_arg) const
|
||||
|
||||
FuncStatus LyXFunc::getStatus(kb_action action,
|
||||
string const & argument) const
|
||||
{
|
||||
kb_action action;
|
||||
FuncStatus flag;
|
||||
string argument;
|
||||
Buffer * buf = owner->buffer();
|
||||
|
||||
if (lyxaction.isPseudoAction(ac))
|
||||
action = lyxaction.retrieveActionArg(ac, argument);
|
||||
else {
|
||||
action = static_cast<kb_action>(ac);
|
||||
if (!not_to_use_arg.empty())
|
||||
argument = not_to_use_arg; // except here
|
||||
}
|
||||
|
||||
if (action == LFUN_UNKNOWN_ACTION) {
|
||||
setErrorMessage(N_("Unknown action"));
|
||||
return flag.unknown(true);
|
||||
@ -435,7 +424,7 @@ FuncStatus LyXFunc::getStatus(int ac,
|
||||
disable = true;
|
||||
if (owner->view()->theLockingInset()) {
|
||||
FuncStatus ret;
|
||||
ret.disabled(true);
|
||||
//ret.disabled(true);
|
||||
if (owner->view()->theLockingInset()->lyxCode() == Inset::TABULAR_CODE) {
|
||||
ret = static_cast<InsetTabular *>
|
||||
(owner->view()->theLockingInset())->
|
||||
@ -760,12 +749,12 @@ void LyXFunc::miniDispatch(string const & s)
|
||||
string s2(frontStrip(strip(s)));
|
||||
|
||||
if (!s2.empty()) {
|
||||
dispatch(s2);
|
||||
verboseDispatch(s2, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string const LyXFunc::dispatch(string const & s)
|
||||
void const LyXFunc::verboseDispatch(string const & s, bool show_sc)
|
||||
{
|
||||
// Split command string into command and argument
|
||||
string cmd;
|
||||
@ -778,57 +767,107 @@ string const LyXFunc::dispatch(string const & s)
|
||||
string const msg = string(_("Unknown function ("))
|
||||
+ cmd + ")";
|
||||
owner->message(msg);
|
||||
return string();
|
||||
} else {
|
||||
return dispatch(action, arg);
|
||||
verboseDispatch(action, show_sc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string const LyXFunc::dispatch(int ac,
|
||||
string const & do_not_use_this_arg)
|
||||
void const LyXFunc::verboseDispatch(int ac, bool show_sc)
|
||||
{
|
||||
lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << ac
|
||||
<<"] arg[" << do_not_use_this_arg << "]" << endl;
|
||||
|
||||
string argument;
|
||||
kb_action action;
|
||||
|
||||
// get the real action and argument
|
||||
action = lyxaction.retrieveActionArg(ac, argument);
|
||||
|
||||
verboseDispatch(action, argument, show_sc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void const LyXFunc::verboseDispatch(kb_action action,
|
||||
string const & argument, bool show_sc)
|
||||
{
|
||||
string res = dispatch(action, argument);
|
||||
|
||||
commandshortcut.erase();
|
||||
|
||||
if (lyxrc.display_shortcuts && show_sc) {
|
||||
if (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)
|
||||
{
|
||||
lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << action
|
||||
<<"] arg[" << argument << "]" << endl;
|
||||
|
||||
// we have not done anything wrong yet.
|
||||
errorstat = false;
|
||||
dispatch_buffer.erase();
|
||||
|
||||
// if action is a pseudo-action, we need the real action
|
||||
if (lyxaction.isPseudoAction(ac)) {
|
||||
string tmparg;
|
||||
action = static_cast<kb_action>
|
||||
(lyxaction.retrieveActionArg(ac, tmparg));
|
||||
if (!tmparg.empty())
|
||||
argument = tmparg;
|
||||
} else {
|
||||
action = static_cast<kb_action>(ac);
|
||||
if (!do_not_use_this_arg.empty())
|
||||
argument = do_not_use_this_arg; // except here
|
||||
}
|
||||
|
||||
|
||||
#ifdef NEW_DISPATCHER
|
||||
// We try do call the most specific dispatcher first:
|
||||
// 1. the lockinginset's dispatch
|
||||
// 2. the bufferview's dispatch
|
||||
// 3. the lyxview's dispatch
|
||||
#endif
|
||||
|
||||
|
||||
selection_possible = false;
|
||||
|
||||
|
||||
if (owner->view()->available())
|
||||
owner->view()->hideCursor();
|
||||
|
||||
// We cannot use this function here
|
||||
if (getStatus(ac, do_not_use_this_arg).disabled()) {
|
||||
if (getStatus(action, argument).disabled()) {
|
||||
lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: "
|
||||
<< lyxaction.getActionName(ac)
|
||||
<< " [" << ac << "] is disabled at this location"
|
||||
<< lyxaction.getActionName(action)
|
||||
<< " [" << action << "] is disabled at this location"
|
||||
<< endl;
|
||||
goto exit_with_message;
|
||||
}
|
||||
@ -838,7 +877,8 @@ string const LyXFunc::dispatch(int ac,
|
||||
if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
|
||||
(!keyseq.deleted())))
|
||||
{
|
||||
if ((action==LFUN_UNKNOWN_ACTION) && argument.empty()){
|
||||
if ((action == LFUN_UNKNOWN_ACTION)
|
||||
&& argument.empty()){
|
||||
argument = keyseq.getiso();
|
||||
}
|
||||
// Undo/Redo is a bit tricky for insets.
|
||||
@ -1509,7 +1549,7 @@ string const LyXFunc::dispatch(int ac,
|
||||
while (argument.find(';') != string::npos) {
|
||||
string first;
|
||||
argument = split(argument, first, ';');
|
||||
dispatch(first);
|
||||
verboseDispatch(first, false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1588,65 +1628,10 @@ string const LyXFunc::dispatch(int ac,
|
||||
|
||||
exit_with_message:
|
||||
|
||||
commandshortcut.erase();
|
||||
|
||||
if (lyxrc.display_shortcuts && show_sc) {
|
||||
if (action != LFUN_SELFINSERT) {
|
||||
// Put name of command and list of shortcuts
|
||||
// for it in minibuffer
|
||||
string comname = lyxaction.getActionName(action);
|
||||
|
||||
kb_action pseudoaction = action;
|
||||
bool argsadded = false;
|
||||
|
||||
if (!argument.empty()) {
|
||||
// If we have the command with argument,
|
||||
// this is better
|
||||
pseudoaction =
|
||||
lyxaction.searchActionArg(action,
|
||||
argument);
|
||||
|
||||
if (pseudoaction == -1) {
|
||||
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 + ')';
|
||||
|
||||
// Here we could even add a small pause,
|
||||
// to annoy the user and make him learn
|
||||
// the shortcuts.
|
||||
// No! That will just annoy, not teach
|
||||
// anything. The user will read the messages
|
||||
// if they are interested. (Asger)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string const res = getMessage();
|
||||
|
||||
if (res.empty()) {
|
||||
if (!commandshortcut.empty()) {
|
||||
owner->getMiniBuffer()->addSet(commandshortcut);
|
||||
}
|
||||
} else {
|
||||
string const msg(_(res) + ' ' + commandshortcut);
|
||||
owner->message(msg);
|
||||
}
|
||||
if (!res.empty())
|
||||
owner->message(_(res));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -31,13 +31,22 @@ public:
|
||||
LyXFunc(LyXView *);
|
||||
|
||||
/// LyX dispatcher, executes lyx actions.
|
||||
string const dispatch(int action, string const & arg = string());
|
||||
|
||||
/// The same but uses the name of a lyx command.
|
||||
string const dispatch(string const & cmd);
|
||||
string const dispatch(kb_action ac, string argument = string());
|
||||
|
||||
///
|
||||
void miniDispatch(string const & cmd);
|
||||
/// The same as dispatch, but also shows shortcuts and command
|
||||
/// name in minibuffer if show_sc is true (more to come?)
|
||||
void const LyXFunc::verboseDispatch(kb_action action,
|
||||
string const & argument,
|
||||
bool show_sc);
|
||||
|
||||
/// Same as above, using a pseudoaction as argument
|
||||
void const LyXFunc::verboseDispatch(int ac, bool show_sc);
|
||||
|
||||
/// Same as above, when the command is provided as a string
|
||||
void const LyXFunc::verboseDispatch(string const & s, bool show_sc);
|
||||
|
||||
///
|
||||
void LyXFunc::miniDispatch(string const & s);
|
||||
|
||||
///
|
||||
void initMiniBuffer();
|
||||
@ -45,12 +54,12 @@ public:
|
||||
///
|
||||
void processKeySym(KeySym k, unsigned int state);
|
||||
|
||||
/// we need one internall which is called from inside LyXAction and
|
||||
/// we need one internal which is called from inside LyXAction and
|
||||
/// can contain the string argument.
|
||||
FuncStatus getStatus(int ac) const;
|
||||
///
|
||||
FuncStatus getStatus(int ac,
|
||||
string const & not_to_use_arg) const;
|
||||
FuncStatus getStatus(kb_action action,
|
||||
string const & argument = string()) const;
|
||||
|
||||
/// The last key was meta
|
||||
bool wasMetaKey() const;
|
||||
@ -65,8 +74,7 @@ public:
|
||||
string const getMessage() const { return dispatch_buffer; }
|
||||
/// Handle a accented char keysequenze
|
||||
void handleKeyFunc(kb_action action);
|
||||
/// Should a hint message be displayed?
|
||||
void setHintMessage(bool);
|
||||
|
||||
private:
|
||||
///
|
||||
LyXView * owner;
|
||||
@ -116,8 +124,6 @@ private:
|
||||
///
|
||||
LyXText * TEXT(bool) const;
|
||||
///
|
||||
// This is the same for all lyxfunc objects
|
||||
static bool show_sc;
|
||||
};
|
||||
|
||||
|
||||
@ -130,10 +136,4 @@ bool LyXFunc::wasMetaKey() const
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
void LyXFunc::setHintMessage(bool hm)
|
||||
{
|
||||
show_sc = hm;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -501,7 +501,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
|
||||
// connect to the lyxfunc in the single LyXView we
|
||||
// support currently. (Lgb)
|
||||
|
||||
int action = lyxaction.LookupFunc(cmd);
|
||||
kb_action action = static_cast<kb_action>(lyxaction.LookupFunc(cmd));
|
||||
//int action = -1;
|
||||
string rval, buf;
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
2002-01-10 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
|
||||
|
||||
* math_support.C: change latex_mathfontcmds to an array of
|
||||
kb_action.
|
||||
|
||||
2002-01-11 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* math_exfuncinset.C: remove using std::ostream declaration.
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "math_parser.h"
|
||||
#include "Painter.h"
|
||||
#include "debug.h"
|
||||
#include "commandtags.h"
|
||||
|
||||
using std::map;
|
||||
using std::endl;
|
||||
@ -781,9 +782,9 @@ char const * latex_mathstyle[] = {
|
||||
"textstyle", "displaystyle", "scriptstyle", "scriptscriptstyle"
|
||||
};
|
||||
|
||||
char const * latex_mathfontcmds[] = {
|
||||
"font-bold", "font-emph", "font-roman", "font-code", "font-sans",
|
||||
"font-ital", "font-noun", "font-frak", "font-free", "font-default"
|
||||
kb_action latex_mathfontcmds[] = {
|
||||
LFUN_BOLD, LFUN_EMPH, LFUN_ROMAN, LFUN_CODE, LFUN_SANS,
|
||||
LFUN_ITAL, LFUN_NOUN, LFUN_FRAK, LFUN_FREE, LFUN_DEFAULT
|
||||
};
|
||||
|
||||
|
||||
|
@ -150,7 +150,7 @@ void RCS::registrer(string const & msg)
|
||||
cmd += OnlyFilename(owner_->fileName());
|
||||
cmd += "\"";
|
||||
doVCCommand(cmd, owner_->filepath);
|
||||
owner_->getUser()->owner()->getLyXFunc()->dispatch("buffer-reload");
|
||||
owner_->getUser()->owner()->getLyXFunc()->dispatch(LFUN_MENURELOAD);
|
||||
}
|
||||
|
||||
|
||||
@ -158,7 +158,7 @@ void RCS::checkIn(string const & msg)
|
||||
{
|
||||
doVCCommand("ci -q -u -m\"" + msg + "\" \""
|
||||
+ OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
|
||||
owner_->getUser()->owner()->getLyXFunc()->dispatch("buffer-reload");
|
||||
owner_->getUser()->owner()->getLyXFunc()->dispatch(LFUN_MENURELOAD);
|
||||
}
|
||||
|
||||
|
||||
@ -167,7 +167,7 @@ void RCS::checkOut()
|
||||
owner_->markLyxClean();
|
||||
doVCCommand("co -q -l \""
|
||||
+ OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
|
||||
owner_->getUser()->owner()->getLyXFunc()->dispatch("buffer-reload");
|
||||
owner_->getUser()->owner()->getLyXFunc()->dispatch(LFUN_MENURELOAD);
|
||||
}
|
||||
|
||||
|
||||
@ -178,7 +178,7 @@ void RCS::revert()
|
||||
// We ignore changes and just reload!
|
||||
owner_->markLyxClean();
|
||||
owner_->getUser()->owner()
|
||||
->getLyXFunc()->dispatch("buffer-reload");
|
||||
->getLyXFunc()->dispatch(LFUN_MENURELOAD);
|
||||
}
|
||||
|
||||
|
||||
@ -280,7 +280,7 @@ void CVS::registrer(string const & msg)
|
||||
{
|
||||
doVCCommand("cvs -q add -m \"" + msg + "\" \""
|
||||
+ OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
|
||||
owner_->getUser()->owner()->getLyXFunc()->dispatch("buffer-reload");
|
||||
owner_->getUser()->owner()->getLyXFunc()->dispatch(LFUN_MENURELOAD);
|
||||
}
|
||||
|
||||
|
||||
@ -289,7 +289,7 @@ void CVS::checkIn(string const & msg)
|
||||
doVCCommand("cvs -q commit -m \"" + msg + "\" \""
|
||||
+ OnlyFilename(owner_->fileName()) + "\"",
|
||||
owner_->filepath);
|
||||
owner_->getUser()->owner()->getLyXFunc()->dispatch("buffer-reload");
|
||||
owner_->getUser()->owner()->getLyXFunc()->dispatch(LFUN_MENURELOAD);
|
||||
}
|
||||
|
||||
|
||||
@ -310,7 +310,7 @@ void CVS::revert()
|
||||
owner_->filepath);
|
||||
owner_->markLyxClean();
|
||||
owner_->getUser()->owner()
|
||||
->getLyXFunc()->dispatch("buffer-reload");
|
||||
->getLyXFunc()->dispatch(LFUN_MENURELOAD);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user