X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxfunc.C;h=26a1b6aae34ee20166b5e8bd1e6852d7bdbe276f;hb=1ff9cadb81d675f3192315600fd949e7927a64d6;hp=d1c33e2d14a49c4a21bd12c67b6da5a760810157;hpb=97ef9131ba95f605a48d09595bd2ace0f993a55b;p=lyx.git diff --git a/src/lyxfunc.C b/src/lyxfunc.C index d1c33e2d14..26a1b6aae3 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -269,7 +269,7 @@ void LyXFunc::processKeySym(KeySym keysym, key_modifier::state state) lyxerr << "meta_fake_bit is [" << meta_fake_bit << "]" << endl; } -#endif +#endif // remove Caps Lock and Mod2 as a modifiers action = keyseq.addkey(keysym, (state | meta_fake_bit)); if (lyxerr.debugging(Debug::KEY)) { @@ -487,7 +487,7 @@ FuncStatus LyXFunc::getStatus(kb_action action, break; } case LFUN_MATH_VALIGN: - if (mathcursor) { + if (mathcursor && mathcursor->formula()->getType() != LM_OT_SIMPLE) { char align = mathcursor->valign(); if (align == '\0') { disable = true; @@ -507,7 +507,7 @@ FuncStatus LyXFunc::getStatus(kb_action action, break; case LFUN_MATH_HALIGN: - if (mathcursor) { + if (mathcursor && mathcursor->formula()->getType() != LM_OT_SIMPLE) { char align = mathcursor->halign(); if (align == '\0') { disable = true; @@ -537,6 +537,8 @@ FuncStatus LyXFunc::getStatus(kb_action action, flag.setOnOff(type == LM_OT_EQNARRAY); } else if (argument == "align") { flag.setOnOff(type == LM_OT_ALIGN); + } else if (argument == "none") { + flag.setOnOff(type == LM_OT_NONE); } else { disable = true; } @@ -559,7 +561,8 @@ FuncStatus LyXFunc::getStatus(kb_action action, case LFUN_MATH_ROW_DELETE: case LFUN_MATH_COLUMN_INSERT: case LFUN_MATH_COLUMN_DELETE: - disable = !mathcursor || !mathcursor->halign(); + disable = !mathcursor || !mathcursor->halign() || + mathcursor->formula()->getType() == LM_OT_SIMPLE; break; default: @@ -723,28 +726,28 @@ FuncStatus LyXFunc::getStatus(kb_action action, } } else { - MathTextCodes tc = mathcursor->getLastCode(); + string tc = mathcursor->getLastCode(); switch (action) { case LFUN_BOLD: - flag.setOnOff(tc == LM_TC_BF); + flag.setOnOff(tc == "mathbf"); break; case LFUN_SANS: - flag.setOnOff(tc == LM_TC_SF); + flag.setOnOff(tc == "mathsf"); break; case LFUN_EMPH: - flag.setOnOff(tc == LM_TC_CAL); + flag.setOnOff(tc == "mathcal"); break; case LFUN_ROMAN: - flag.setOnOff(tc == LM_TC_RM); + flag.setOnOff(tc == "mathrm"); break; case LFUN_CODE: - flag.setOnOff(tc == LM_TC_TT); + flag.setOnOff(tc == "mathtt"); break; case LFUN_NOUN: - flag.setOnOff(tc == LM_TC_BB); + flag.setOnOff(tc == "mathbb"); break; case LFUN_DEFAULT: - flag.setOnOff(tc == LM_TC_VAR); + flag.setOnOff(tc == "mathnormal"); break; default: break; @@ -1611,7 +1614,7 @@ string const LyXFunc::dispatch(kb_action action, string argument) // Of course we should only do the resize and the textcache.clear // if values really changed...but not very important right now. (Lgb) // All visible buffers will need resize - owner->resize(); + owner->view()->resize(); // We also need to empty the textcache so that // the buffer will be formatted correctly after // a zoom change. @@ -1910,15 +1913,16 @@ void LyXFunc::open(string const & fname) } -// checks for running without gui are missing. void LyXFunc::doImport(string const & argument) { string format; string filename = split(argument, format, ' '); + lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format << " file: " << filename << endl; - - if (filename.empty()) { // need user interaction + + // need user interaction + if (filename.empty()) { string initpath = lyxrc.document_path; if (owner->view()->available()) { @@ -1955,7 +1959,6 @@ void LyXFunc::doImport(string const & argument) owner->message(_("Canceled.")); } - // still no filename? abort if (filename.empty()) return; @@ -1965,35 +1968,35 @@ void LyXFunc::doImport(string const & argument) string const lyxfile = ChangeExtension(filename, ".lyx"); // Check if the document already is open - if (bufferlist.exists(lyxfile)) { + if (lyxrc.use_gui && bufferlist.exists(lyxfile)) { switch (Alert::askConfirmation(_("Document is already open:"), MakeDisplayPath(lyxfile, 50), _("Do you want to close that document now?\n" "('No' will just switch to the open version)"))) { - case 1: // Yes: close the document - if (!bufferlist.close(bufferlist.getBuffer(lyxfile))) + case 1: // If close is canceled, we cancel here too. + if (!bufferlist.close(bufferlist.getBuffer(lyxfile))) return; break; - case 2: // No: switch to the open document + case 2: owner->view()->buffer(bufferlist.getBuffer(lyxfile)); return; - case 3: // Cancel: Do nothing + case 3: owner->message(_("Canceled.")); return; } } - // Check if a LyX document by the same root exists in filesystem - FileInfo const f(lyxfile, true); - if (f.exist() && !Alert::askQuestion(_("A document by the name"), - MakeDisplayPath(lyxfile), - _("already exists. Overwrite?"))) { - owner->message(_("Canceled")); - return; + // if the file exists already, and we didn't do + // -i lyx thefile.lyx, warn + if (FileInfo(lyxfile, true).exist() && filename != lyxfile) { + if (!Alert::askQuestion(_("A document by the name"), + MakeDisplayPath(lyxfile), _("already exists. Overwrite?"))) { + owner->message(_("Canceled")); + return; + } } - // filename should be valid now Importer::Import(owner, filename, format); }