#include "insets/InsetRef.h"
#include "insets/InsetText.h"
+#include "mathed/MathData.h"
+
#include "frontends/alert.h"
#include "frontends/Application.h"
#include "frontends/Delegates.h"
return Change(Change::UNCHANGED);
DocIterator dit = d->cursor_.selectionBegin();
+ // The selected content might have been changed (see #7685)
+ while (dit.inMathed())
+ // Find enclosing text cursor
+ dit.pop_back();
return dit.paragraph().lookupChange(dit.pos());
}
if (tm.contains(bot_pit)) {
ParagraphMetrics const & pm = tm.parMetrics(bot_pit);
- LBUFERR(!pm.rows().empty(), from_ascii(""));
+ LBUFERR(!pm.rows().empty());
// FIXME: smooth scrolling doesn't work in mathed.
CursorSlice const & cs = dit.innerTextSlice();
int offset = coordOffset(dit).y_;
case LFUN_BIBTEX_DATABASE_ADD:
case LFUN_BIBTEX_DATABASE_DEL:
case LFUN_STATISTICS:
- case LFUN_BRANCH_ADD_INSERT:
case LFUN_KEYMAP_OFF:
case LFUN_KEYMAP_PRIMARY:
case LFUN_KEYMAP_SECONDARY:
case LFUN_CHANGES_TRACK:
flag.setEnabled(true);
- flag.setOnOff(buffer_.params().trackChanges);
+ flag.setOnOff(buffer_.params().track_changes);
break;
case LFUN_CHANGES_OUTPUT:
flag.setEnabled(true);
- flag.setOnOff(buffer_.params().outputChanges);
+ flag.setOnOff(buffer_.params().output_changes);
break;
case LFUN_CHANGES_MERGE:
flag.setEnabled(cur.inset().allowParagraphCustomization(cur.idx()));
break;
+ case LFUN_BRANCH_ADD_INSERT:
+ flag.setEnabled(!(cur.inTexted() && cur.paragraph().isPassThru()));
+ break;
+
case LFUN_DIALOG_SHOW_NEW_INSET:
// FIXME: this is wrong, but I do not understand the
// intent (JMarc)
break;
}
- // FIXME We do not really want this here, but at present we need to
- // 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:
- 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;
- }
-
default:
return false;
}
}
case LFUN_CHANGES_TRACK:
- buffer_.params().trackChanges = !buffer_.params().trackChanges;
+ buffer_.params().track_changes = !buffer_.params().track_changes;
break;
case LFUN_CHANGES_OUTPUT:
- buffer_.params().outputChanges = !buffer_.params().outputChanges;
- if (buffer_.params().outputChanges) {
+ buffer_.params().output_changes = !buffer_.params().output_changes;
+ if (buffer_.params().output_changes) {
bool dvipost = LaTeXFeatures::isAvailable("dvipost");
bool xcolorulem = LaTeXFeatures::isAvailable("ulem") &&
LaTeXFeatures::isAvailable("xcolor");
case LFUN_WORD_FIND_FORWARD:
case LFUN_WORD_FIND_BACKWARD: {
+ // FIXME THREAD
+ // Would it maybe be better if this variable were view specific anyway?
static docstring last_search;
docstring searched_string;
docstring const data =
find2string(searched_string, true, false, fw);
bool found = lyxfind(this, FuncRequest(LFUN_WORD_FIND, data));
- if (found)
+ if (found) {
dr.screenUpdate(Update::Force | Update::FitCursor);
+ cur.dispatched();
+ dispatched = true;
+ } else {
+ cur.undispatched();
+ dispatched = false;
+ }
break;
}
lyx::dispatch(FuncRequest(LFUN_DIALOG_SHOW, "findreplace"));
break;
}
- if (lyxfind(this, req))
+ if (lyxfind(this, req)) {
dr.screenUpdate(Update::Force | Update::FitCursor);
- else
- message(_("String not found."));
+ cur.dispatched();
+ dispatched = true;
+ } else {
+ cur.undispatched();
+ dispatched = false;
+ }
d->search_request_cache_ = req;
break;
}
if (lyxreplace(this, cmd, has_deleted)) {
dr.forceBufferUpdate();
dr.screenUpdate(Update::Force | Update::FitCursor);
+ cur.dispatched();
+ dispatched = true;
+ } else {
+ cur.undispatched();
+ dispatched = false;
}
break;
}
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
- // need a cursor, but we do not have that yet.
- // 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:
- 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 = 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 activate = (cmd.action() == LFUN_BRANCH_ACTIVATE
- || cmd.action() == LFUN_BRANCH_MASTER_ACTIVATE);
- if (branch->isSelected() != activate) {
- branch->setSelected(activate);
- cur.recordUndoFullDocument();
- dr.setError(false);
- dr.screenUpdate(Update::Force);
- dr.forceBufferUpdate();
- }
- break;
- }
-
default:
// OK, so try the Buffer itself...
buffer_.dispatch(cmd, dr);
TextMetrics & BufferView::textMetrics(Text const * t)
{
- LBUFERR(t, from_ascii(""));
+ LBUFERR(t);
TextMetricsCache::iterator tmc_it = d->text_metrics_.find(t);
if (tmc_it == d->text_metrics_.end()) {
tmc_it = d->text_metrics_.insert(
return false;
d->cursor_ = cur;
+
+ // we would rather not do this here, but it needs to be done before
+ // the changed() signal is sent.
+ buffer_.updateBuffer();
- cur.forceBufferUpdate();
- cur.screenUpdateFlags(Update::Force);
+ buffer_.changed(true);
return true;
}
bool BufferView::selectIfEmpty(DocIterator & cur)
{
- if (!cur.paragraph().empty())
+ if ((cur.inTexted() && !cur.paragraph().empty())
+ || (cur.inMathed() && !cur.cell().empty()))
return false;
pit_type const beg_pit = cur.pit();
TextMetrics const & tm = textMetrics(sl.text());
ParagraphMetrics const & pm = tm.parMetrics(sl.pit());
- LBUFERR(!pm.rows().empty(), from_ascii(""));
+ LBUFERR(!pm.rows().empty());
y -= pm.rows()[0].ascent();
#if 1
// FIXME: document this mess