void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state)
{
- string argument;
-
- if (lyxerr.debugging(Debug::KEY)) {
- lyxerr << "KeySym is "
- << keysym->getSymbolName()
- << endl;
- }
+ lyxerr[Debug::KEY] << "KeySym is " << keysym->getSymbolName() << endl;
// Do nothing if we have nothing (JMarc)
if (!keysym->isOK()) {
if (encoded_last_key != 0) {
string arg;
arg += encoded_last_key;
+ lyxerr << "SelfInsert arg[`"
+ << arg << "']" << endl;
dispatch(FuncRequest(LFUN_SELFINSERT, arg));
- lyxerr[Debug::KEY] << "SelfInsert arg[`"
- << argument << "']" << endl;
+ lyxerr[Debug::KEY]
+ << "SelfInsert arg[`" << arg << "']" << endl;
}
} else {
dispatch(func);
code = InsetOld::SPACE_CODE;
break;
case LFUN_INSET_DIALOG_SHOW: {
- InsetBase * inset = view()->getLyXText()->getInset();
+ InsetBase * inset = view()->cursor().nextInset();
disable = !inset;
if (inset) {
code = inset->lyxCode();
} //namespace anon
-void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
+void LyXFunc::dispatch(FuncRequest const & cmd, bool verbose)
{
- string argument = func.argument;
- kb_action action = func.action;
+ string argument = cmd.argument;
+ kb_action action = cmd.action;
- //lyxerr[Debug::ACTION] << "LyXFunc::dispatch: cmd: " << func << endl;
- lyxerr << "LyXFunc::dispatch: cmd: " << func << endl;
+ lyxerr[Debug::ACTION] << "LyXFunc::dispatch: cmd: " << cmd << endl;
+ //lyxerr << "*** LyXFunc::dispatch: cmd: " << cmd << endl;
// we have not done anything wrong yet.
errorstat = false;
dispatch_buffer.erase();
-
-#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;
// We cannot use this function here
- if (getStatus(func).disabled()) {
+ if (getStatus(cmd).disabled()) {
lyxerr[Debug::ACTION] << "LyXFunc::dispatch: "
<< lyxaction.getActionName(action)
<< " [" << action << "] is disabled at this location"
<< " found." << endl;
}
- par.lockPath(view());
- LyXText * lt = par.text(*view()->buffer());
-
// Set the cursor
- lt->setCursor(par.pit(), 0);
+ view()->setCursor(par, 0);
+
view()->switchKeyMap();
owner->view_state_changed();
break;
case LFUN_DIALOG_SHOW: {
- string const name = func.getArg(0);
- string data = trim(func.argument.substr(name.size()));
+ string const name = cmd.getArg(0);
+ string data = trim(cmd.argument.substr(name.size()));
if (name == "character") {
data = freefont2string();
}
case LFUN_DIALOG_SHOW_NEW_INSET: {
- string const name = func.getArg(0);
- string data = trim(func.argument.substr(name.size()));
+ string const name = cmd.getArg(0);
+ string data = trim(cmd.argument.substr(name.size()));
if (name == "bibitem" ||
name == "bibtex" ||
name == "include" ||
break;
case LFUN_INSET_DIALOG_SHOW: {
- InsetBase * inset = view()->getLyXText()->getInset();
+ InsetBase * inset = view()->cursor().nextInset();
if (inset)
inset->dispatch(view()->cursor(), FuncRequest(LFUN_INSET_DIALOG_SHOW));
break;
// Can only update a dialog connected to an existing inset
InsetBase * inset = owner->getDialogs().getOpenInset(name);
if (inset) {
- FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, func.argument);
+ FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, cmd.argument);
inset->dispatch(view()->cursor(), fr);
} else if (name == "paragraph") {
dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
break;
default:
- view()->cursor().dispatch(FuncRequest(func));
+ DispatchResult res = view()->cursor().dispatch(cmd);
+ if (!res.dispatched());
+ view()->dispatch(cmd);
break;
}
}
- view()->owner()->updateLayoutChoice();
+ if (!view()->cursor().inMathed())
+ view()->owner()->updateLayoutChoice();
if (view()->available()) {
view()->fitCursor();
view()->update();
view()->cursor().updatePos();
// if we executed a mutating lfun, mark the buffer as dirty
- if (!getStatus(func).disabled()
- && !lyxaction.funcHasFlag(func.action, LyXAction::NoBuffer)
- && !lyxaction.funcHasFlag(func.action, LyXAction::ReadOnly))
+ if (!getStatus(cmd).disabled()
+ && !lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)
+ && !lyxaction.funcHasFlag(cmd.action, LyXAction::ReadOnly))
view()->buffer()->markDirty();
}
- sendDispatchMessage(getMessage(), func, verbose);
+ if (!view()->cursor().inMathed())
+ sendDispatchMessage(getMessage(), cmd, verbose);
}
void LyXFunc::sendDispatchMessage(string const & msg,
- FuncRequest const & func, bool verbose)
+ FuncRequest const & cmd, bool verbose)
{
owner->updateMenubar();
owner->updateToolbar();
- if (func.action == LFUN_SELFINSERT || !verbose) {
+ if (cmd.action == LFUN_SELFINSERT || !verbose) {
lyxerr[Debug::ACTION] << "dispatch msg is " << msg << endl;
if (!msg.empty())
owner->message(msg);
if (!dispatch_msg.empty())
dispatch_msg += ' ';
- string comname = lyxaction.getActionName(func.action);
+ string comname = lyxaction.getActionName(cmd.action);
bool argsadded = false;
- if (!func.argument.empty()) {
- if (func.action != LFUN_UNKNOWN_ACTION) {
- comname += ' ' + func.argument;
+ if (!cmd.argument.empty()) {
+ if (cmd.action != LFUN_UNKNOWN_ACTION) {
+ comname += ' ' + cmd.argument;
argsadded = true;
}
}
- string const shortcuts = toplevel_keymap->findbinding(func);
+ string const shortcuts = toplevel_keymap->findbinding(cmd);
if (!shortcuts.empty()) {
comname += ": " + shortcuts;
- } else if (!argsadded && !func.argument.empty()) {
- comname += ' ' + func.argument;
+ } else if (!argsadded && !cmd.argument.empty()) {
+ comname += ' ' + cmd.argument;
}
if (!comname.empty()) {
// Each "owner" should have it's own message method. lyxview and
// the minibuffer would use the minibuffer, but lyxserver would
// send an ERROR signal to its client. Alejandro 970603
-// This func is bit problematic when it comes to NLS, to make the
+// This function is bit problematic when it comes to NLS, to make the
// lyx servers client be language indepenent we must not translate
// strings sent to this func.
void LyXFunc::setErrorMessage(string const & m) const