// buffer clean/dirty status by itself.
flag.setEnabled(!buffer_.isReadonly() && buffer_.undo().hasRedoStack());
break;
- case LFUN_FILE_INSERT:
case LFUN_FILE_INSERT_PLAINTEXT_PARA:
- case LFUN_FILE_INSERT_PLAINTEXT:
+ case LFUN_FILE_INSERT_PLAINTEXT: {
+ docstring const fname = cmd.argument();
+ if (!FileName::isAbsolute(to_utf8(fname))) {
+ flag.message(_("Absolute filename expected."));
+ return false;
+ }
+ flag.setEnabled(cur.inTexted());
+ break;
+ }
+ case LFUN_FILE_INSERT:
case LFUN_BOOKMARK_SAVE:
// FIXME: Actually, these LFUNS should be moved to Text
flag.setEnabled(cur.inTexted());
p = Point(width_, height_);
Cursor old = cur;
bool const in_texted = cur.inTexted();
- cur.reset();
+ cur.setCursor(doc_iterator_begin(cur.buffer()));
+ cur.selHandle(false);
buffer_.changed(true);
updateHoveredInset();
d->text_metrics_[&buffer_.text()].editXY(cur, p.x_, p.y_,
true, act == LFUN_SCREEN_UP);
- cur.resetAnchor();
//FIXME: what to do with cur.x_target()?
bool update = in_texted && cur.bv().checkDepm(cur, old);
cur.finishUndo();
- if (update) {
+ if (update || cur.selection()) {
dr.screenUpdate(Update::Force | Update::FitCursor);
dr.forceBufferUpdate();
}
break;
}
- case LFUN_SCROLL:
- lfunScroll(cmd);
+ case LFUN_SCROLL: {
+ string const scroll_type = cmd.getArg(0);
+ int scroll_step = 0;
+ if (scroll_type == "line")
+ scroll_step = d->scrollbarParameters_.single_step;
+ else if (scroll_type == "page")
+ scroll_step = d->scrollbarParameters_.page_step;
+ else
+ return;
+ string const scroll_quantity = cmd.getArg(1);
+ if (scroll_quantity == "up")
+ scrollUp(scroll_step);
+ else if (scroll_quantity == "down")
+ scrollDown(scroll_step);
+ else {
+ int const scroll_value = convert<int>(scroll_quantity);
+ if (scroll_value)
+ scroll(scroll_step * scroll_value);
+ }
+ buffer_.changed(true);
+ updateHoveredInset();
dr.forceBufferUpdate();
break;
+ }
case LFUN_SCREEN_UP_SELECT: {
cur.selHandle(true);
cur.setCurrentFont();
dr.forceBufferUpdate();
}
+ }
+
+ case LFUN_FILE_INSERT_PLAINTEXT_PARA:
+ case LFUN_FILE_INSERT_PLAINTEXT: {
+ bool const as_paragraph = (act == LFUN_FILE_INSERT_PLAINTEXT_PARA);
+ string const fname = to_utf8(cmd.argument());
+ if (!FileName::isAbsolute(fname))
+ dr.setMessage(_("Absolute filename expected."));
+ else
+ insertPlaintextFile(FileName(fname), as_paragraph);
break;
}
}
-void BufferView::lfunScroll(FuncRequest const & cmd)
-{
- string const scroll_type = cmd.getArg(0);
- int scroll_step = 0;
- if (scroll_type == "line")
- scroll_step = d->scrollbarParameters_.single_step;
- else if (scroll_type == "page")
- scroll_step = d->scrollbarParameters_.page_step;
- else
- return;
- string const scroll_quantity = cmd.getArg(1);
- if (scroll_quantity == "up")
- scrollUp(scroll_step);
- else if (scroll_quantity == "down")
- scrollDown(scroll_step);
- else {
- int const scroll_value = convert<int>(scroll_quantity);
- if (scroll_value)
- scroll(scroll_step * scroll_value);
- }
- buffer_.changed(true);
- updateHoveredInset();
-}
-
-
int BufferView::minVisiblePart()
{
return 2 * defaultRowHeight();
d->cursor_ = cur;
cur.forceBufferUpdate();
- buffer_.changed(true);
+ cur.screenUpdateFlags(Update::Force);
return true;
}