+2005-08-03 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
+
+ * text.C (read): remove unused variable.
+ (readParToken): remove static Change variable (never good in
+ recursive settings...); add it as a parameter instead.
+
+ * paragraph_pimpl.C (acceptChange): make debug info conditional.
+
+ * metricsinfo.C (PainterInfo): add new member erased_.
+
+ * rowpainter.C (RowPainter): add erased_ member, initialized from
+ PainterInfo.
+ (paintInset): pass erased_ to Inset::draw.
+
+ * lyxfunc.C (lookupChange): new function. Tells whether change
+ tracking is disabled at a given postion.
+ (getStatus): disable some actions when in deleted text with change
+ tracking.
+
+2005-08-03 John Levon <levon@movementarian.org>
+
+ * tabular.C (appendColumn, setMultiColumn): adapt to change to
+ InsetText::clear().
+
+ * paragraph_pimpl.C (markErased): add bool argument and handle it.
+ Also make sure to mark insets recursively.
+ (rejectChange, erase): be recursive
+
+ * paragraph.C (markErased): add bool argument.
2005-08-04 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* lyxfind.C (findNextChange): tiny cleanup.
+2005-08-03 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
+
+ * insettabular.C (draw): pass PainterInfro::erased_ to
+ drawCellLines
+ (drawCellLines): add an erased bool and handle it.
+
+2005-08-03 John Levon <levon@movementarian.org>
+
+ * insettext.C (clear): remove bool argument.
+ (read): adapt to clear() changes.
+
+ * insettabular.C (cutSelection): adapt to MarkErased changes.
+
+ * insettext.C (markErased):
+ * insettabular.C (markErased):
+ * insetbase.C (markErased): add bool argument.
+
2005-09-06 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* insettabular.C: mark tabular_stack_ (of CutAndPaste) dirty
}
-void InsetBase::markErased()
+void InsetBase::markErased(bool)
{}
virtual mode_type currentMode() const { return UNDECIDED_MODE; }
/// returns whether this inset is allowed in other insets of given mode
virtual bool allowedIn(mode_type) const { return true; }
-
/// is this inset allowed within a font change?
virtual bool noFontChange() const { return false; }
- ///
- virtual void markErased();
+ /// mark the inset as erased or not
+ virtual void markErased(bool erased);
+
/// pretty arbitrary
virtual int width() const { return 10; }
/// pretty arbitrary
|| y + d < 0
|| y - a > bv->workHeight()) {
cell(idx)->draw(nullpi, cx, y);
- drawCellLines(nop, nx, y, i, idx);
+ drawCellLines(nop, nx, y, i, idx, pi.erased_);
} else {
cell(idx)->draw(pi, cx, y);
- drawCellLines(pi.pain, nx, y, i, idx);
+ drawCellLines(pi.pain, nx, y, i, idx, pi.erased_);
}
nx += tabular.getWidthOfColumn(idx);
++idx;
void InsetTabular::drawCellLines(Painter & pain, int x, int y,
- row_type row, idx_type cell) const
+ row_type row, idx_type cell, bool erased) const
{
int x2 = x + tabular.getWidthOfColumn(cell);
bool on_off = false;
+ LColor::color col = LColor::tabularline;
+ LColor::color onoffcol = LColor::tabularonoffline;
+
+ if (erased) {
+ col = LColor::strikeout;
+ onoffcol = LColor::strikeout;
+ }
if (!tabular.topAlreadyDrawn(cell)) {
on_off = !tabular.topLine(cell);
pain.line(x, y - tabular.getAscentOfRow(row),
x2, y - tabular.getAscentOfRow(row),
- on_off ? LColor::tabularonoffline : LColor::tabularline,
+ on_off ? onoffcol : col,
on_off ? Painter::line_onoffdash : Painter::line_solid);
}
on_off = !tabular.bottomLine(cell);
pain.line(x, y + tabular.getDescentOfRow(row),
x2, y + tabular.getDescentOfRow(row),
- on_off ? LColor::tabularonoffline : LColor::tabularline,
+ on_off ? onoffcol : col,
on_off ? Painter::line_onoffdash : Painter::line_solid);
if (!tabular.leftAlreadyDrawn(cell)) {
on_off = !tabular.leftLine(cell);
pain.line(x, y - tabular.getAscentOfRow(row),
x, y + tabular.getDescentOfRow(row),
- on_off ? LColor::tabularonoffline : LColor::tabularline,
+ on_off ? onoffcol : col,
on_off ? Painter::line_onoffdash : Painter::line_solid);
}
on_off = !tabular.rightLine(cell);
y - tabular.getAscentOfRow(row),
x2 - tabular.getAdditionalWidth(cell),
y + tabular.getDescentOfRow(row),
- on_off ? LColor::tabularonoffline : LColor::tabularline,
+ on_off ? onoffcol : col,
on_off ? Painter::line_onoffdash : Painter::line_solid);
}
void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
{
- lyxerr << "# InsetTabular::dispatch: cmd: " << cmd << endl;
+ lyxerr << "# InsetTabular::doDispatch: cmd: " << cmd << endl;
lyxerr << " cur:\n" << cur << endl;
CursorSlice sl = cur.top();
LCursor & bvcur = cur.bv().cursor();
if (!cur.selection())
return;
- bool const track = cur.buffer().params().tracking_changes;
row_type rs, re;
col_type cs, ce;
getSelection(cur, rs, re, cs, ce);
- for (row_type i = rs; i <= re; ++i)
- for (col_type j = cs; j <= ce; ++j)
- cell(tabular.getCellNumber(i, j))->clear(track);
+ for (row_type i = rs; i <= re; ++i) {
+ for (col_type j = cs; j <= ce; ++j) {
+ shared_ptr<InsetText> t
+ = cell(tabular.getCellNumber(i, j));
+ if (cur.buffer().params().tracking_changes)
+ t->markErased(true);
+ else
+ t->clear();
+ }
+ }
// cursor position might be invalid now
cur.pos() = cur.lastpos();
}
-void InsetTabular::markErased()
+void InsetTabular::markErased(bool erased)
{
for (idx_type idx = 0; idx < nargs(); ++idx)
- cell(idx)->markErased();
+ cell(idx)->markErased(erased);
}
LyXText * getText(int) const;
///
- void markErased();
+ void markErased(bool);
// this should return true if we have a "normal" cell, otherwise true.
// "normal" means without width set!
///
void drawCellLines(Painter &, int x, int y, row_type row,
- idx_type cell) const;
+ idx_type cell, bool erased) const;
///
void setCursorFromCoordinates(LCursor & cur, int x, int y) const;
}
-void InsetText::clear(bool just_mark_erased)
+void InsetText::markErased(bool erased)
+{
+ ParagraphList & pars = paragraphs();
+ for_each(pars.begin(), pars.end(),
+ bind(&Paragraph::markErased, _1, erased));
+}
+
+
+void InsetText::clear()
{
ParagraphList & pars = paragraphs();
- if (just_mark_erased) {
- for_each(pars.begin(), pars.end(),
- bind(&Paragraph::markErased, _1));
- return;
- }
// This is a gross hack...
LyXLayout_ptr old_layout = pars.begin()->layout();
void InsetText::read(Buffer const & buf, LyXLex & lex)
{
- clear(false);
+ clear();
#ifdef WITH_WARNINGS
#warning John, look here. Doesnt make much sense.
void InsetText::setText(string const & data, LyXFont const & font)
{
- clear(false);
+ clear();
Paragraph & first = paragraphs().front();
for (unsigned int i = 0; i < data.length(); ++i)
first.insertChar(i, data[i], font);
explicit InsetText(BufferParams const &);
///
InsetText();
- /// empty inset to empty par, or just mark as erased
- void clear(bool just_mark_erased);
+ /// empty inset to empty par
+ void clear();
///
void read(Buffer const & buf, LyXLex & lex);
///
bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
/// mark as erased for change tracking
- void markErased() { clear(true); }
+ void markErased(bool erased);
+
/**
* Mark as new. Used when pasting in tabular, and adding rows
* or columns. Note that pasting will ensure that tracking already
return res;
}
+
+/** 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).
+ * When \param outer is true, the top slice is not looked at.
+ */
+Change::Type lookupChange(DocIterator const & dit, bool outer = false)
+{
+ size_t const depth = dit.depth() - outer ? 1 : 0;
+
+ for (size_t i = 0 ; i < depth ; ++i) {
+ CursorSlice const & slice = dit[i];
+ if (!slice.inset().inMathed()
+ && slice.pos() < slice.paragraph().size()) {
+ Change::Type const ch = slice.paragraph().lookupChange(slice.pos());
+ if (ch != Change::UNCHANGED)
+ return ch;
+ }
+ }
+ return Change::UNCHANGED;
+}
+
}
LyXFunc::LyXFunc(LyXView * lv)
flag.enabled(false);
}
+ // Are we in a DELETED change-tracking region?
+ if (buf && buf->params().tracking_changes
+ && lookupChange(cur, true) == Change::DELETED
+ && !lyxaction.funcHasFlag(cmd.action, LyXAction::ReadOnly)
+ && !lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)) {
+ flag.message(N_("This portion of the document is deleted."));
+ flag.enabled(false);
+ }
+
// the default error message if we disable the command
if (!flag.enabled() && flag.message().empty())
flag.message(N_("Command disabled"));
PainterInfo::PainterInfo(BufferView * bv, Painter & painter)
- : pain(painter), ltr_pos(false)
+ : pain(painter), ltr_pos(false), erased_(false)
{
base.bv = bv;
}
Painter & pain;
/// Whether the text at this point is right-to-left (for InsetNewline)
bool ltr_pos;
+ /// Whether the parent is deleted (change tracking)
+ bool erased_;
};
class TextMetricsInfo {};
}
-void Paragraph::markErased()
+void Paragraph::markErased(bool erased)
{
- pimpl_->markErased();
+ pimpl_->markErased(erased);
}
/// reject change
void rejectChange(lyx::pos_type start, lyx::pos_type end);
- /// mark whole par as erased
- void markErased();
+ /// mark whole par as erased or not
+ void markErased(bool erased);
/// Paragraphs can contain "manual labels", for example, Description
/// environment. The text for this user-editable label is stored in
}
-void Paragraph::Pimpl::markErased()
+void Paragraph::Pimpl::markErased(bool erased)
{
BOOST_ASSERT(tracking());
- // FIXME: we should actually remove INSERTED chars.
- // difficult because owning insettexts/tabulars need
- // to update themselves when rows etc. change
- changes_->set(Change::DELETED, 0, size());
- changes_->reset(Change::DELETED);
+ if (erased) {
+ erase(0, size());
+ } else {
+ pos_type i = 0;
+
+ for (pos_type i = 0; i < size(); ++i) {
+ changes_->set(Change::UNCHANGED, i);
+ if (owner_->isInset(i))
+ owner_->getInset(i)->markErased(false);
+ }
+ }
}
return;
}
- lyxerr << "acceptchange" << endl;
+ lyxerr[Debug::CHANGES] << "acceptchange" << endl;
pos_type i = start;
for (; i < end; ++i) {
}
}
- lyxerr << "endacceptchange" << endl;
+ lyxerr[Debug::CHANGES] << "endacceptchange" << endl;
changes_->reset(Change::UNCHANGED);
}
case Change::DELETED:
changes_->set(Change::UNCHANGED, i);
+ if (owner_->isInset(i))
+ owner_->getInset(i)->markErased(false);
break;
}
}
// only allow the actual removal if it was /new/ text
if (changetype != Change::INSERTED) {
- if (owner_->text_[pos] == Paragraph::META_INSET) {
- owner_->getInset(pos)->markErased();
- }
+ if (owner_->isInset(pos))
+ owner_->getInset(pos)->markErased(true);
return false;
}
}
/// set change at pos
void setChange(lyx::pos_type pos, Change::Type type);
/// mark as erased
- void markErased();
+ void markErased(bool);
/// accept change
void acceptChange(lyx::pos_type start, lyx::pos_type end);
/// reject change
pit_type const pit_;
Paragraph const & par_;
+ /// is row erased? (change tracking)
+ bool erased_;
+
// Looks ugly - is
double const xo_;
int const yo_; // current baseline
LyXText const & text, pit_type pit, Row const & row, int x, int y)
: bv_(*pi.base.bv), pain_(pi.pain), text_(text), pars_(text.paragraphs()),
row_(row), pit_(pit), par_(text.paragraphs()[pit]),
+ erased_(pi.erased_),
xo_(x), yo_(y), width_(text_.width())
{
RowMetrics m = text_.computeRowMetrics(pit, row_);
PainterInfo pi(const_cast<BufferView *>(&bv_), pain_);
pi.base.font = font;
pi.ltr_pos = (text_.bidi.level(pos) % 2 == 0);
+ pi.erased_ = erased_ || isDeletedText(par_, pos);
theCoords.insets().add(inset, int(x_), yo_);
inset->drawSelection(pi, int(x_), yo_);
inset->draw(pi, int(x_), yo_);
double const orig_x = x_;
- char const c = par_.getChar(pos);
-
- if (c == Paragraph::META_INSET) {
+ if (par_.isInset(pos)) {
paintInset(pos, orig_font);
++vpos;
paintForeignMark(orig_x, orig_font);
}
// usual characters, no insets
+ char const c = par_.getChar(pos);
// special case languages
std::string const & lang = orig_font.language()->lang();
}
//++column;
for (row_type i = 0; i < rows_; ++i) {
- cell_info[i][column + 1].inset->clear(false);
+ cell_info[i][column + 1].inset->clear();
if (bp.tracking_changes)
cell_info[i][column + 1].inset->markNew(true);
}
cellstruct & cs1 = cellinfo_of_cell(cell + i);
cs1.multicolumn = CELL_PART_OF_MULTICOLUMN;
cs.inset->appendParagraphs(buffer, cs1.inset->paragraphs());
- cs1.inset->clear(false);
+ cs1.inset->clear();
}
set_row_column_number_info();
}
void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex,
- string const & token, LyXFont & font)
+ string const & token, LyXFont & font, Change & change)
{
- static Change change;
-
BufferParams const & bp = buf.params();
if (token[0] != '\\') {
lex.nextToken();
string token = lex.getString();
LyXFont font;
+ Change change;
while (lex.isOK()) {
- readParToken(buf, par, lex, token, font);
+ readParToken(buf, par, lex, token, font, change);
lex.nextToken();
token = lex.getString();
bool LyXText::read(Buffer const & buf, LyXLex & lex)
{
- static Change current_change;
-
Paragraph::depth_type depth = 0;
while (lex.isOK()) {