namespace fs = boost::filesystem;
-// (alkis)
-extern tex_accent_struct get_accent(kb_action action);
-
-
namespace {
bool getLocalStatus(LCursor cursor,
c = 0;
lyx_view_->view()->getIntl().getTransManager().deadkey(
- c, get_accent(action).accent, view()->getLyXText(), view()->cursor());
+ c, get_accent(action).accent, view()->cursor().innerText(), view()->cursor());
// Need to clear, in case the minibuffer calls these
// actions
keyseq->clear();
void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state)
{
- lyxerr[Debug::KEY] << "KeySym is " << keysym->getSymbolName() << endl;
+ LYXERR(Debug::KEY) << "KeySym is " << keysym->getSymbolName() << endl;
// Do nothing if we have nothing (JMarc)
if (!keysym->isOK()) {
- lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
+ LYXERR(Debug::KEY) << "Empty kbd action (probably composing)"
<< endl;
return;
}
if (keysym->isModifier()) {
- lyxerr[Debug::KEY] << "isModifier true" << endl;
+ LYXERR(Debug::KEY) << "isModifier true" << endl;
return;
}
cancel_meta_seq->reset();
FuncRequest func = cancel_meta_seq->addkey(keysym, state);
- lyxerr[Debug::KEY] << BOOST_CURRENT_FUNCTION
+ LYXERR(Debug::KEY) << BOOST_CURRENT_FUNCTION
<< " action first set to [" << func.action << ']'
<< endl;
if ((func.action != LFUN_CANCEL) && (func.action != LFUN_META_PREFIX)) {
// remove Caps Lock and Mod2 as a modifiers
func = keyseq->addkey(keysym, (state | meta_fake_bit));
- lyxerr[Debug::KEY] << BOOST_CURRENT_FUNCTION
+ LYXERR(Debug::KEY) << BOOST_CURRENT_FUNCTION
<< "action now set to ["
<< func.action << ']' << endl;
}
func = FuncRequest(LFUN_COMMAND_PREFIX);
}
- if (lyxerr.debugging(Debug::KEY)) {
- lyxerr << BOOST_CURRENT_FUNCTION
- << " Key [action="
- << func.action << "]["
- << to_utf8(keyseq->print(false)) << ']'
- << endl;
- }
+ LYXERR(Debug::KEY) << BOOST_CURRENT_FUNCTION
+ << " Key [action="
+ << func.action << "]["
+ << to_utf8(keyseq->print(false)) << ']'
+ << endl;
// already here we know if it any point in going further
// why not return already here if action == -1 and
// Let's see. But only if shift is the only modifier
if (func.action == LFUN_UNKNOWN_ACTION &&
state == key_modifier::shift) {
- lyxerr[Debug::KEY] << "Trying without shift" << endl;
+ LYXERR(Debug::KEY) << "Trying without shift" << endl;
func = keyseq->addkey(keysym, key_modifier::none);
- lyxerr[Debug::KEY] << "Action now " << func.action << endl;
+ LYXERR(Debug::KEY) << "Action now " << func.action << endl;
}
if (func.action == LFUN_UNKNOWN_ACTION) {
// if it's normal insertable text not already covered
// by a binding
if (keysym->isText() && keyseq->length() == 1) {
- lyxerr[Debug::KEY] << "isText() is true, inserting." << endl;
+ LYXERR(Debug::KEY) << "isText() is true, inserting." << endl;
func = FuncRequest(LFUN_SELF_INSERT,
FuncRequest::KEYBOARD);
} else {
- lyxerr[Debug::KEY] << "Unknown, !isText() - giving up" << endl;
+ LYXERR(Debug::KEY) << "Unknown, !isText() - giving up" << endl;
lyx_view_->message(_("Unknown function."));
return;
}
docstring const arg(1, encoded_last_key);
dispatch(FuncRequest(LFUN_SELF_INSERT, arg,
FuncRequest::KEYBOARD));
- lyxerr[Debug::KEY]
+ LYXERR(Debug::KEY)
<< "SelfInsert arg[`" << to_utf8(arg) << "']" << endl;
}
} else {
case LFUN_DIALOG_SHOW_NEW_INSET:
enable = cur.inset().lyxCode() != InsetBase::ERT_CODE;
+ if (cur.inset().lyxCode() == InsetBase::CAPTION_CODE) {
+ FuncStatus flag;
+ if (cur.inset().getStatus(cur, cmd, flag))
+ return flag;
+ }
break;
case LFUN_DIALOG_UPDATE: {
string const argument = to_utf8(cmd.argument());
kb_action const action = cmd.action;
- lyxerr[Debug::ACTION] << endl << "LyXFunc::dispatch: cmd: " << cmd << endl;
+ LYXERR(Debug::ACTION) << endl << "LyXFunc::dispatch: cmd: " << cmd << endl;
//lyxerr << "LyXFunc::dispatch: cmd: " << cmd << endl;
// we have not done anything wrong yet.
FuncStatus const flag = getStatus(cmd);
if (!flag.enabled()) {
// We cannot use this function here
- lyxerr[Debug::ACTION] << "LyXFunc::dispatch: "
+ LYXERR(Debug::ACTION) << "LyXFunc::dispatch: "
<< lyxaction.getActionName(action)
<< " [" << action << "] is disabled at this location"
<< endl;
if (view()->buffer())
// cancel any selection
dispatch(FuncRequest(LFUN_MARK_OFF));
- setMessage(_("Cancel"));
+ setMessage(from_ascii(N_("Cancel")));
break;
case LFUN_META_PREFIX:
lyx_view_->message(str);
menuWrite(lyx_view_->buffer());
lyx_view_->message(str + _(" done."));
- } else
- writeAs(lyx_view_->buffer());
+ } else {
+ writeAs(lyx_view_->buffer());
+ }
updateFlags = Update::None;
break;
}
// Push directory path.
- string const path = buffer->temppath();
- support::Path p(path);
+ string const path(buffer->temppath());
+ // Prevent the compiler from optimizing away p
+ FileName pp(path);
+ support::Path p(pp);
// there are three cases here:
// 1. we print to a file
} else {
// case 1: print to a file
+ FileName const filename(makeAbsPath(target_name, path));
+ if (fs::exists(filename.toFilesystemEncoding())) {
+ docstring text = bformat(
+ _("The file %1$s already exists.\n\n"
+ "Do you want to over-write that file?"),
+ makeDisplayPath(filename.absFilename()));
+ if (Alert::prompt(_("Over-write file?"),
+ text, 0, 1, _("&Over-write"), _("&Cancel")) != 0)
+ break;
+ }
command += lyxrc.print_to_file
- + quoteName(makeAbsPath(target_name,
- path).toFilesystemEncoding())
+ + quoteName(filename.toFilesystemEncoding())
+ ' '
+ quoteName(dviname);
res = one.startscript(Systemcall::DontWait,
BOOST_ASSERT(lyx_view_);
string const arg = argument;
if (arg.empty()) {
- setErrorMessage(_("Missing argument"));
+ setErrorMessage(from_ascii(N_("Missing argument")));
break;
}
FileName const fname = i18nLibFileSearch("doc", arg, "lyx");
case LFUN_SERVER_GET_NAME:
BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
setMessage(from_utf8(lyx_view_->buffer()->fileName()));
- lyxerr[Debug::INFO] << "FNAME["
+ LYXERR(Debug::INFO) << "FNAME["
<< lyx_view_->buffer()->fileName()
<< "] " << endl;
break;
int row;
istringstream is(argument);
is >> file_name >> row;
- if (prefixIs(file_name, package().temp_dir())) {
+ if (prefixIs(file_name, package().temp_dir().absFilename())) {
// Needed by inverse dvi search. If it is a file
// in tmpdir, call the apropriated function
lyx_view_->setBuffer(theBufferList().getBufferFromTmp(file_name));
string opt1;
if (contains(argument, "|")) {
arg = token(argument, '|', 0);
- opt1 = '[' + token(argument, '|', 1) + ']';
+ opt1 = token(argument, '|', 1);
}
- std::ostringstream os;
- os << "citation LatexCommand\n"
- << "\\cite" << opt1 << "{" << arg << "}\n"
- << "\\end_inset";
- FuncRequest fr(LFUN_INSET_INSERT, os.str());
+ InsetCommandParams icp("cite");
+ icp["key"] = from_utf8(arg);
+ if (!opt1.empty())
+ icp["before"] = from_utf8(opt1);
+ string icstr = InsetCommandMailer::params2string("citation", icp);
+ FuncRequest fr(LFUN_INSET_INSERT, icstr);
dispatch(fr);
} else
- dispatch(FuncRequest(LFUN_DIALOG_SHOW, "citation"));
+ dispatch(FuncRequest(LFUN_DIALOG_SHOW_NEW_INSET, "citation"));
break;
}
BOOST_ASSERT(lyx_view_);
FileName const filename =
makeAbsPath(argument, lyx_view_->buffer()->filePath());
- // FIXME Should use bformat
- setMessage(_("Opening child document ") +
- makeDisplayPath(filename.absFilename()) + "...");
+ setMessage(bformat(_("Opening child document %1$s..."),
+ makeDisplayPath(filename.absFilename())));
view()->saveBookmark(false);
string const parentfilename = lyx_view_->buffer()->fileName();
if (theBufferList().exists(filename.absFilename()))
case LFUN_PREFERENCES_SAVE: {
lyxrc.write(makeAbsPath("preferences",
- package().user_support()),
+ package().user_support().absFilename()),
false);
break;
}
case LFUN_SCREEN_FONT_UPDATE:
BOOST_ASSERT(lyx_view_);
// handle the screen font changes.
- lyxrc.set_font_norm_type();
theFontLoader().update();
/// FIXME: only the current view will be updated. the Gui
/// class is able to furnish the list of views.
string lyx_name;
string const x11_name = split(argument, lyx_name, ' ');
if (lyx_name.empty() || x11_name.empty()) {
- setErrorMessage(_("Syntax: set-color <lyx_name>"
- " <x11_name>"));
+ setErrorMessage(from_ascii(N_(
+ "Syntax: set-color <lyx_name>"
+ " <x11_name>")));
break;
}
InsetIterator it = inset_iterator_begin(inset);
InsetIterator const end = inset_iterator_end(inset);
for (; it != end; ++it) {
- if (inset_code == InsetBase::NO_CODE
- || inset_code == it->lyxCode()) {
+ if (!it->asInsetMath()
+ && (inset_code == InsetBase::NO_CODE
+ || inset_code == it->lyxCode())) {
LCursor tmpcur = cur;
tmpcur.pushLeft(*it);
it->dispatch(tmpcur, fr);
if (oldL->rightToLeft() == newL->rightToLeft()
&& !buffer.isMultiLingual())
buffer.changeLanguage(oldL, newL);
- else
- buffer.updateDocLang(newL);
break;
}
case LFUN_BUFFER_SAVE_AS_DEFAULT: {
string const fname =
- addName(addPath(package().user_support(), "templates/"),
+ addName(addPath(package().user_support().absFilename(), "templates/"),
"defaults.lyx");
Buffer defaults(fname);
}
if (defaults.writeFile(FileName(defaults.fileName())))
- // FIXME Should use bformat
- setMessage(_("Document defaults saved in ")
- + makeDisplayPath(fname));
+ setMessage(bformat(_("Document defaults saved in %1$s"),
+ makeDisplayPath(fname)));
else
- setErrorMessage(_("Unable to save document defaults"));
+ setErrorMessage(from_ascii(N_("Unable to save document defaults")));
break;
}
case LFUN_BUFFER_PARAMS_APPLY: {
BOOST_ASSERT(lyx_view_);
biblio::CiteEngine const engine =
- lyx_view_->buffer()->params().cite_engine;
+ lyx_view_->buffer()->params().getEngine();
istringstream ss(argument);
LyXLex lex(0,0);
<< (unknown_tokens == 1 ? "" : "s")
<< endl;
}
- if (engine == lyx_view_->buffer()->params().cite_engine)
+ if (engine == lyx_view_->buffer()->params().getEngine())
break;
LCursor & cur = view()->cursor();
// if we executed a mutating lfun, mark the buffer as dirty
if (flag.enabled()
- && !lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)
- && !lyxaction.funcHasFlag(cmd.action, LyXAction::ReadOnly))
+ && !lyxaction.funcHasFlag(action, LyXAction::NoBuffer)
+ && !lyxaction.funcHasFlag(action, LyXAction::ReadOnly))
view()->buffer()->markDirty();
if (view()->cursor().inTexted()) {
if (!quitting) {
lyx_view_->updateMenubar();
lyx_view_->updateToolbars();
- sendDispatchMessage(getMessage(), cmd);
+ // Some messages may already be translated, so we cannot use _()
+ sendDispatchMessage(translateIfPossible(getMessage()), cmd);
}
}
|| cmd.origin == FuncRequest::COMMANDBUFFER);
if (cmd.action == LFUN_SELF_INSERT || !verbose) {
- lyxerr[Debug::ACTION] << "dispatch msg is " << to_utf8(msg) << endl;
+ LYXERR(Debug::ACTION) << "dispatch msg is " << to_utf8(msg) << endl;
if (!msg.empty())
lyx_view_->message(msg);
return;
dispatch_msg += '(' + rtrim(comname) + ')';
}
- lyxerr[Debug::ACTION] << "verbose dispatch msg "
+ LYXERR(Debug::ACTION) << "verbose dispatch msg "
<< to_utf8(dispatch_msg) << endl;
if (!dispatch_msg.empty())
lyx_view_->message(dispatch_msg);
}
Buffer * const b = newFile(filename, templname, !name.empty());
- if (b)
+ if (b) {
+ updateLabels(*b);
lyx_view_->setBuffer(b);
+ }
}
FileDialog fileDlg(_("Select document to open"),
LFUN_FILE_OPEN,
make_pair(_("Documents|#o#O"), from_utf8(lyxrc.document_path)),
- make_pair(_("Examples|#E#e"), from_utf8(addPath(package().system_support(), "examples"))));
+ make_pair(_("Examples|#E#e"), from_utf8(addPath(package().system_support().absFilename(), "examples"))));
FileDialog::Result result =
fileDlg.open(from_utf8(initpath),
string format;
string filename = split(argument, format, ' ');
- lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
+ LYXERR(Debug::INFO) << "LyXFunc::doImport: " << format
<< " file: " << filename << endl;
// need user interaction
LFUN_BUFFER_IMPORT,
make_pair(_("Documents|#o#O"), from_utf8(lyxrc.document_path)),
make_pair(_("Examples|#E#e"),
- from_utf8(addPath(package().system_support(), "examples"))));
+ from_utf8(addPath(package().system_support().absFilename(), "examples"))));
docstring filter = formats.prettyName(format);
filter += " (*.";
string const encoded = FileName(
lyxrc_new.document_path).toFilesystemEncoding();
if (fs::exists(encoded) && fs::is_directory(encoded))
- support::package().document_dir() = lyxrc.document_path;
+ support::package().document_dir() = FileName(lyxrc.document_path);
}
case LyXRC::RC_ESC_CHARS:
case LyXRC::RC_FONT_ENCODING:
support::prependEnvPath("PATH", lyxrc.path_prefix);
}
case LyXRC::RC_PERS_DICT:
- case LyXRC::RC_POPUP_BOLD_FONT:
- case LyXRC::RC_POPUP_FONT_ENCODING:
- case LyXRC::RC_POPUP_NORMAL_FONT:
case LyXRC::RC_PREVIEW:
case LyXRC::RC_PREVIEW_HASHED_LABELS:
case LyXRC::RC_PREVIEW_SCALE_FACTOR:
case LyXRC::RC_PRINT_COMMAND:
case LyXRC::RC_RTL_SUPPORT:
case LyXRC::RC_SCREEN_DPI:
- case LyXRC::RC_SCREEN_FONT_ENCODING:
case LyXRC::RC_SCREEN_FONT_ROMAN:
case LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY:
case LyXRC::RC_SCREEN_FONT_SANS: