X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxfunc.C;h=5ca26ab25748ad788cd2e22aa87d8b57d28eb4ae;hb=097595d63c8fc0b3e6c17af7545100247f4ee57d;hp=adfe50ce56f93e9fc323694f72c12155baa3826c;hpb=c890dfa0f8e80f10e8ad9b899867c7810d4895e1;p=lyx.git diff --git a/src/lyxfunc.C b/src/lyxfunc.C index adfe50ce56..5ca26ab257 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -379,6 +379,8 @@ FuncStatus LyXFunc::getStatus(kb_action action, } } + UpdatableInset * tli = owner->view()->theLockingInset(); + // I would really like to avoid having this switch and rather try to // encode this in the function itself. bool disable = false; @@ -413,27 +415,30 @@ FuncStatus LyXFunc::getStatus(kb_action action, break; case LFUN_LAYOUT_TABULAR: - disable = true; - if (owner->view()->theLockingInset()) { - disable = (owner->view()->theLockingInset()->lyxCode() != Inset::TABULAR_CODE) && - !owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE); - } + disable = !tli + || (tli->lyxCode() != Inset::TABULAR_CODE + && !tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE)); + break; + + case LFUN_LAYOUT: + case LFUN_LAYOUT_PARAGRAPH: { + Inset * inset = TEXT(false)->cursor.par()->inInset(); + disable = inset && inset->forceDefaultParagraphs(inset); break; + } case LFUN_TABULAR_FEATURE: disable = true; - if (owner->view()->theLockingInset()) { + if (tli) { FuncStatus ret; //ret.disabled(true); - if (owner->view()->theLockingInset()->lyxCode() == Inset::TABULAR_CODE) { - ret = static_cast - (owner->view()->theLockingInset())-> - getStatus(argument); - } else if (owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) { + if (tli->lyxCode() == Inset::TABULAR_CODE) { + ret = static_cast(tli) + ->getStatus(argument); + } else if (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) { ret = static_cast - (owner->view()->theLockingInset()-> - getFirstLockingInsetOfType(Inset::TABULAR_CODE))-> - getStatus(argument); + (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) + ->getStatus(argument); } flag |= ret; disable = false; @@ -443,7 +448,8 @@ FuncStatus LyXFunc::getStatus(kb_action action, disable = true; ret = inset.getStatus(argument); - if (ret.onoff(true) || ret.onoff(false)) flag.setOnOff(false); + if (ret.onoff(true) || ret.onoff(false)) + flag.setOnOff(false); } break; @@ -471,13 +477,7 @@ FuncStatus LyXFunc::getStatus(kb_action action, disable = (TEXT(false)->getInset() == 0); break; - case LFUN_MATH_VALIGN: { - // I think this test can be simplified (Andre') - // mathcursor is != 0 iff we are in math mode - //Inset * tli = owner->view()->theLockingInset(); - //if (tli && (tli->lyxCode() == Inset::MATH_CODE - // || tli->lyxCode() == Inset::MATHMACRO_CODE)) { - // + case LFUN_MATH_VALIGN: if (mathcursor) { char align = mathcursor->valign(); if (align == '\0') { @@ -496,11 +496,8 @@ FuncStatus LyXFunc::getStatus(kb_action action, } else disable = true; break; - } - case LFUN_MATH_HALIGN: { - //Inset * tli = owner->view()->theLockingInset(); - //if (tli && (tli->lyxCode() == Inset::MATH_CODE - // || tli->lyxCode() == Inset::MATHMACRO_CODE)) { + + case LFUN_MATH_HALIGN: if (mathcursor) { char align = mathcursor->halign(); if (align == '\0') { @@ -519,9 +516,8 @@ FuncStatus LyXFunc::getStatus(kb_action action, } else disable = true; break; - } - case LFUN_MATH_MUTATE: { - Inset * tli = owner->view()->theLockingInset(); + + case LFUN_MATH_MUTATE: if (tli && (tli->lyxCode() == Inset::MATH_CODE)) { MathInsetTypes type = mathcursor->formula()->getType(); if (argument == "inline") { @@ -538,7 +534,6 @@ FuncStatus LyXFunc::getStatus(kb_action action, } else disable = true; break; - } // we just need to be in math mode to enable that case LFUN_MATH_SIZE: @@ -663,9 +658,7 @@ FuncStatus LyXFunc::getStatus(kb_action action, default: break; } - if (code != Inset::NO_CODE - && owner->view()->theLockingInset() - && !owner->view()->theLockingInset()->insetAllowed(code)) { + if (code != Inset::NO_CODE && tli && !tli->insetAllowed(code)) { disable = true; } @@ -754,18 +747,13 @@ void LyXFunc::miniDispatch(string const & s) } -void const LyXFunc::verboseDispatch(string const & s, bool show_sc) +void LyXFunc::verboseDispatch(string const & s, bool show_sc) { - // Split command string into command and argument - string cmd; - string line = frontStrip(s); - string const arg = strip(frontStrip(split(line, cmd, ' '))); - - int action = lyxaction.LookupFunc(cmd); + int action = lyxaction.LookupFunc(frontStrip(s)); if (action == LFUN_UNKNOWN_ACTION) { string const msg = string(_("Unknown function (")) - + cmd + ")"; + + s + ")"; owner->message(msg); } else { verboseDispatch(action, show_sc); @@ -773,7 +761,7 @@ void const LyXFunc::verboseDispatch(string const & s, bool show_sc) } -void const LyXFunc::verboseDispatch(int ac, bool show_sc) +void LyXFunc::verboseDispatch(int ac, bool show_sc) { string argument; kb_action action; @@ -786,8 +774,8 @@ void const LyXFunc::verboseDispatch(int ac, bool show_sc) -void const LyXFunc::verboseDispatch(kb_action action, - string const & argument, bool show_sc) +void LyXFunc::verboseDispatch(kb_action action, + string const & argument, bool show_sc) { string res = dispatch(action, argument); @@ -1402,7 +1390,7 @@ string const LyXFunc::dispatch(kb_action action, string argument) case LFUN_GOTO_PARAGRAPH: { - istringstream istr(argument.c_str()); + istringstream istr(argument.c_str()); int id; istr >> id; @@ -1416,8 +1404,13 @@ string const LyXFunc::dispatch(kb_action action, string argument) << " found." << endl; } + if (owner->view()->theLockingInset()) + owner->view()->unlockInset(owner->view()->theLockingInset()); + if (par->inInset()) { + par->inInset()->edit(owner->view()); + } // Set the cursor - owner->view()->text->setCursor(owner->view(), par, 0); + owner->view()->getLyXText()->setCursor(owner->view(), par, 0); owner->view()->setState(); owner->showState(); @@ -1513,7 +1506,7 @@ string const LyXFunc::dispatch(kb_action action, string argument) { string const filename = MakeAbsPath(argument, - OnlyPath(owner->buffer()->fileName())); + owner->buffer()->filePath()); setMessage(N_("Opening child document ") + MakeDisplayPath(filename) + "..."); owner->view()->savePosition(0); @@ -1652,7 +1645,7 @@ void LyXFunc::menuNew(bool fromTemplate) string initpath = lyxrc.document_path; if (owner->view()->available()) { - string const trypath = owner->buffer()->filepath; + string const trypath = owner->buffer()->filePath(); // If directory is writeable, use this as default. if (IsDirWriteable(trypath)) initpath = trypath; @@ -1778,7 +1771,7 @@ void LyXFunc::open(string const & fname) string initpath = lyxrc.document_path; if (owner->view()->available()) { - string const trypath = owner->buffer()->filepath; + string const trypath = owner->buffer()->filePath(); // If directory is writeable, use this as default. if (IsDirWriteable(trypath)) initpath = trypath; @@ -1855,7 +1848,7 @@ void LyXFunc::doImport(string const & argument) string initpath = lyxrc.document_path; if (owner->view()->available()) { - string const trypath = owner->buffer()->filepath; + string const trypath = owner->buffer()->filePath(); // If directory is writeable, use this as default. if (IsDirWriteable(trypath)) initpath = trypath;