#include "support/lstrings.h"
#include "support/lyxlib.h"
#include "support/convert.h"
+#include "support/lyxtime.h"
#include "mathed/math_hullinset.h"
#include "mathed/math_macrotemplate.h"
{
recordUndo(cur);
string sel = cur.selectionAsString(false);
- lyxerr << "selection is: '" << sel << "'" << endl;
+ //lyxerr << "selection is: '" << sel << "'" << endl;
if (sel.empty()) {
const int old_pos = cur.pos();
void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
{
lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
- lyxerr << "*** LyXText::dispatch: cmd: " << cmd << endl;
BOOST_ASSERT(cur.text() == this);
BufferView * bv = &cur.bv();
CursorSlice oldTopSlice = cur.top();
+ bool oldBoundary = cur.boundary();
bool sel = cur.selection();
bool needsUpdate = !lyxaction.funcHasFlag(cmd.action, LyXAction::NoUpdate);
case LFUN_RIGHT:
case LFUN_RIGHTSEL:
- lyxerr << BOOST_CURRENT_FUNCTION
- << " LFUN_RIGHT[SEL]:\n" << cur << endl;
+ //lyxerr << BOOST_CURRENT_FUNCTION
+ // << " LFUN_RIGHT[SEL]:\n" << cur << endl;
cur.selHandle(cmd.action == LFUN_RIGHTSEL);
if (isRTL(cur.paragraph()))
needsUpdate = cursorLeft(cur);
else
needsUpdate = cursorRight(cur);
- if (!needsUpdate && oldTopSlice == cur.top()) {
+
+ if (!needsUpdate && oldTopSlice == cur.top()
+ && cur.boundary() == oldBoundary) {
cur.undispatched();
cmd = FuncRequest(LFUN_FINISHED_RIGHT);
}
needsUpdate = cursorRight(cur);
else
needsUpdate = cursorLeft(cur);
- if (oldTopSlice == cur.top()) {
+
+ if (!needsUpdate && oldTopSlice == cur.top()
+ && cur.boundary() == oldBoundary) {
cur.undispatched();
cmd = FuncRequest(LFUN_FINISHED_LEFT);
}
update(cur);
//lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl;
cur.selHandle(cmd.action == LFUN_UPSEL);
+
needsUpdate = cursorUp(cur);
- if (oldTopSlice == cur.top()) {
+ if (!needsUpdate && oldTopSlice == cur.top()
+ && cur.boundary() == oldBoundary) {
cur.undispatched();
cmd = FuncRequest(LFUN_FINISHED_UP);
}
//lyxerr << "handle LFUN_DOWN[SEL]:\n" << cur << endl;
cur.selHandle(cmd.action == LFUN_DOWNSEL);
needsUpdate = cursorDown(cur);
- if (oldTopSlice == cur.top()) {
+ if (!needsUpdate && oldTopSlice == cur.top() &&
+ cur.boundary() == oldBoundary)
+ {
cur.undispatched();
cmd = FuncRequest(LFUN_FINISHED_DOWN);
}
}
case LFUN_INSET_SETTINGS:
- if (cur.inset().asUpdatableInset())
- cur.inset().asUpdatableInset()->showInsetDialog(bv);
+ cur.inset().showInsetDialog(bv);
break;
case LFUN_NEXT_INSET_TOGGLE: {
break;
case LFUN_GETXY:
- cur.message(convert<string>(cursorX(cur.top())) + ' '
- + convert<string>(cursorY(cur.top())));
+ cur.message(convert<string>(cursorX(cur.top(), cur.boundary())) + ' '
+ + convert<string>(cursorY(cur.top(), cur.boundary())));
break;
case LFUN_SETXY: {
cur.clearSelection();
string const clip = bv->getClipboard();
if (!clip.empty()) {
+ recordUndo(cur);
if (cmd.argument == "paragraph")
insertStringAsParagraphs(cur, clip);
else
break;
}
- case LFUN_DATE_INSERT: {
- lyx::cap::replaceSelection(cur);
- time_t now_time_t = time(NULL);
- struct tm * now_tm = localtime(&now_time_t);
- setlocale(LC_TIME, "");
- string arg;
- if (!cmd.argument.empty())
- arg = cmd.argument;
+ case LFUN_DATE_INSERT:
+ if (cmd.argument.empty())
+ bv->owner()->dispatch(FuncRequest(LFUN_SELFINSERT,
+ lyx::formatted_time(lyx::current_time())));
else
- arg = lyxrc.date_insert_format;
- char datetmp[32];
- int const datetmp_len =
- ::strftime(datetmp, 32, arg.c_str(), now_tm);
-
- for (int i = 0; i < datetmp_len; i++)
- insertChar(cur, datetmp[i]);
-
- cur.resetAnchor();
- moveCursor(cur, false);
+ bv->owner()->dispatch(FuncRequest(LFUN_SELFINSERT,
+ lyx::formatted_time(lyx::current_time(), cmd.argument)));
break;
- }
case LFUN_MOUSE_TRIPLE:
if (cmd.button() == mouse_button::button1) {
// don't set anchor_
bvcur.setCursor(cur);
bvcur.selection() = true;
- lyxerr << "MOTION: " << bv->cursor() << endl;
+ //lyxerr << "MOTION: " << bv->cursor() << endl;
}
} else
break;
default:
- lyxerr << BOOST_CURRENT_FUNCTION
- << " Not DISPATCHED by LyXText" << endl;
+ lyxerr[Debug::ACTION]
+ << BOOST_CURRENT_FUNCTION
+ << ": Command " << cmd
+ << " not DISPATCHED by LyXText" << endl;
cur.undispatched();
break;
}
flag.setOnOff(cur.paragraph().params().startOfAppendix());
return true;
+ case LFUN_INSERT_BIBITEM:
+ enable = (cur.paragraph().layout()->labeltype == LABEL_BIBLIO);
+ break;
+
#if 0
// the functions which insert insets
InsetBase::Code code = InsetBase::NO_CODE;
case LFUN_INSERT_LABEL:
case LFUN_INSERT_NOTE:
case LFUN_INSERT_CHARSTYLE:
- case LFUN_INSERT_BIBITEM:
case LFUN_INSET_FLOAT:
case LFUN_INSET_FOOTNOTE:
case LFUN_INSET_MARGINAL: