frontend::WorkAreaManager & Buffer::workAreaManager() const
{
- LBUFERR(d->wa_, _("Unable to find WorkArea for Buffer!"));
+ LBUFERR(d->wa_);
return *d->wa_;
}
switch (cmd.action()) {
- case LFUN_BUFFER_TOGGLE_READ_ONLY:
- flag.setOnOff(isReadonly());
- break;
+ case LFUN_BUFFER_TOGGLE_READ_ONLY:
+ flag.setOnOff(isReadonly());
+ break;
// FIXME: There is need for a command-line import.
//case LFUN_BUFFER_IMPORT:
- case LFUN_BUFFER_AUTO_SAVE:
- break;
+ case LFUN_BUFFER_AUTO_SAVE:
+ break;
- case LFUN_BUFFER_EXPORT_CUSTOM:
- // FIXME: Nothing to check here?
- break;
+ case LFUN_BUFFER_EXPORT_CUSTOM:
+ // FIXME: Nothing to check here?
+ break;
- case LFUN_BUFFER_EXPORT: {
- docstring const arg = cmd.argument();
- if (arg == "custom") {
- enable = true;
- break;
- }
- string format = to_utf8(arg);
- size_t pos = format.find(' ');
- if (pos != string::npos)
- format = format.substr(0, pos);
- enable = params().isExportable(format);
- if (!enable)
- flag.message(bformat(
- _("Don't know how to export to format: %1$s"), arg));
+ case LFUN_BUFFER_EXPORT: {
+ docstring const arg = cmd.argument();
+ if (arg == "custom") {
+ enable = true;
break;
}
+ string format = to_utf8(arg);
+ size_t pos = format.find(' ');
+ if (pos != string::npos)
+ format = format.substr(0, pos);
+ enable = params().isExportable(format);
+ if (!enable)
+ flag.message(bformat(
+ _("Don't know how to export to format: %1$s"), arg));
+ break;
+ }
- case LFUN_BUFFER_CHKTEX:
- enable = params().isLatex() && !lyxrc.chktex_command.empty();
- break;
+ case LFUN_BUFFER_CHKTEX:
+ enable = params().isLatex() && !lyxrc.chktex_command.empty();
+ break;
- case LFUN_BUILD_PROGRAM:
- enable = params().isExportable("program");
- break;
+ case LFUN_BUILD_PROGRAM:
+ enable = params().isExportable("program");
+ break;
- case LFUN_BRANCH_ADD:
- case LFUN_BRANCHES_RENAME:
- case LFUN_BUFFER_PRINT:
- // if no Buffer is present, then of course we won't be called!
- break;
+ case LFUN_BRANCH_ACTIVATE:
+ 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 ? masterBuffer()->params().branchlist()
+ : params().branchlist();
+ docstring const branchName = cmd.argument();
+ flag.setEnabled(!branchName.empty() && branchList.find(branchName));
+ break;
+ }
- case LFUN_BUFFER_LANGUAGE:
- enable = !isReadonly();
- break;
+ case LFUN_BRANCH_ADD:
+ case LFUN_BRANCHES_RENAME:
+ case LFUN_BUFFER_PRINT:
+ // if no Buffer is present, then of course we won't be called!
+ break;
- default:
- return false;
+ case LFUN_BUFFER_LANGUAGE:
+ enable = !isReadonly();
+ break;
+
+ default:
+ return false;
}
flag.setEnabled(enable);
return true;
resetAutosaveTimers();
break;
+ case LFUN_BRANCH_ACTIVATE:
+ case LFUN_BRANCH_DEACTIVATE:
+ case LFUN_BRANCH_MASTER_ACTIVATE:
+ case LFUN_BRANCH_MASTER_DEACTIVATE: {
+ bool const master = (func.action() == LFUN_BRANCH_MASTER_ACTIVATE
+ || func.action() == LFUN_BRANCH_MASTER_DEACTIVATE);
+ Buffer * buf = master ? const_cast<Buffer *>(masterBuffer())
+ : this;
+
+ docstring const branch_name = func.argument();
+ // the case without a branch name is handled elsewhere
+ if (branch_name.empty()) {
+ dispatched = false;
+ break;
+ }
+ Branch * branch = buf->params().branchlist().find(branch_name);
+ if (!branch) {
+ LYXERR0("Branch " << branch_name << " does not exist.");
+ dr.setError(true);
+ docstring const msg =
+ bformat(_("Branch \"%1$s\" does not exist."), branch_name);
+ dr.setMessage(msg);
+ break;
+ }
+ bool const activate = (func.action() == LFUN_BRANCH_ACTIVATE
+ || func.action() == LFUN_BRANCH_MASTER_ACTIVATE);
+ if (branch->isSelected() != activate) {
+ buf->undo().recordUndoFullDocument(CursorData());
+ branch->setSelected(activate);
+ dr.setError(false);
+ dr.screenUpdate(Update::Force);
+ dr.forceBufferUpdate();
+ }
+ break;
+ }
+
case LFUN_BRANCH_ADD: {
docstring branch_name = func.argument();
if (branch_name.empty()) {
void Buffer::updateBuffer(UpdateScope scope, UpdateType utype) const
{
- LBUFERR(!text().paragraphs().empty(), _("Buffer error"));
+ LBUFERR(!text().paragraphs().empty());
// Use the master text class also for child documents
Buffer const * const master = masterBuffer();