return 0;
}
+
/// Note that comparing contents can only be used for InsetCommand
bool findNextInset(DocIterator & dit, vector<InsetCode> const & codes,
docstring const & contents)
}
-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).
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));
// handle their dispatch here, for reasons explained there, so we'll
// handle this here, too, for consistency.
case LFUN_BRANCH_ACTIVATE:
- case LFUN_BRANCH_DEACTIVATE: {
- BranchList const & branchList = buffer().params().branchlist();
+ case LFUN_BRANCH_DEACTIVATE:
+ case LFUN_BRANCH_MASTER_ACTIVATE:
+ case LFUN_BRANCH_MASTER_DEACTIVATE: {
+ bool const master = (cmd.action() == LFUN_BRANCH_MASTER_ACTIVATE
+ || cmd.action() == LFUN_BRANCH_MASTER_DEACTIVATE);
+ BranchList const & branchList = master ? buffer().masterBuffer()->params().branchlist()
+ : buffer().params().branchlist();
docstring const branchName = cmd.argument();
flag.setEnabled(!branchName.empty() && branchList.find(branchName));
break;
void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
{
- //lyxerr << [ cmd = " << cmd << "]" << endl;
-
- // Make sure that the cached BufferView is correct.
- LYXERR(Debug::ACTION, " action[" << cmd.action() << ']'
- << " arg[" << to_utf8(cmd.argument()) << ']'
- << " x[" << cmd.x() << ']'
- << " y[" << cmd.y() << ']'
- << " button[" << cmd.button() << ']');
+ LYXERR(Debug::ACTION, "BufferView::dispatch: cmd: " << cmd);
string const argument = to_utf8(cmd.argument());
Cursor & cur = d->cursor_;
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:");
//FIXME: what to do with cur.x_target()?
bool update = in_texted && cur.bv().checkDepm(cur, old);
cur.finishUndo();
- if (update || cur.selection()) {
- 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;
cur.setCurrentFont();
dr.forceBufferUpdate();
}
+ break;
}
case LFUN_FILE_INSERT_PLAINTEXT_PARA:
// So, if this does get fixed, this code can be moved back to Buffer.cpp,
// and the corresponding code in getStatus() should be moved back, too.
case LFUN_BRANCH_ACTIVATE:
- case LFUN_BRANCH_DEACTIVATE: {
- BranchList & branch_list = buffer().params().branchlist();
+ case LFUN_BRANCH_DEACTIVATE:
+ case LFUN_BRANCH_MASTER_ACTIVATE:
+ case LFUN_BRANCH_MASTER_DEACTIVATE: {
+ bool const master = (cmd.action() == LFUN_BRANCH_MASTER_ACTIVATE
+ || cmd.action() == LFUN_BRANCH_MASTER_DEACTIVATE);
+ Buffer * buf = master ? const_cast<Buffer *>(buffer().masterBuffer())
+ : &buffer();
+
docstring const branch_name = cmd.argument();
// the case without a branch name is handled elsewhere
if (branch_name.empty()) {
dispatched = false;
break;
}
- Branch * branch = branch_list.find(branch_name);
+ Branch * branch = buf->params().branchlist().find(branch_name);
if (!branch) {
LYXERR0("Branch " << branch_name << " does not exist.");
dr.setError(true);
dr.setMessage(msg);
break;
}
- bool activate = cmd.action() == LFUN_BRANCH_ACTIVATE;
+ bool activate = (cmd.action() == LFUN_BRANCH_ACTIVATE
+ || cmd.action() == LFUN_BRANCH_MASTER_ACTIVATE);
if (branch->isSelected() != activate) {
branch->setSelected(activate);
cur.recordUndoFullDocument();
// 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();
}
cap::saveSelection(cursor());
d->cursor_.macroModeClose();
+ // If a macro has been finalized, the cursor might have been broken
+ cur.fixIfBroken();
// Has the cursor just left the inset?
bool const leftinset = (&d->cursor_.inset() != &cur.inset());