#include "support/path.h"
#include "support/lyxfunctional.h"
+#include "BoostFormat.h"
+
#include <ctime>
#include <clocale>
#include <cstdlib>
}
if (keysym->isModifier()) {
+ lyxerr[Debug::KEY] << "isModifier true" << endl;
return;
}
cancel_meta_seq.reset();
int action = cancel_meta_seq.addkey(keysym, state);
- lyxerr[Debug::KEY] << "action first set to [" << action << "]" << endl;
+ lyxerr[Debug::KEY] << "action first set to [" << action << ']' << endl;
// When not cancel or meta-fake, do the normal lookup.
// Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
// remove Caps Lock and Mod2 as a modifiers
action = keyseq.addkey(keysym, (state | meta_fake_bit));
lyxerr[Debug::KEY] << "action now set to ["
- << action << "]" << endl;
+ << action << ']' << endl;
}
// Dont remove this unless you know what you are doing.
if (lyxerr.debugging(Debug::KEY)) {
lyxerr << "Key [action="
<< action << "]["
- << keyseq.print() << "]"
+ << keyseq.print() << ']'
<< endl;
}
owner->message(keyseq.print());
}
- if (action == LFUN_UNKNOWN_ACTION) {
- // It is unknown, but what if we remove all
- // the modifiers? (Lgb)
+
+ // Maybe user can only reach the key via holding down shift.
+ // Let's see. But only if shift is the only modifier
+ if (action == LFUN_UNKNOWN_ACTION && state == key_modifier::shift) {
+ lyxerr[Debug::KEY] << "Trying without shift" << endl;
action = keyseq.addkey(keysym, key_modifier::none);
-
- lyxerr[Debug::KEY] << "Removing modifiers...\n"
- << "Action now set to ["
- << action << "]" << endl;
-
- if (action == LFUN_UNKNOWN_ACTION) {
+ lyxerr[Debug::KEY] << "Action now " << action << endl;
+ }
+
+ if (action == LFUN_UNKNOWN_ACTION) {
+ // Hmm, we didn't match any of the keysequences. See
+ // 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;
+ action = LFUN_SELFINSERT;
+ } else {
+ lyxerr[Debug::KEY] << "Unknown, !isText() - giving up" << endl;
owner->message(_("Unknown function."));
return;
}
char c = keysym->getISOEncoded();
string argument;
+ // FIXME: why ...
if (c != 0)
argument = c;
int const action = lyxaction.LookupFunc(s);
if (action == LFUN_UNKNOWN_ACTION) {
+#if USE_BOOST_FORMAT
+boost::format fmt(_("Unknown function (%1$s)"));
+fmt % s;
+owner->message(fmt.str());
+#else
string const msg = string(_("Unknown function ("))
- + s + ")";
+ + s + ')';
owner->message(msg);
+#endif
return;
}
void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
{
lyxerr[Debug::ACTION] << "LyXFunc::dispatch: action[" << ev.action
- <<"] arg[" << ev.argument << "]" << endl;
+ <<"] arg[" << ev.argument << ']' << endl;
// we have not done anything wrong yet.
errorstat = false;
case LFUN_MENUWRITE:
if (!owner->buffer()->isUnnamed()) {
ostringstream s1;
- s1 << _("Saving document") << ' '
- << MakeDisplayPath(owner->buffer()->fileName() + "...");
+#if USE_BOOST_FORMAT
+ s1 << boost::format(_("Saving document %1$s..."))
+ % MakeDisplayPath(owner->buffer()->fileName());
+#else
+ s1 << _("Saving document ")
+ << MakeDisplayPath(owner->buffer()->fileName())
+ << _("...");
+#endif
owner->message(STRCONV(s1.str()));
MenuWrite(view(), owner->buffer());
s1 << _(" done.");
break;
}
ostringstream str;
- str << _("Opening help file") << ' '
- << MakeDisplayPath(fname) << "...";
+#if USE_BOOST_FORMAT
+ str << boost::format(_("Opening help file %1$s..."))
+ % MakeDisplayPath(fname);
+#else
+ str << _("Opening help file ")
+ << MakeDisplayPath(fname) << _("...");
+#endif
owner->message(STRCONV(str.str()));
view()->buffer(bufferlist.loadLyXFile(fname, false));
owner->allowInput();
Paragraph * par = owner->buffer()->getParFromID(id);
if (par == 0) {
lyxerr[Debug::INFO] << "No matching paragraph found! ["
- << id << "]" << endl;
+ << id << ']' << endl;
break;
} else {
lyxerr[Debug::INFO] << "Paragraph " << par->id()
x11_name != lcolor.getX11Name(LColor::graphicsbg));
if (!lcolor.setColor(lyx_name, x11_name)) {
- static string const err1 (N_("Set-color \""));
- static string const err2 (
- N_("\" failed - color is undefined "
- "or may not be redefined"));
- setErrorMessage(_(err1) + lyx_name + _(err2));
+#if USE_BOOST_FORMAT
+ setErrorMessage(
+ boost::io::str(
+ boost::format(
+ _("Set-color \"%1$s\" failed "
+ "- color is undefined or "
+ "may not be redefined"))
+ % lyx_name));
+#else
+ setErrorMessage(_("Set-color ") + lyx_name
+ + _(" failed - color is undefined"
+ " or may not be redefined"));
+#endif
+
break;
}
string dispatch_msg = msg;
if (!dispatch_msg.empty())
- dispatch_msg += " ";
+ dispatch_msg += ' ';
string comname = lyxaction.getActionName(ev.action);
if (pseudoaction == LFUN_UNKNOWN_ACTION) {
pseudoaction = ev.action;
} else {
- comname += " " + ev.argument;
+ comname += ' ' + ev.argument;
argsadded = true;
}
}
if (!shortcuts.empty()) {
comname += ": " + shortcuts;
} else if (!argsadded && !ev.argument.empty()) {
- comname += " " + ev.argument;
+ comname += ' ' + ev.argument;
}
if (!comname.empty()) {
comname = rtrim(comname);
- dispatch_msg += "(" + comname + ')';
+ dispatch_msg += '(' + comname + ')';
}
lyxerr[Debug::ACTION] << "verbose dispatch msg " << dispatch_msg << endl;
string(lyxrc.template_path)));
FileDialog::Result result =
- fileDlg.Select(lyxrc.template_path,
+ fileDlg.open(lyxrc.template_path,
_("*.lyx|LyX Documents (*.lyx)"));
if (result.first == FileDialog::Later)
string(AddPath(system_lyxdir, "examples"))));
FileDialog::Result result =
- fileDlg.Select(initpath,
+ fileDlg.open(initpath,
"*.lyx|LyX Documents (*.lyx)");
if (result.first == FileDialog::Later)
}
ostringstream str;
- str << _("Opening document") << ' ' << disp_fn << "...";
+#if USE_BOOST_FORMAT
+ str << boost::format(_("Opening document %1$s...")) % disp_fn;
+#else
+ str << _("Opening document ") << disp_fn << _("...");
+#endif
owner->message(STRCONV(str.str()));
ostringstream str2;
if (openbuf) {
view()->buffer(openbuf);
- str2 << _("Document") << ' ' << disp_fn << ' ' << _("opened.");
+#if USE_BOOST_FORMAT
+ str2 << boost::format(_("Document %1$s opened.")) % disp_fn;
+#else
+ str2 << _("Document ") << disp_fn << _(" opened.");
+#endif
} else {
- str2 << _("Could not open document") << ' ' << disp_fn;
+#if USE_BOOST_FORMAT
+ str2 << boost::format(_("Could not open document %1$s"))
+ % disp_fn;
+#else
+ str2 << _("Could not open document ") << disp_fn;
+#endif
}
owner->message(STRCONV(str2.str()));
}
initpath = trypath;
}
+#if USE_BOOST_FORMAT
+ boost::format fmt(_("Select %1$s file to import"));
+ fmt % formats.prettyName(format);
+ string const text = fmt.str();
+#else
string const text = _("Select ") + formats.prettyName(format)
- + _(" file to import");
+ + _(" file to import");;
+#endif
FileDialog fileDlg(owner, text,
LFUN_IMPORT,
string const extension = "*." + formats.extension(format)
+ "| " + formats.prettyName(format)
- + " (*." + formats.extension(format) + ")";
+ + " (*." + formats.extension(format) + ')';
- FileDialog::Result result = fileDlg.Select(initpath,
+ FileDialog::Result result = fileDlg.open(initpath,
extension);
if (result.first == FileDialog::Later)