}
-void BufferView::updateDocumentClass(DocumentClass const * const olddc)
+void BufferView::makeDocumentClass()
+{
+ DocumentClassConstPtr olddc = buffer_.params().documentClassPtr();
+ buffer_.params().makeDocumentClass();
+ updateDocumentClass(olddc);
+}
+
+
+void BufferView::updateDocumentClass(DocumentClassConstPtr olddc)
{
message(_("Converting document to new document class..."));
buffer_.errors("Class Switch");
}
+
/** Return the change status at cursor position, taking in account the
* status at each level of the document iterator (a table in a deleted
* footnote is deleted).
// 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());
case LFUN_WORD_FIND:
case LFUN_WORD_FIND_FORWARD:
case LFUN_WORD_FIND_BACKWARD:
- case LFUN_WORD_FINDADV:
case LFUN_WORD_REPLACE:
case LFUN_MARK_OFF:
case LFUN_MARK_ON:
flag.setEnabled(true);
break;
+ case LFUN_WORD_FINDADV: {
+ FindAndReplaceOptions opt;
+ istringstream iss(to_utf8(cmd.argument()));
+ iss >> opt;
+ flag.setEnabled(opt.repl_buf_name.empty()
+ || !buffer_.isReadonly());
+ }
+
case LFUN_LABEL_GOTO: {
flag.setEnabled(!cmd.argument().empty()
|| getInsetByCode<InsetRef>(cur, REF_CODE));
switch (act) {
case LFUN_BUFFER_PARAMS_APPLY: {
- DocumentClass const * const oldClass = buffer_.params().documentClassPtr();
+ DocumentClassConstPtr olddc = buffer_.params().documentClassPtr();
cur.recordUndoFullDocument();
istringstream ss(to_utf8(cmd.argument()));
Lexer lex;
<< unknown_tokens << " unknown token"
<< (unknown_tokens == 1 ? "" : "s"));
}
- updateDocumentClass(oldClass);
+ updateDocumentClass(olddc);
// We are most certainly here because of a change in the document
// It is then better to make sure that all dialogs are in sync with
}
case LFUN_LAYOUT_MODULES_CLEAR: {
- DocumentClass const * const oldClass =
- buffer_.params().documentClassPtr();
cur.recordUndoFullDocument();
buffer_.params().clearLayoutModules();
- buffer_.params().makeDocumentClass();
- updateDocumentClass(oldClass);
+ makeDocumentClass();
dr.screenUpdate(Update::Force);
dr.forceBufferUpdate();
break;
"conflicts with installed modules.");
break;
}
- DocumentClass const * const oldClass = params.documentClassPtr();
cur.recordUndoFullDocument();
buffer_.params().addLayoutModule(argument);
- buffer_.params().makeDocumentClass();
- updateDocumentClass(oldClass);
+ makeDocumentClass();
dr.screenUpdate(Update::Force);
dr.forceBufferUpdate();
break;
break;
// Save the old, possibly modular, layout for use in conversion.
- DocumentClass const * const oldDocClass =
- buffer_.params().documentClassPtr();
cur.recordUndoFullDocument();
buffer_.params().setBaseClass(argument);
- buffer_.params().makeDocumentClass();
- updateDocumentClass(oldDocClass);
+ makeDocumentClass();
dr.screenUpdate(Update::Force);
dr.forceBufferUpdate();
break;
}
case LFUN_LAYOUT_RELOAD: {
- DocumentClass const * const oldClass = buffer_.params().documentClassPtr();
LayoutFileIndex bc = buffer_.params().baseClassID();
LayoutFileList::get().reset(bc);
buffer_.params().setBaseClass(bc);
- buffer_.params().makeDocumentClass();
- updateDocumentClass(oldClass);
+ makeDocumentClass();
dr.screenUpdate(Update::Force);
dr.forceBufferUpdate();
break;
from = doc_iterator_begin(&buffer_);
to = doc_iterator_end(&buffer_);
}
- int const words = countWords(from, to);
- int const chars = countChars(from, to, false);
- int const chars_blanks = countChars(from, to, true);
+ buffer_.updateStatistics(from, to);
+ int const words = buffer_.wordCount();
+ int const chars = buffer_.charCount(false);
+ int const chars_blanks = buffer_.charCount(true);
docstring message;
if (cur.selection())
message = _("Statistics for the selection:");
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) {
- dr.screenUpdate(Update::Force | Update::FitCursor);
+
+ if (update || cur.mark())
+ dr.screenUpdate(Update::Force | Update::FitCursor);
+ if (update)
dr.forceBufferUpdate();
- }
break;
}
}
case LFUN_SCREEN_UP_SELECT: {
+ // FIXME: why is the algorithm different from LFUN_SCREEN_UP?
cur.selHandle(true);
if (isTopScreen()) {
lyx::dispatch(FuncRequest(LFUN_BUFFER_BEGIN_SELECT));
}
case LFUN_SCREEN_DOWN_SELECT: {
+ // FIXME: why is the algorithm different from LFUN_SCREEN_DOWN?
cur.selHandle(true);
if (isBottomScreen()) {
lyx::dispatch(FuncRequest(LFUN_BUFFER_END_SELECT));
FuncRequest const fr = lyxaction.lookupFunc(commandstr);
// an arbitrary number to limit number of iterations
- const int max_iter = 10000;
+ const int max_iter = 100000;
int iterations = 0;
Cursor & cur = d->cursor_;
Cursor const savecur = cur;
break;
}
+ 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;
+ }
+
// FIXME We do not really want this here, but it has to be at present
// because we need a cursor for the recordUndoFullDocument call. What
// we would really like is a recordUndoBufferParams call that did not
// Notify left insets
if (cur != old) {
- old.fixIfBroken();
- bool badcursor = notifyCursorLeavesOrEnters(old, cur);
+ bool badcursor = old.fixIfBroken() | cur.fixIfBroken();
+ badcursor |= notifyCursorLeavesOrEnters(old, cur);
if (badcursor)
cursor().fixIfBroken();
}