#include "support/lstrings.h"
#include "support/lyxlib.h"
-#include "support/tostr.h"
+#include "support/convert.h"
#include "mathed/math_hullinset.h"
#include "mathed/math_macrotemplate.h"
using lyx::cap::replaceSelection;
using lyx::support::isStrUnsignedInt;
-using lyx::support::strToUnsignedInt;
-using lyx::support::atoi;
using lyx::support::token;
using std::endl;
extern string current_layout;
-// the selection possible is needed, that only motion events are
-// used, where the button press event was on the drawing area too
-bool selection_possible = false;
-
namespace {
cur.undispatched();
}
break;
-
+
case LFUN_ENDBUFSEL:
if (cur.size() == 1) {
if (!cur.selection())
case LFUN_PARAGRAPH_SPACING: {
Paragraph & par = cur.paragraph();
Spacing::Space cur_spacing = par.params().spacing().getSpace();
- float cur_value = 1.0;
+ string cur_value = "1.0";
if (cur_spacing == Spacing::Other)
- cur_value = par.params().spacing().getValue();
+ cur_value = par.params().spacing().getValueAsString();
istringstream is(cmd.argument);
string tmp;
is >> tmp;
Spacing::Space new_spacing = cur_spacing;
- float new_value = cur_value;
+ string new_value = cur_value;
if (tmp.empty()) {
lyxerr << "Missing argument to `paragraph-spacing'"
<< endl;
new_spacing = Spacing::Double;
} else if (tmp == "other") {
new_spacing = Spacing::Other;
- float tmpval = 0.0;
+ string tmpval = "0.0";
is >> tmpval;
lyxerr << "new_value = " << tmpval << endl;
- if (tmpval != 0.0)
+ if (tmpval != "0.0")
new_value = tmpval;
} else if (tmp == "default") {
new_spacing = Spacing::Default;
lyxerr << _("Unknown spacing argument: ")
<< cmd.argument << endl;
}
- if (cur_spacing != new_spacing || cur_value != new_value)
+ if (cur_spacing != new_spacing || cur_value != new_value)
par.params().spacing(Spacing(new_spacing, new_value));
break;
}
#warning FIXME Check if the arg is in the domain of available selections.
#endif
if (isStrUnsignedInt(cmd.argument))
- pasteSelection(cur, strToUnsignedInt(cmd.argument));
+ pasteSelection(cur, convert<unsigned int>(cmd.argument));
else
pasteSelection(cur, 0);
cur.clearSelection(); // bug 393
break;
case LFUN_GETXY:
- cur.message(tostr(cursorX(cur.top())) + ' '
- + tostr(cursorY(cur.top())));
+ cur.message(convert<string>(cursorX(cur.top())) + ' '
+ + convert<string>(cursorY(cur.top())));
break;
case LFUN_SETXY: {
case LFUN_MOUSE_TRIPLE:
if (cmd.button() == mouse_button::button1) {
- selection_possible = true;
cursorHome(cur);
cur.resetAnchor();
cursorEnd(cur);
case LFUN_MOUSE_DOUBLE:
if (cmd.button() == mouse_button::button1) {
- selection_possible = true;
selectWord(cur, lyx::WHOLE_WORD_STRICT);
bv->haveSelection(cur.selection());
}
// Right click on a footnote flag opens float menu
if (cmd.button() == mouse_button::button3) {
cur.clearSelection();
- selection_possible = false;
break;
}
paste_internally = true;
}
- selection_possible = true;
-
// Clear the selection
cur.clearSelection();
// Set cursor here.
bv->cursor() = cur;
- // Don't allow selection after a big jump.
- //if (bv->fitCursor())
- // selection_possible = false;
-
// Insert primary selection with middle mouse
// if there is a local selection in the current buffer,
// insert this
bv->owner()->dispatch(FuncRequest(LFUN_PASTE));
else
bv->owner()->dispatch(FuncRequest(LFUN_PASTESELECTION, "paragraph"));
- selection_possible = false;
}
break;
// Only use motion with button 1
//if (cmd.button() != mouse_button::button1)
// return false;
- // We want to use only motion events for which
- // the button press event was on the drawing area too.
- if (!selection_possible) {
- lyxerr[Debug::ACTION] << "BufferView::Pimpl::"
- "dispatch: no selection possible\n";
- lyxerr << "BufferView::Pimpl::dispatch: no selection possible\n";
- break;
- }
// ignore motions deeper nested than the real anchor
LCursor & bvcur = cur.bv().cursor();
int const wh = bv->workHeight();
int const y = std::max(0, std::min(wh - 1, cmd.y));
-
+
setCursorFromCoordinates(cur, cmd.x, y);
cur.x_target() = cmd.x;
if (cmd.y >= wh)
bvcur.selection() = true;
lyxerr << "MOTION: " << bv->cursor() << endl;
}
-
+
} else
cur.undispatched();
break;
}
case LFUN_MOUSE_RELEASE: {
- selection_possible = false;
-
if (cmd.button() == mouse_button::button2)
break;
case LFUN_MATH_IMPORT_SELECTION:
case LFUN_MATH_MODE:
- mathDispatch(cur, cmd, false);
+ if (cmd.argument == "on")
+ // don't pass "on" as argument
+ mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);
+ else
+ mathDispatch(cur, cmd, false);
break;
case LFUN_MATH_MACRO:
else {
string s = cmd.argument;
string const s1 = token(s, ' ', 1);
- int const nargs = s1.empty() ? 0 : atoi(s1);
+ int const nargs = s1.empty() ? 0 : convert<int>(s1);
string const s2 = token(s, ' ', 2);
string const type = s2.empty() ? "newcommand" : s2;
cur.insert(new MathMacroTemplate(token(s, ' ', 0), nargs, s2));
}
break;
+ // passthrough hat and underscore outside mathed:
+ case LFUN_SUBSCRIPT:
+ mathDispatch(cur, FuncRequest(LFUN_SELFINSERT, "_"), false);
+ break;
+ case LFUN_SUPERSCRIPT:
+ mathDispatch(cur, FuncRequest(LFUN_SELFINSERT, "^"), false);
+ break;
+
case LFUN_INSERT_MATH:
case LFUN_INSERT_MATRIX:
case LFUN_MATH_DELIM: {
InsetBase & inset = cur.inset();
bool const accept = !inset.forceDefaultParagraphs(&inset);
- data = "update " + tostr(accept) + '\n' + data;
+ data = "update " + convert<string>(accept) + '\n' + data;
bv->owner()->getDialogs().update("paragraph", data);
break;
}
case LFUN_INSERT_MATH:
case LFUN_INSERT_MATRIX:
case LFUN_MATH_DELIM:
+ case LFUN_SUBSCRIPT:
+ case LFUN_SUPERSCRIPT:
case LFUN_DEFAULT:
case LFUN_UNDERLINE:
case LFUN_FONT_SIZE: