if (find(labels.begin(),labels.end(),label) != labels.end()) {
text()->clearSelection();
text()->setCursor(
- std::distance(text()->ownerParagraphs().begin(), it.getPar()),
+ std::distance(text()->paragraphs().begin(), it.getPar()),
it.getPos());
text()->selection.cursor = text()->cursor;
update();
return t->cursorPar()->getFont(
buffer()->params(),
t->cursor.pos(),
- outerFont(t->cursorPar(), t->ownerParagraphs())
+ outerFont(t->cursorPar(), t->paragraphs())
).language()->encoding();
}
+
+2003-12-01 André Pönitz <poenitz@gmx.net>
+
+ * buffer.[Ch]:
+ * lyxtext.h: move ParagraphList member to LyXText
+ rename LyXText::ownerParagraphs to LyXText::paragraph
+
+ * CutAndPaste.C:
+ * bufferview_funcs.C:
+ * iterators.[Ch]:
+ * lyx_cb.C:
+ * paragraph.C:
+ * rowpainter.C:
+ * tabular.C:
+ * text.C:
+ * text2.C:
+ * text3.C: adjust
+
+ * lyxfunc.C: move LFUN_INSET_TOGGLE handling to insets.
+
+ * undo.C: fix cursor positioning
+
2003-12-01 John Levon <levon@movementarian.org>
* BufferView_pimpl.C: fix a crash on exit with
BOOST_ASSERT(0 <= end && end <= endpit->size());
BOOST_ASSERT(startpit != endpit || start <= end);
- ParagraphList paragraphs;
// Clone the paragraphs within the selection.
ParagraphList::iterator postend = boost::next(endpit);
- paragraphs.assign(startpit, postend);
+ ParagraphList paragraphs(startpit, postend);
for_each(paragraphs.begin(), paragraphs.end(), resetOwnerAndChanges());
// Cut out the end of the last paragraph.
limited_stack<Undo> undostack;
limited_stack<Undo> redostack;
BufferParams params;
- ParagraphList paragraphs;
LyXVC lyxvc;
string temppath;
bool nicefile;
: nicefile(true),
lyx_clean(true), bak_clean(true), unnamed(false), read_only(readonly_),
filename(file), filepath(OnlyPath(file)), file_fully_loaded(false),
- text(0, 0, 0, paragraphs)
+ text(0, 0)
{
lyxvc.buffer(&parent);
if (readonly_ || lyxrc.use_tempdir)
bformat(_("Could not remove the temporary directory %1$s"), temppath()));
}
- paragraphs().clear();
-
// Remove any previewed LaTeX snippets associated with this buffer.
lyx::graphics::Previews::get().removeLoader(*this);
}
ParagraphList & Buffer::paragraphs()
{
- return pimpl_->paragraphs;
+ return pimpl_->text.paragraphs();
}
ParagraphList const & Buffer::paragraphs() const
{
- return pimpl_->paragraphs;
+ return pimpl_->text.paragraphs();
}
// needed to insert the selection
void Buffer::insertStringAsLines(ParagraphList::iterator & par, pos_type & pos,
- LyXFont const & fn,string const & str)
+ LyXFont const & fn, string const & str)
{
LyXLayout_ptr const & layout = par->layout();
bv->getLyXText()->clearSelection();
- LyXText * text = par.text(bv);
+ LyXText * text = par.text(*bv->buffer());
par.lockPath(bv);
//hack for the chicken and egg problem
if (par.inset())
+
+2003-12-01 André Pönitz <poenitz@gmx.net>
+
+ * insetbase.h: whitespace
+
+ * inset.[Ch]: remove latexTextWidth
+ make setBackgroundColor virtual
+
+ * insettext.[Ch]: move ParagraphList member to LyXText
+
+ * insetcollapsable.[Ch]: handle LFUN_INSET_TOGGLE
+
+ * insetcharstyle.C:
+ * insetenv.C:
+ * insetert.[Ch]:
+ * insetfloat.[Ch]:
+ * insetminipage.[Ch]:
+ * insettabular.C:
+ * insetwrap.[Ch]: adjust paragraphs and background color handling,
+
2003-11-28 Angus Leeming <leeming@lyx.org>
* insetvspace.[Ch] (d-tor, priv_dispatch): new member functions,
InsetOld::InsetOld()
: InsetBase(),
- xo_(0), yo_(0), scx(0), owner_(0),
- background_color_(LColor::inherit)
+ xo_(0), yo_(0), scx(0), owner_(0),
+ //background_color_(LColor::inherit)
+ background_color_(LColor::background)
{}
InsetOld::InsetOld(InsetOld const & in)
: InsetBase(),
- xo_(0), yo_(0), scx(0), owner_(0),
- name_(in.name_), background_color_(in.background_color_)
+ xo_(0), yo_(0), scx(0), owner_(0), name_(in.name_),
+ background_color_(in.background_color_)
{}
}
-#if 0
-LyXFont const InsetOld::convertFont(LyXFont const & font) const
-{
-#if 1
- return font;
-#else
- return LyXFont(font);
-#endif
-}
-#endif
-
-
string const InsetOld::editMessage() const
{
return _("Opened inset");
LColor_color InsetOld::backgroundColor() const
{
- if (background_color_ == LColor::inherit) {
- if (owner())
- return owner()->backgroundColor();
- else
- return LColor::background;
- } else
- return LColor::color(background_color_);
+ return LColor::color(background_color_);
}
return false;
}
-int InsetOld::latexTextWidth(BufferView * bv) const
-{
- if (owner())
- return (owner()->latexTextWidth(bv));
- return bv->workWidth();
-}
-
int InsetOld::ascent() const
{
}
-bool InsetOld::checkInsertChar(LyXFont &)
-{
- return false;
-}
-
-
int InsetOld::scroll(bool recursive) const
{
if (!recursive || !owner_)
///
UpdatableInset * owner() const { return owner_; }
///
- void setBackgroundColor(LColor_color);
+ virtual void setBackgroundColor(LColor_color);
///
LColor_color backgroundColor() const;
///
virtual void open() {}
/// close the inset
virtual void close() const {}
- /// check if the font of the char we want inserting is correct
- /// and modify it if it is not.
- virtual bool checkInsertChar(LyXFont &);
// should this inset be handled like a normal charater
virtual bool isChar() const { return false; }
// is this equivalent to a letter?
virtual bool noFontChange() const { return false; }
//
virtual void getDrawFont(LyXFont &) const {}
- /* needed for widths which are % of something
- returns the value of \textwidth in this inset. Most of the
- time this is the width of the workarea, but if there is a
- minipage somewhere, it will be the width of this minipage */
- virtual int latexTextWidth(BufferView *) const;
/// mark the inset contents as erased (for change tracking)
virtual void markErased() {}
DispatchResult
dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
// the real dispatcher
- DispatchResult
- dispatch(FuncRequest const & cmd);
+ DispatchResult dispatch(FuncRequest const & cmd);
/// cursor enters
virtual void edit(BufferView * bv, bool left);
int outputVerbatim(std::ostream & os, InsetText inset)
{
int lines = 0;
- ParagraphList::iterator par = inset.paragraphs.begin();
- ParagraphList::iterator end = inset.paragraphs.end();
+ ParagraphList::iterator par = inset.paragraphs().begin();
+ ParagraphList::iterator end = inset.paragraphs().end();
while (par != end) {
lyx::pos_type siz = par->size();
for (lyx::pos_type i = 0; i < siz; ++i) {
xo_ = x;
yo_ = y;
- if (!isOpen()) {
+ if (collapsed_) {
draw_collapsed(pi, x, y);
return;
}
void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
{
- // by default, we are not inlined-drawing
+ // by default we don't draw inline
draw(pi, x, y, false);
}
lyxerr << "InsetCollapsable: edit xy" << endl;
if (collapsed_) {
collapsed_ = false;
- // set this only here as it should be recollapsed only if
- // it was already collapsed!
- inset.edit(bv, x, y);
} else {
if (y <= button_dim.y2)
- inset.edit(bv, x, 0);
+ y = 0;
else
- inset.edit(bv, x, ascent() + y - height_collapsed() + inset.ascent());
+ y += inset.ascent() - height_collapsed();
}
-
+ inset.edit(bv, x, y);
bv->cursor().push(this);
}
return lfunMouseRelease(cmd);
return DispatchResult(true, true);
+ case LFUN_INSET_TOGGLE:
+ if (!inset.text_.toggleInset())
+ close();
+ return DispatchResult(true, true);
+
default:
return inset.dispatch(adjustCommand(cmd));
}
void InsetCollapsable::getCursorPos(int & x, int & y) const
{
- inset.getCursorPos(x , y);
+ inset.getCursorPos(x, y);
y += - ascent() + height_collapsed() + inset.ascent();
}
void InsetCollapsable::open()
{
- if (!collapsed_)
- return;
-
collapsed_ = false;
}
void InsetCollapsable::close() const
{
- if (collapsed_)
- return;
-
collapsed_ = true;
}
labelfont_ = f;
}
+
#if 0
void InsetCollapsable::setAutoCollapse(bool f)
{
}
#endif
-void InsetCollapsable::scroll(BufferView *bv, float sx) const
+
+void InsetCollapsable::scroll(BufferView * bv, float sx) const
{
UpdatableInset::scroll(bv, sx);
}
-void InsetCollapsable::scroll(BufferView *bv, int offset) const
+void InsetCollapsable::scroll(BufferView * bv, int offset) const
{
UpdatableInset::scroll(bv, offset);
}
return button_dim;
}
+
+void InsetCollapsable::setBackgroundColor(LColor_color color)
+{
+ InsetOld::setBackgroundColor(color);
+ inset.setBackgroundColor(color);
+}
void markErased();
///
void addPreview(lyx::graphics::PreviewLoader &) const;
+ ///
+ void setBackgroundColor(LColor_color);
protected:
///
{
os << layout_->latexheader;
TexRow texrow;
- latexParagraphs(buf, paragraphs, os, texrow, runparams,
+ latexParagraphs(buf, paragraphs(), os, texrow, runparams,
layout_->latexparagraph);
os << layout_->latexfooter;
return texrow.rows();
string::const_iterator end = contents.end();
pos_type pos = 0;
for (; cit != end; ++cit) {
- inset.paragraphs.begin()->insertChar(pos++, *cit, font);
+ inset.paragraphs().begin()->insertChar(pos++, *cit, font);
}
// the init has to be after the initialization of the paragraph
// because of the label settings (draw_label for ert insets).
font.setFamily(LyXFont::TYPEWRITER_FAMILY);
font.setColor(LColor::latex);
- ParagraphList::iterator pit = inset.paragraphs.begin();
- ParagraphList::iterator pend = inset.paragraphs.end();
+ ParagraphList::iterator pit = inset.paragraphs().begin();
+ ParagraphList::iterator pend = inset.paragraphs().end();
for (; pit != pend; ++pit) {
pos_type siz = pit->size();
for (pos_type i = 0; i < siz; ++i) {
//inset.writeParagraphData(buf, os);
string const layout(buf.params().getLyXTextClass().defaultLayoutName());
- ParagraphList::iterator par = inset.paragraphs.begin();
- ParagraphList::iterator end = inset.paragraphs.end();
+ ParagraphList::iterator par = inset.paragraphs().begin();
+ ParagraphList::iterator end = inset.paragraphs().end();
for (; par != end; ++par) {
os << "\n\\begin_layout " << layout << "\n";
pos_type siz = par->size();
int InsetERT::latex(Buffer const &, ostream & os,
OutputParams const &) const
{
- ParagraphList::iterator par = inset.paragraphs.begin();
- ParagraphList::iterator end = inset.paragraphs.end();
+ ParagraphList::iterator par = inset.paragraphs().begin();
+ ParagraphList::iterator end = inset.paragraphs().end();
int lines = 0;
while (par != end) {
int InsetERT::linuxdoc(Buffer const &, ostream & os,
OutputParams const &)const
{
- ParagraphList::iterator par = inset.paragraphs.begin();
- ParagraphList::iterator end = inset.paragraphs.end();
+ ParagraphList::iterator par = inset.paragraphs().begin();
+ ParagraphList::iterator end = inset.paragraphs().end();
int lines = 0;
while (par != end) {
int InsetERT::docbook(Buffer const &, ostream & os,
OutputParams const &) const
{
- ParagraphList::iterator par = inset.paragraphs.begin();
- ParagraphList::iterator end = inset.paragraphs.end();
+ ParagraphList::iterator par = inset.paragraphs().begin();
+ ParagraphList::iterator end = inset.paragraphs().end();
int lines = 0;
while (par != end) {
{
BufferView * bv = cmd.view();
- if (inset.paragraphs.begin()->empty())
+ if (inset.paragraphs().begin()->empty())
setLatexFont(bv);
switch (cmd.action) {
return DispatchResult(true, true);
case LFUN_LAYOUT:
- bv->owner()->setLayout(inset.paragraphs.begin()->layout()->name());
+ bv->owner()->setLayout(inset.paragraphs().begin()->layout()->name());
return DispatchResult(true);
case LFUN_BREAKPARAGRAPH:
{
string la;
pos_type const max_length = 15;
- pos_type const p_siz = inset.paragraphs.begin()->size();
+ pos_type const p_siz = inset.paragraphs().begin()->size();
pos_type const n = min(max_length, p_siz);
pos_type i = 0;
pos_type j = 0;
for( ; i < n && j < p_siz; ++j) {
- if (inset.paragraphs.begin()->isInset(j))
+ if (inset.paragraphs().begin()->isInset(j))
continue;
- la += inset.paragraphs.begin()->getChar(j);
+ la += inset.paragraphs().begin()->getChar(j);
++i;
}
- if (inset.paragraphs.size() > 1 || (i > 0 && j < p_siz)) {
+ if (inset.paragraphs().size() > 1 || (i > 0 && j < p_siz)) {
la += "...";
}
if (la.empty()) {
}
-bool InsetERT::checkInsertChar(LyXFont & /* font */)
-{
-#ifdef SET_HARD_FONT
- LyXFont font(LyXFont::ALL_INHERIT, latex_language);
- font.setFamily(LyXFont::TYPEWRITER_FAMILY);
- font.setColor(LColor::latex);
-#endif
- return true;
-}
-
-
void InsetERT::metrics(MetricsInfo & mi, Dimension & dim) const
{
setButtonLabel();
///
void validate(LaTeXFeatures &) const {}
///
- bool checkInsertChar(LyXFont &);
- ///
// these are needed here because of the label/inlined functionallity
///
bool isOpen() const { return status_ == Open || status_ == Inlined; }
setInsetName(type);
LyXTextClass const & tclass = bp.getLyXTextClass();
if (tclass.hasLayout(caplayout))
- inset.paragraphs.begin()->layout(tclass[caplayout]);
+ inset.paragraphs().begin()->layout(tclass[caplayout]);
}
-InsetFloat::InsetFloat(InsetFloat const & in)
- : InsetCollapsable(in), params_(in.params_)
-{}
-
-
InsetFloat::~InsetFloat()
{
InsetFloatMailer(*this).hideDialog();
bool InsetFloat::insetAllowed(InsetOld::Code code) const
{
- if (code == InsetOld::FLOAT_CODE)
- return false;
- if (code == InsetOld::FOOT_CODE || code == InsetOld::MARGIN_CODE)
- return false;
- return true;
+ return code != InsetOld::FLOAT_CODE
+ && code != InsetOld::FOOT_CODE
+ && code != InsetOld::MARGIN_CODE;
}
void InsetFloat::addToToc(lyx::toc::TocList & toclist, Buffer const & buf) const
{
- ParIterator pit(inset.paragraphs.begin(), inset.paragraphs);
- ParIterator end(inset.paragraphs.end(), inset.paragraphs);
+ ParIterator pit(inset.paragraphs().begin(), inset.paragraphs());
+ ParIterator end(inset.paragraphs().end(), inset.paragraphs());
// Find a caption layout in one of the (child inset's) pars
for (; pit != end; ++pit) {
///
InsetFloat(BufferParams const &, std::string const &);
///
- InsetFloat(InsetFloat const &);
- ///
~InsetFloat();
///
void write(Buffer const & buf, std::ostream & os) const;
}
-int InsetMinipage::latexTextWidth(BufferView * bv) const
-{
- return params_.width.inPixels(InsetCollapsable::latexTextWidth(bv));
-}
-
-
InsetMinipage::Params::Params()
- : pos(center),
- inner_pos(inner_center),
- width(100, LyXLength::PCW)
+ : pos(center), inner_pos(inner_center), width(100, LyXLength::PCW)
{}
///
bool showInsetDialog(BufferView *) const;
///
- int latexTextWidth(BufferView *) const;
- ///
void params(Params const & p) { params_ = p; }
///
Params const & params() const { return params_; }
++actcell;
}
if (lock) {
- bool rtl = tabular.getCellInset(actcell).paragraphs.begin()->
+ bool rtl = tabular.getCellInset(actcell).paragraphs().begin()->
isRightToLeftPar(bv->buffer()->params());
activateCellInset(bv, 0, 0, !rtl);
}
}
lyxerr << "move prevcell 2" << endl;
if (lock) {
- bool rtl = tabular.getCellInset(actcell).paragraphs.begin()->
+ bool rtl = tabular.getCellInset(actcell).paragraphs().begin()->
isRightToLeftPar(bv->buffer()->params());
activateCellInset(bv, 0, 0, !rtl);
}
if (cols < columns) {
InsetText & inset = loctab->getCellInset(cell);
LyXFont const font = inset.text_.
- getFont(inset.paragraphs.begin(), 0);
+ getFont(inset.paragraphs().begin(), 0);
inset.setText(buf.substr(op, p - op), font);
++cols;
++cell;
if (cols < columns) {
InsetText & inset = tabular.getCellInset(cell);
LyXFont const font = inset.text_.
- getFont(inset.paragraphs.begin(), 0);
+ getFont(inset.paragraphs().begin(), 0);
inset.setText(buf.substr(op, p - op), font);
}
cols = ocol;
// check for the last cell if there is no trailing '\n'
if (cell < cells && op < len) {
InsetText & inset = loctab->getCellInset(cell);
- LyXFont const font = inset.text_.getFont(inset.paragraphs.begin(), 0);
+ LyXFont const font = inset.text_.getFont(inset.paragraphs().begin(), 0);
inset.setText(buf.substr(op, len - op), font);
}
InsetText::InsetText(BufferParams const & bp)
- : UpdatableInset(),
- paragraphs(1),
- autoBreakRows_(false),
- drawFrame_(NEVER),
- frame_color_(LColor::insetframe),
- text_(0, this, true, paragraphs)
-{
- paragraphs.begin()->layout(bp.getLyXTextClass().defaultLayout());
+ : autoBreakRows_(false), drawFrame_(NEVER),
+ frame_color_(LColor::insetframe), text_(0, true)
+{
+ paragraphs().push_back(Paragraph());
+ paragraphs().begin()->layout(bp.getLyXTextClass().defaultLayout());
if (bp.tracking_changes)
- paragraphs.begin()->trackChanges();
+ paragraphs().begin()->trackChanges();
init();
}
InsetText::InsetText(InsetText const & in)
- : UpdatableInset(in),
- text_(in.text_.bv_owner, this, true, paragraphs)
+ : UpdatableInset(in), text_(in.text_.bv_owner, true)
{
// this is ugly...
operator=(in);
void InsetText::operator=(InsetText const & in)
{
UpdatableInset::operator=(in);
- paragraphs = in.paragraphs;
autoBreakRows_ = in.autoBreakRows_;
drawFrame_ = in.drawFrame_;
frame_color_ = in.frame_color_;
- text_ = LyXText(in.text_.bv_owner, this, true, paragraphs);
+ text_ = LyXText(in.text_.bv_owner, true);
+ text_.paragraphs() = in.text_.paragraphs();
init();
}
void InsetText::init()
{
- ParagraphList::iterator pit = paragraphs.begin();
- ParagraphList::iterator end = paragraphs.end();
+ ParagraphList::iterator pit = paragraphs().begin();
+ ParagraphList::iterator end = paragraphs().end();
for (; pit != end; ++pit)
pit->setInsetOwner(this);
- text_.paragraphs_ = ¶graphs;
old_par = -1;
in_insetAllowed = false;
}
void InsetText::clear(bool just_mark_erased)
{
+ ParagraphList & pars = paragraphs();
if (just_mark_erased) {
- ParagraphList::iterator it = paragraphs.begin();
- ParagraphList::iterator end = paragraphs.end();
+ ParagraphList::iterator it = pars.begin();
+ ParagraphList::iterator end = pars.end();
for (; it != end; ++it)
it->markErased();
return;
}
// This is a gross hack...
- LyXLayout_ptr old_layout = paragraphs.begin()->layout();
+ LyXLayout_ptr old_layout = pars.begin()->layout();
- paragraphs.clear();
- paragraphs.push_back(Paragraph());
- paragraphs.begin()->setInsetOwner(this);
- paragraphs.begin()->layout(old_layout);
+ pars.clear();
+ pars.push_back(Paragraph());
+ pars.begin()->setInsetOwner(this);
+ pars.begin()->layout(old_layout);
}
void InsetText::writeParagraphData(Buffer const & buf, ostream & os) const
{
- ParagraphList::const_iterator it = paragraphs.begin();
- ParagraphList::const_iterator end = paragraphs.end();
+ ParagraphList::const_iterator it = paragraphs().begin();
+ ParagraphList::const_iterator end = paragraphs().end();
Paragraph::depth_type dth = 0;
for (; it != end; ++it) {
it->write(buf, os, buf.params(), dth);
#warning John, look here. Doesnt make much sense.
if (buf.params().tracking_changes)
- paragraphs.begin()->trackChanges();
+ paragraphs().begin()->trackChanges();
// delete the initial paragraph
- Paragraph oldpar = *paragraphs.begin();
- paragraphs.clear();
- ParagraphList::iterator pit = paragraphs.begin();
+ Paragraph oldpar = *paragraphs().begin();
+ paragraphs().clear();
+ ParagraphList::iterator pit = paragraphs().begin();
while (lex.isOK()) {
lex.nextToken();
}
// FIXME: ugly.
- const_cast<Buffer&>(buf).readParagraph(lex, token, paragraphs, pit, depth);
+ const_cast<Buffer&>(buf).readParagraph(lex, token, paragraphs(), pit, depth);
}
- pit = paragraphs.begin();
- ParagraphList::iterator const end = paragraphs.end();
+ pit = paragraphs().begin();
+ ParagraphList::iterator const end = paragraphs().end();
for (; pit != end; ++pit)
pit->setInsetOwner(this);
// sanity check
// ensure we have at least one par.
- if (paragraphs.empty())
- paragraphs.push_back(oldpar);
+ if (paragraphs().empty())
+ paragraphs().push_back(oldpar);
}
if (!bv)
return;
- if (!autoBreakRows_ && paragraphs.size() > 1)
+ if (!autoBreakRows_ && paragraphs().size() > 1)
collapseParagraphs(bv);
if (!text_.selection.set())
void InsetText::sanitizeEmptyText(BufferView * bv)
{
- if (paragraphs.size() == 1
- && paragraphs.begin()->empty()
+ if (paragraphs().size() == 1
+ && paragraphs().begin()->empty()
&& bv->getParentLanguage(this) != text_.current_font.language()) {
LyXFont font(LyXFont::ALL_IGNORE);
font.setLanguage(bv->getParentLanguage(this));
if (left)
text_.setCursorIntern(0, 0);
else
- text_.setCursor(paragraphs.size() - 1, paragraphs.back().size());
+ text_.setCursor(paragraphs().size() - 1, paragraphs().back().size());
sanitizeEmptyText(bv);
updateLocal(bv);
DispatchResult result;
result.dispatched(true);
- bool was_empty = paragraphs.begin()->empty() && paragraphs.size() == 1;
+ bool was_empty = paragraphs().begin()->empty() && paragraphs().size() == 1;
switch (cmd.action) {
case LFUN_MOUSE_PRESS:
// If the action has deleted all text in the inset, we need
// to change the language to the language of the surronding
// text.
- if (!was_empty && paragraphs.begin()->empty() &&
- paragraphs.size() == 1) {
+ if (!was_empty && paragraphs().begin()->empty() &&
+ paragraphs().size() == 1) {
LyXFont font(LyXFont::ALL_IGNORE);
font.setLanguage(bv->getParentLanguage(this));
text_.setFont(font, false);
OutputParams const & runparams) const
{
TexRow texrow;
- latexParagraphs(buf, paragraphs, os, texrow, runparams);
+ latexParagraphs(buf, paragraphs(), os, texrow, runparams);
return texrow.rows();
}
int InsetText::plaintext(Buffer const & buf, ostream & os,
OutputParams const & runparams) const
{
- ParagraphList::const_iterator beg = paragraphs.begin();
- ParagraphList::const_iterator end = paragraphs.end();
+ ParagraphList::const_iterator beg = paragraphs().begin();
+ ParagraphList::const_iterator end = paragraphs().end();
ParagraphList::const_iterator it = beg;
for (; it != end; ++it)
asciiParagraph(buf, *it, os, runparams, it == beg);
int InsetText::linuxdoc(Buffer const & buf, ostream & os,
OutputParams const & runparams) const
{
- linuxdocParagraphs(buf, paragraphs, os, runparams);
+ linuxdocParagraphs(buf, paragraphs(), os, runparams);
return 0;
}
int InsetText::docbook(Buffer const & buf, ostream & os,
OutputParams const & runparams) const
{
- docbookParagraphs(buf, paragraphs, os, runparams);
+ docbookParagraphs(buf, paragraphs(), os, runparams);
return 0;
}
void InsetText::validate(LaTeXFeatures & features) const
{
- for_each(paragraphs.begin(), paragraphs.end(),
+ for_each(paragraphs().begin(), paragraphs().end(),
boost::bind(&Paragraph::validate, _1, boost::ref(features)));
}
void InsetText::getLabelList(Buffer const & buffer,
std::vector<string> & list) const
{
- ParagraphList::const_iterator pit = paragraphs.begin();
- ParagraphList::const_iterator pend = paragraphs.end();
+ ParagraphList::const_iterator pit = paragraphs().begin();
+ ParagraphList::const_iterator pend = paragraphs().end();
for (; pit != pend; ++pit) {
InsetList::const_iterator beg = pit->insetlist.begin();
InsetList::const_iterator end = pit->insetlist.end();
void InsetText::markNew(bool track_changes)
{
- ParagraphList::iterator pit = paragraphs.begin();
- ParagraphList::iterator end = paragraphs.end();
+ ParagraphList::iterator pit = paragraphs().begin();
+ ParagraphList::iterator end = paragraphs().end();
for (; pit != end; ++pit) {
if (track_changes) {
pit->trackChanges();
{
clear(false);
for (unsigned int i = 0; i < data.length(); ++i)
- paragraphs.begin()->insertChar(i, data[i], font);
+ paragraphs().begin()->insertChar(i, data[i], font);
}
void InsetText::removeNewlines()
{
- ParagraphList::iterator it = paragraphs.begin();
- ParagraphList::iterator end = paragraphs.end();
+ ParagraphList::iterator it = paragraphs().begin();
+ ParagraphList::iterator end = paragraphs().end();
for (; it != end; ++it)
for (int i = 0; i < it->size(); ++i)
if (it->isNewline(i))
ParagraphList * InsetText::getParagraphs(int i) const
{
- return (i == 0) ? const_cast<ParagraphList*>(¶graphs) : 0;
+ return (i == 0) ? const_cast<ParagraphList*>(¶graphs()) : 0;
}
}
-bool InsetText::checkInsertChar(LyXFont & font)
-{
- return owner() ? owner()->checkInsertChar(font) : true;
-}
-
-
void InsetText::collapseParagraphs(BufferView * bv)
{
- while (paragraphs.size() > 1) {
- ParagraphList::iterator const first = paragraphs.begin();
+ while (paragraphs().size() > 1) {
+ ParagraphList::iterator const first = paragraphs().begin();
ParagraphList::iterator second = first;
++second;
size_t const first_par_size = first->size();
}
}
- mergeParagraph(bv->buffer()->params(), paragraphs, first);
+ mergeParagraph(bv->buffer()->params(), paragraphs(), first);
}
}
// And it probably does. You have to take a look at this John. (Lgb)
#warning John, have a look here. (Lgb)
ParagraphList::iterator pit = plist.begin();
- ParagraphList::iterator ins = paragraphs.insert(paragraphs.end(), *pit);
+ ParagraphList::iterator ins = paragraphs().insert(paragraphs().end(), *pit);
++pit;
- mergeParagraph(buffer->params(), paragraphs, boost::prior(ins));
+ mergeParagraph(buffer->params(), paragraphs(), boost::prior(ins));
ParagraphList::iterator pend = plist.end();
for (; pit != pend; ++pit)
- paragraphs.push_back(*pit);
+ paragraphs().push_back(*pit);
}
void InsetText::addPreview(PreviewLoader & loader) const
{
- ParagraphList::const_iterator pit = paragraphs.begin();
- ParagraphList::const_iterator pend = paragraphs.end();
+ ParagraphList::const_iterator pit = paragraphs().begin();
+ ParagraphList::const_iterator pend = paragraphs().end();
for (; pit != pend; ++pit) {
InsetList::const_iterator it = pit->insetlist.begin();
it->inset->addPreview(loader);
}
}
+
+
+ParagraphList & InsetText::paragraphs() const
+{
+ return const_cast<ParagraphList &>(text_.paragraphs());
+}
*/
void markNew(bool track_changes = false);
- ///
- bool checkInsertChar(LyXFont &);
///
void getDrawFont(LyXFont &) const;
/// append text onto the existing text
///
int numParagraphs() const { return 1; }
///
- mutable ParagraphList paragraphs;
+ ParagraphList & paragraphs() const;
+
private:
///
DispatchResult
setInsetName(type);
LyXTextClass const & tclass = bp.getLyXTextClass();
if (tclass.hasLayout(caplayout))
- inset.paragraphs.begin()->layout(tclass[caplayout]);
+ inset.paragraphs().begin()->layout(tclass[caplayout]);
}
}
-int InsetWrap::latexTextWidth(BufferView * bv) const
-{
- return params_.width.inPixels(InsetCollapsable::latexTextWidth(bv));
-}
-
-
bool InsetWrap::showInsetDialog(BufferView * bv) const
{
- if (!inset.showInsetDialog(bv)) {
- InsetWrap * tmp = const_cast<InsetWrap *>(this);
- InsetWrapMailer(*tmp).showDialog(bv);
- }
+ if (!inset.showInsetDialog(bv))
+ InsetWrapMailer(const_cast<InsetWrap &>(*this)).showDialog(bv);
return true;
}
void InsetWrap::addToToc(lyx::toc::TocList & toclist, Buffer const & buf) const
{
// Now find the caption in the float...
- ParagraphList::iterator tmp = inset.paragraphs.begin();
- ParagraphList::iterator end = inset.paragraphs.end();
+ ParagraphList::iterator tmp = inset.paragraphs().begin();
+ ParagraphList::iterator end = inset.paragraphs().end();
for (; tmp != end; ++tmp) {
if (tmp->layout()->name() == caplayout) {
* Full author contact details are available in file CREDITS.
*/
-#ifndef InsetWrap_H
-#define InsetWrap_H
-
+#ifndef INSETWRAP_H
+#define INSETWRAP_H
#include "insetcollapsable.h"
#include "toc.h"
///
void addToToc(lyx::toc::TocList &, Buffer const &) const;
///
- bool showInsetDialog(BufferView *) const;
- ///
- int latexTextWidth(BufferView *) const;
+ bool showInsetDialog(BufferView *) const;
///
InsetWrapParams const & params() const { return params_; }
protected:
#include "paragraph.h"
#include "PosIterator.h"
#include "cursor.h"
+#include "buffer.h"
#include "BufferView.h"
#include "dispatchresult.h"
}
-LyXText * ParIterator::text(BufferView * bv) const
+LyXText * ParIterator::text(Buffer & buf) const
{
//lyxerr << "positions.size: " << pimpl_->positions.size() << std::endl;
if (pimpl_->positions.size() <= 1)
- return bv->text();
+ return &buf.text();
ParPosition const & pos = pimpl_->positions[pimpl_->positions.size() - 2];
return (*pos.it)->inset->getText(*pos.index);
for (int i = 0; i < last; ++i) {
ParPosition & pp = pimpl_->positions[i];
p.stack_.push_back(
- PosIteratorItem(const_cast<ParagraphList *>(pp.plist), pp.pit, (*pp.it)->pos, *pp.index + 1));
+ PosIteratorItem(const_cast<ParagraphList *>(pp.plist),
+ pp.pit, (*pp.it)->pos, *pp.index + 1));
}
ParPosition const & pp = pimpl_->positions[last];
p.stack_.push_back(
class LyXText;
class InsetOld;
class Cursor;
+class Buffer;
class BufferView;
class PosIterator;
///
ParagraphList & plist() const;
/// returns 'innermost' LyXText
- LyXText * text(BufferView *) const;
+ LyXText * text(Buffer &) const;
/// returns innermost inset
InsetOld * inset() const;
/// returns index of cell in innermost inset
string const getPossibleLabel(BufferView const & bv)
{
ParagraphList::iterator pit = bv.getLyXText()->cursorPar();
- ParagraphList & plist = bv.getLyXText()->ownerParagraphs();
+ ParagraphList & plist = bv.getLyXText()->paragraphs();
LyXLayout_ptr layout = pit->layout();
disable = !buf->params().tracking_changes;
break;
- case LFUN_INSET_TOGGLE: {
- LyXText * lt = view()->getLyXText();
- disable = !(isEditableInset(lt->getInset())
- || (lt->inset_owner
- && lt->inset_owner->owner()
- && lt->inset_owner->owner()->isOpen()));
- break;
- }
-
case LFUN_INSET_SETTINGS: {
disable = true;
UpdatableInset * inset = view()->cursor().innerInset();
}
par.lockPath(view());
- LyXText * lt = par.text(view());
+ LyXText * lt = par.text(*view()->buffer());
// Set the cursor
lt->setCursor(par.pit(), 0);
class BufferView;
class Dimension;
class LColor_color;
-class InsetText;
class LyXCursor;
class MetricsInfo;
class Paragraph;
// Public Functions
public:
/// Constructor
- LyXText(BufferView *, InsetText *, bool ininset, ParagraphList & plist);
+ LyXText(BufferView *, bool ininset);
///
void init(BufferView *);
/// draw text (only used for insets)
void draw(PainterInfo & pi, int x, int y) const;
- ///
+ /// try to handle that request
DispatchResult dispatch(FuncRequest const & cmd);
BufferView * bv();
/// Change the case of the word at cursor position.
void changeCase(TextCase action);
- ///
- void toggleInset();
+ /// returns success
+ bool toggleInset();
///
void cutSelection(bool doclear = true, bool realcut = true);
///
//
// special owner functions
///
- ParagraphList & ownerParagraphs() const;
+ ParagraphList & paragraphs() const;
/// return true if this is owned by an inset.
bool isInInset() const;
/// our buffer's default layout font
LyXFont defaultfont_;
///
- InsetText * inset_owner;
+ int background_color_;
/// only the top-level LyXText has this non-zero
BufferView * bv_owner;
///
bool in_inset_;
///
- ParagraphList * paragraphs_;
+ ParagraphList paragraphs_;
/// absolute document pixel coordinates of this LyXText
mutable int xo_;
}
-bool Paragraph::checkInsertChar(LyXFont & font)
+bool Paragraph::checkInsertChar(LyXFont &)
{
- if (pimpl_->inset_owner)
- return pimpl_->inset_owner->checkInsertChar(font);
return true;
}
bool Paragraph::hasSameLayout(Paragraph const & par) const
{
- return
- par.layout() == layout() &&
- params().sameLayout(par.params());
+ return par.layout() == layout() && params().sameLayout(par.params());
}
namespace {
-/* paragraphs inside floats need different alignment tags to avoid
-unwanted space */
+// paragraphs inside floats need different alignment tags to avoid
+// unwanted space
bool noTrivlistCentering(UpdatableInset const * inset)
{
if (c == Paragraph::META_INSET) {
- InsetOld const * inset = getInset(i);
- inset->linuxdoc(buf, os, runparams);
+ getInset(i)->linuxdoc(buf, os, runparams);
font_old = font;
continue;
}
if (ws && !isFreeSpacing()) {
// in freespacing mode, spaces are
// non-breaking characters
- if (desc_on) {// if char is ' ' then...
-
+ if (desc_on) { // if char is ' ' then...
++char_line_count;
sgmlLineBreak(os, char_line_count, 6);
os << "</tag>";
bool emph_flag = false;
LyXLayout_ptr const & style = layout();
- LyXLayout_ptr const & defaultstyle
- = buf.params().getLyXTextClass().defaultLayout();
+ LyXLayout_ptr const & defaultstyle =
+ buf.params().getLyXTextClass().defaultLayout();
- LyXFont font_old = (style->labeltype == LABEL_MANUAL ? style->labelfont : style->font);
+ LyXFont font_old =
+ style->labeltype == LABEL_MANUAL ? style->labelfont : style->font;
int char_line_count = depth;
bool label_closed = true;
LyXLayout_ptr const & layout = pit_->layout();
if (buffer.params().paragraph_separation == BufferParams::PARSEP_SKIP) {
- if (pit_ != text_.ownerParagraphs().begin()) {
+ if (pit_ != text_.paragraphs().begin()) {
if (layout->latextype == LATEX_PARAGRAPH
&& !pit_->getDepth()) {
y_top += buffer.params().getDefSkip().inPixels(bv_);
int const ww = bv_.workWidth();
bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
- bool const is_seq = isFirstInSequence(pit_, text_.ownerParagraphs());
+ bool const is_seq = isFirstInSequence(pit_, text_.paragraphs());
//lyxerr << "paintFirst: " << pit_->id() << " is_seq: " << is_seq << std::endl;
// should we print a label?
{
int const ww = bv_.workWidth();
bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
- int const endlabel = getEndLabel(pit_, text_.ownerParagraphs());
+ int const endlabel = getEndLabel(pit_, text_.paragraphs());
// draw an endlabel
switch (endlabel) {
int const y2 = bv.painter().paperHeight();
y -= bv.top_y();
- ParagraphList::iterator end = text.ownerParagraphs().end();
+ ParagraphList::iterator end = text.paragraphs().end();
for ( ; pit != end; ++pit) {
RowList::iterator row = pit->rows.begin();
void paintTextInset(BufferView const & bv, LyXText const & text, int xo, int yo)
{
- paintPars(bv, text, text.ownerParagraphs().begin(), xo, yo, 0);
+ paintPars(bv, text, text.paragraphs().begin(), xo, yo, 0);
}
bool getTokenValue(string const & str, const char * token, LyXAlignment & num)
{
string tmp;
- if (!getTokenValue(str, token, tmp))
- return false;
- return string2type(tmp, num);
+ return getTokenValue(str, token, tmp) && string2type(tmp, num);
}
LyXTabular::VAlignment & num)
{
string tmp;
- if (!getTokenValue(str, token, tmp))
- return false;
- return string2type(tmp, num);
+ return getTokenValue(str, token, tmp) && string2type(tmp, num);
}
LyXTabular::BoxType & num)
{
string tmp;
- if (!getTokenValue(str, token, tmp))
- return false;
- return string2type(tmp, num);
+ return getTokenValue(str, token, tmp) && string2type(tmp, num);
}
// not in the file-format.
flag = false;
string tmp;
- if (!getTokenValue(str, token, tmp))
- return false;
- return string2type(tmp, flag);
+ return getTokenValue(str, token, tmp) && string2type(tmp, flag);
}
// in the file format.
len = LyXLength();
string tmp;
- if (!getTokenValue(str, token, tmp))
- return false;
- return isValidLength(tmp, &len);
+ return getTokenValue(str, token, tmp) && isValidLength(tmp, &len);
}
for (int i = 1; i < number; ++i) {
cellstruct & cs1 = cellinfo_of_cell(cell + i);
cs1.multicolumn = CELL_PART_OF_MULTICOLUMN;
- cs.inset.appendParagraphs(buffer, cs1.inset.paragraphs);
+ cs.inset.appendParagraphs(buffer, cs1.inset.paragraphs());
cs1.inset.clear(false);
}
set_row_column_number_info();
ret += TeXCellPreamble(os, cell);
InsetText & inset = getCellInset(cell);
- bool rtl = inset.paragraphs.begin()->isRightToLeftPar(bufferparams) &&
- !inset.paragraphs.begin()->empty() && getPWidth(cell).zero();
+ bool rtl = inset.paragraphs().begin()->isRightToLeftPar(bufferparams) &&
+ !inset.paragraphs().begin()->empty() && getPWidth(cell).zero();
if (rtl)
os << "\\R{";
LyXTabular::BoxType LyXTabular::useParbox(int cell) const
{
- ParagraphList const & parlist = getCellInset(cell).paragraphs;
+ ParagraphList const & parlist = getCellInset(cell).paragraphs();
ParagraphList::const_iterator cit = parlist.begin();
ParagraphList::const_iterator end = parlist.end();
void LyXText::updateParPositions()
{
- ParagraphList::iterator pit = ownerParagraphs().begin();
- ParagraphList::iterator end = ownerParagraphs().end();
+ ParagraphList::iterator pit = paragraphs().begin();
+ ParagraphList::iterator end = paragraphs().end();
for (height = 0; pit != end; ++pit) {
pit->y = height;
height += pit->height;
if (pit->getDepth() == 0) {
if (pit->layout() == tclass.defaultLayout()) {
// find the previous same level paragraph
- if (pit != ownerParagraphs().begin()) {
+ if (pit != paragraphs().begin()) {
ParagraphList::iterator newpit =
- depthHook(pit, ownerParagraphs(), pit->getDepth());
+ depthHook(pit, paragraphs(), pit->getDepth());
if (newpit == pit && newpit->layout()->nextnoindent)
parindent.erase();
}
} else {
// find the next level paragraph
ParagraphList::iterator newpar =
- outerHook(pit, ownerParagraphs());
+ outerHook(pit, paragraphs());
// Make a corresponding row. Need to call leftMargin()
// to check whether it is a sufficent paragraph.
- if (newpar != ownerParagraphs().end()
+ if (newpar != paragraphs().end()
&& newpar->layout()->isEnvironment()) {
x = leftMargin(newpar);
}
- if (newpar != ownerParagraphs().end()
+ if (newpar != paragraphs().end()
&& pit->layout() == tclass.defaultLayout()) {
if (newpar->params().noindent())
parindent.erase();
// theorems (JMarc)
|| (layout->labeltype == LABEL_STATIC
&& layout->latextype == LATEX_ENVIRONMENT
- && !isFirstInSequence(pit, ownerParagraphs()))) {
+ && !isFirstInSequence(pit, paragraphs()))) {
x += font_metrics::signedWidth(layout->leftmargin,
labelfont);
} else if (layout->labeltype != LABEL_TOP_ENVIRONMENT
}
}
- if (!pit->params().leftIndent().zero()) {
- int const tw = inset_owner ?
- inset_owner->latexTextWidth(bv()) : textWidth();
- x += pit->params().leftIndent().inPixels(tw);
- }
+ if (!pit->params().leftIndent().zero())
+ x += pit->params().leftIndent().inPixels(textWidth());
LyXAlignment align;
|| layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT
|| (layout->labeltype == LABEL_STATIC
&& layout->latextype == LATEX_ENVIRONMENT
- && !isFirstInSequence(pit, ownerParagraphs())))
+ && !isFirstInSequence(pit, paragraphs())))
&& align == LYX_ALIGN_BLOCK
&& !pit->params().noindent()
// in tabulars and ert paragraphs are never indented!
LColor_color LyXText::backgroundColor() const
{
- if (inset_owner)
- return inset_owner->backgroundColor();
- return LColor::background;
+ return LColor_color(LColor::color(background_color_));
}
// some parksips VERY EASY IMPLEMENTATION
if (bv()->buffer()->params().paragraph_separation
== BufferParams::PARSEP_SKIP
- && pit != ownerParagraphs().begin()
+ && pit != paragraphs().begin()
&& ((layout->isParagraph() && pit->getDepth() == 0)
|| (boost::prior(pit)->layout()->isParagraph()
&& boost::prior(pit)->getDepth() == 0)))
if ((layout->labeltype == LABEL_TOP_ENVIRONMENT
|| layout->labeltype == LABEL_BIBLIO
|| layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
- && isFirstInSequence(pit, ownerParagraphs())
+ && isFirstInSequence(pit, paragraphs())
&& !pit->getLabelstring().empty())
{
labeladdon = int(
// environment.
ParagraphList::iterator prev =
- depthHook(pit, ownerParagraphs(), pit->getDepth());
+ depthHook(pit, paragraphs(), pit->getDepth());
if (prev != pit
&& prev->layout() == layout
&& prev->getDepth() == pit->getDepth()
&& prev->getLabelWidthString() == pit->getLabelWidthString())
{
layoutasc = layout->itemsep * dh;
- } else if (pit != ownerParagraphs().begin() || row.pos() != 0) {
+ } else if (pit != paragraphs().begin() || row.pos() != 0) {
if (layout->topsep > 0)
layoutasc = layout->topsep * dh;
}
- prev = outerHook(pit, ownerParagraphs());
- if (prev != ownerParagraphs().end()) {
+ prev = outerHook(pit, paragraphs());
+ if (prev != paragraphs().end()) {
maxasc += int(prev->layout()->parsep * dh);
- } else if (pit != ownerParagraphs().begin()) {
+ } else if (pit != paragraphs().begin()) {
ParagraphList::iterator prior_pit = boost::prior(pit);
if (prior_pit->getDepth() != 0 ||
prior_pit->layout() == layout) {
// a section, or between the items of a itemize or enumerate
// environment
ParagraphList::iterator nextpit = boost::next(pit);
- if (nextpit != ownerParagraphs().end()) {
+ if (nextpit != paragraphs().end()) {
ParagraphList::iterator cpit = pit;
double usual = 0;
double unusual = 0;
if (cpit->getDepth() > nextpit->getDepth()) {
usual = cpit->layout()->bottomsep * dh;
- cpit = depthHook(cpit, ownerParagraphs(), nextpit->getDepth());
+ cpit = depthHook(cpit, paragraphs(), nextpit->getDepth());
if (cpit->layout() != nextpit->layout()
|| nextpit->getLabelWidthString() != cpit->getLabelWidthString())
{
pos_type pos = from.pos();
int par = from.par();
- while (par != int(ownerParagraphs().size()) &&
+ while (par != int(paragraphs().size()) &&
(pos != to.pos() || par != to.par())) {
ParagraphList::iterator pit = getPar(par);
if (pos == pit->size()) {
ParagraphList::iterator LyXText::getPar(int par) const
{
BOOST_ASSERT(par >= 0);
- BOOST_ASSERT(par < int(ownerParagraphs().size()));
- ParagraphList::iterator pit = ownerParagraphs().begin();
+ BOOST_ASSERT(par < int(paragraphs().size()));
+ ParagraphList::iterator pit = paragraphs().begin();
std::advance(pit, par);
return pit;
}
//lyxerr << "getRowNearY: y " << y << endl;
#if 1
ParagraphList::iterator const
- pend = boost::prior(ownerParagraphs().end());
- pit = ownerParagraphs().begin();
+ pend = boost::prior(paragraphs().end());
+ pit = paragraphs().begin();
while (int(pit->y + pit->height) < y && pit != pend)
++pit;
return rit;
#else
- pit = boost::prior(ownerParagraphs().end());
+ pit = boost::prior(paragraphs().end());
RowList::iterator rit = lastRow();
RowList::iterator rbegin = firstRow();
RowList::iterator LyXText::firstRow() const
{
- return ownerParagraphs().front().rows.begin();
+ return paragraphs().front().rows.begin();
}
ParagraphList::iterator LyXText::firstPar() const
{
- return ownerParagraphs().begin();
+ return paragraphs().begin();
}
RowList::iterator LyXText::endRow() const
{
- return ownerParagraphs().back().rows.end();
+ return paragraphs().back().rows.end();
}
ParagraphList::iterator LyXText::endPar() const
{
- return ownerParagraphs().end();
+ return paragraphs().end();
}
++rit;
if (rit == pit->rows.end()) {
++pit;
- if (pit == ownerParagraphs().end())
+ if (pit == paragraphs().end())
--pit;
else
rit = pit->rows.begin();
if (rit != pit->rows.begin())
--rit;
else {
- BOOST_ASSERT(pit != ownerParagraphs().begin());
+ BOOST_ASSERT(pit != paragraphs().begin());
--pit;
rit = boost::prior(pit->rows.end());
}
int LyXText::parOffset(ParagraphList::iterator pit) const
{
- return std::distance(ownerParagraphs().begin(), pit);
+ return std::distance(paragraphs().begin(), pit);
}
void LyXText::fullRebreak()
{
- redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end());
+ redoParagraphs(paragraphs().begin(), paragraphs().end());
redoCursor();
selection.cursor = cursor;
}
// << " textWidth: " << textWidth() << "\nfont: " << mi.base.font << endl;
// Rebuild row cache. This recomputes height as well.
- redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end());
+ redoParagraphs(paragraphs().begin(), paragraphs().end());
- width = maxParagraphWidth(ownerParagraphs());
+ width = maxParagraphWidth(paragraphs());
// final dimension
dim.asc = firstRow()->ascent_of_text();
bool LyXText::isLastRow(ParagraphList::iterator pit, Row const & row) const
{
return row.endpos() >= pit->size()
- && boost::next(pit) == ownerParagraphs().end();
+ && boost::next(pit) == paragraphs().end();
}
bool LyXText::isFirstRow(ParagraphList::iterator pit, Row const & row) const
{
- return row.pos() == 0 && pit == ownerParagraphs().begin();
+ return row.pos() == 0 && pit == paragraphs().begin();
}
pit->isHfill(pos - 1))) {
--pos;
} else if (!pos) {
- if (pit != ownerParagraphs().begin()) {
+ if (pit != paragraphs().begin()) {
--pit;
pos = pit->size();
}
pos_type pos = cursor.pos();
if (pos == pit->size() &&
- boost::next(pit) != ownerParagraphs().end()) {
+ boost::next(pit) != paragraphs().end()) {
++pit;
pos = 0;
} else {
#include "funcrequest.h"
#include "gettext.h"
#include "language.h"
+#include "LColor.h"
#include "lyxrc.h"
#include "lyxrow.h"
#include "lyxrow_funcs.h"
using std::string;
-LyXText::LyXText(BufferView * bv, InsetText * inset, bool in_inset,
- ParagraphList & paragraphs)
+LyXText::LyXText(BufferView * bv, bool in_inset)
: height(0), width(0), textwidth_(bv ? bv->workWidth() : 100),
- inset_owner(inset), bv_owner(bv),
- in_inset_(in_inset), paragraphs_(¶graphs), xo_(0), yo_(0)
+ background_color_(LColor::background),
+ bv_owner(bv), in_inset_(in_inset), xo_(0), yo_(0)
{}
{
bv_owner = bview;
- ParagraphList::iterator const beg = ownerParagraphs().begin();
- ParagraphList::iterator const end = ownerParagraphs().end();
+ ParagraphList::iterator const beg = paragraphs().begin();
+ ParagraphList::iterator const end = paragraphs().end();
for (ParagraphList::iterator pit = beg; pit != end; ++pit)
pit->rows.clear();
pit->inInset()->getDrawFont(font);
// Realize with the fonts of lesser depth.
- //font.realize(outerFont(pit, ownerParagraphs()));
+ //font.realize(outerFont(pit, paragraphs()));
font.realize(defaultfont_);
return font;
LyXFont font = layout->font;
// Realize with the fonts of lesser depth.
- //font.realize(outerFont(pit, ownerParagraphs()));
+ //font.realize(outerFont(pit, paragraphs()));
font.realize(defaultfont_);
return font;
LyXFont font = layout->labelfont;
// Realize with the fonts of lesser depth.
- font.realize(outerFont(pit, ownerParagraphs()));
+ font.realize(outerFont(pit, paragraphs()));
font.realize(defaultfont_);
return font;
if (pit->getDepth()) {
ParagraphList::iterator tp = pit;
while (!layoutfont.resolved() &&
- tp != ownerParagraphs().end() &&
+ tp != paragraphs().end() &&
tp->getDepth()) {
- tp = outerHook(tp, ownerParagraphs());
- if (tp != ownerParagraphs().end())
+ tp = outerHook(tp, paragraphs());
+ if (tp != paragraphs().end())
layoutfont.realize(tp->layout()->font);
}
}
}
-void LyXText::toggleInset()
+bool LyXText::toggleInset()
{
InsetOld * inset = getInset();
// is there an editable inset at cursor position?
- if (!isEditableInset(inset)) {
- // No, try to see if we are inside a collapsable inset
- if (inset_owner && inset_owner->owner()
- && inset_owner->owner()->isOpen()) {
- finishUndo();
- inset_owner->owner()->close();
- bv()->getLyXText()->cursorRight(true);
- bv()->updateParagraphDialog();
- }
- return;
- }
+ if (!isEditableInset(inset))
+ return false;
//bv()->owner()->message(inset->editMessage());
// do we want to keep this?? (JMarc)
inset->close();
else
inset->open();
+ return true;
}
{
ParagraphList::iterator endpit = boost::next(getPar(send_cur));
ParagraphList::iterator undoendpit = endpit;
- ParagraphList::iterator pars_end = ownerParagraphs().end();
+ ParagraphList::iterator pars_end = paragraphs().end();
if (endpit != pars_end && endpit->getDepth()) {
while (endpit != pars_end && endpit->getDepth()) {
makeFontEntriesLayoutSpecific(bufparams, *pit);
if (lyxlayout->margintype == MARGIN_MANUAL)
pit->setLabelWidthString(lyxlayout->labelstring());
- cur.par(std::distance(ownerParagraphs().begin(), pit));
+ cur.par(std::distance(paragraphs().begin(), pit));
++pit;
} while (pit != epit);
ParagraphList::iterator beg, end;
getSelectionSpan(*this, beg, end);
int max_depth = 0;
- if (beg != ownerParagraphs().begin())
+ if (beg != paragraphs().begin())
max_depth = boost::prior(beg)->getMaxDepthAfter();
for (ParagraphList::iterator pit = beg; pit != end; ++pit) {
recUndo(parOffset(beg), parOffset(end) - 1);
int max_depth = 0;
- if (beg != ownerParagraphs().begin())
+ if (beg != paragraphs().begin())
max_depth = boost::prior(beg)->getMaxDepthAfter();
for (ParagraphList::iterator pit = beg; pit != end; ++pit) {
ParagraphList::iterator beg = getPar(selection.start.par());
ParagraphList::iterator end = getPar(selection.end.par());
- PosIterator pos(&ownerParagraphs(), beg, selection.start.pos());
- PosIterator posend(&ownerParagraphs(), end, selection.end.pos());
+ PosIterator pos(¶graphs(), beg, selection.start.pos());
+ PosIterator posend(¶graphs(), end, selection.end.pos());
BufferParams const & params = bv()->buffer()->params();
void LyXText::cursorTop()
{
- setCursor(ownerParagraphs().begin(), 0);
+ setCursor(paragraphs().begin(), 0);
}
void LyXText::cursorBottom()
{
ParagraphList::iterator lastpit =
- boost::prior(ownerParagraphs().end());
+ boost::prior(paragraphs().end());
setCursor(lastpit, lastpit->size());
}
}
-// the DTP switches for paragraphs. LyX will store them in the first
+// the DTP switches for paragraphs(). LyX will store them in the first
// physical paragraph. When a paragraph is broken, the top settings rest,
// the bottom settings are given to the new one. So I can make sure,
// they do not duplicate themself and you cannot play dirty tricks with
// make sure that the depth behind the selection are restored, too
ParagraphList::iterator endpit = boost::next(getPar(selection.end));
ParagraphList::iterator undoendpit = endpit;
- ParagraphList::iterator pars_end = ownerParagraphs().end();
+ ParagraphList::iterator pars_end = paragraphs().end();
if (endpit != pars_end && endpit->getDepth()) {
while (endpit != pars_end && endpit->getDepth()) {
BufferParams const & bufparams = buf.params();
LyXTextClass const & textclass = bufparams.getLyXTextClass();
LyXLayout_ptr const & layout = pit->layout();
- ParagraphList::iterator first_pit = ownerParagraphs().begin();
+ ParagraphList::iterator first_pit = paragraphs().begin();
Counters & counters = textclass.counters();
// Always reset
// the caption hack:
if (layout->labeltype == LABEL_SENSITIVE) {
- ParagraphList::iterator end = ownerParagraphs().end();
+ ParagraphList::iterator end = paragraphs().end();
ParagraphList::iterator tmppit = pit;
InsetOld * in = 0;
bool isOK = false;
bool update_pos = false;
- ParagraphList::iterator beg = ownerParagraphs().begin();
- ParagraphList::iterator end = ownerParagraphs().end();
+ ParagraphList::iterator beg = paragraphs().begin();
+ ParagraphList::iterator end = paragraphs().end();
for (ParagraphList::iterator pit = beg; pit != end; ++pit) {
string const oldLabel = pit->params().labelString();
size_t maxdepth = 0;
// make sure that the depth behind the selection are restored, too
ParagraphList::iterator endpit = boost::next(getPar(selection.end.par()));
ParagraphList::iterator undoendpit = endpit;
- ParagraphList::iterator pars_end = ownerParagraphs().end();
+ ParagraphList::iterator pars_end = paragraphs().end();
if (endpit != pars_end && endpit->getDepth()) {
while (endpit != pars_end && endpit->getDepth()) {
BufferParams const & bufparams = bv()->buffer()->params();
boost::tie(endpit, endpos) = realcut ?
CutAndPaste::cutSelection(bufparams,
- ownerParagraphs(),
+ paragraphs(),
getPar(selection.start.par()), endpit,
selection.start.pos(), endpos,
bufparams.textclass,
doclear)
: CutAndPaste::eraseSelection(bufparams,
- ownerParagraphs(),
+ paragraphs(),
getPar(selection.start.par()), endpit,
selection.start.pos(), endpos,
doclear);
boost::tie(ppp, endpit) =
CutAndPaste::pasteSelection(*bv()->buffer(),
- ownerParagraphs(),
+ paragraphs(),
cursorPar(), cursor.pos(),
bv()->buffer()->params().textclass,
sel_index, el);
}
-// turns double-CR to single CR, others where converted into one
-// blank. Then InsertStringAsLines is called
+// turn double CR to single CR, others are converted into one
+// blank. Then insertStringAsLines is called
void LyXText::insertStringAsParagraphs(string const & str)
{
string linestr(str);
if (linestr[i] == '\n') {
if (newline_inserted) {
// we know that \r will be ignored by
- // InsertStringA. Of course, it is a dirty
+ // insertStringAsLines. Of course, it is a dirty
// trick, but it works...
linestr[i - 1] = '\r';
linestr[i] = '\n';
}
-bool LyXText::setCursor(paroffset_type par, pos_type pos, bool setfont, bool boundary)
+bool LyXText::setCursor(paroffset_type par, pos_type pos, bool setfont,
+ bool boundary)
{
LyXCursor old_cursor = cursor;
setCursorIntern(par, pos, setfont, boundary);
void LyXText::setCursor(LyXCursor & cur, paroffset_type par,
pos_type pos, bool boundary)
{
- BOOST_ASSERT(par != int(ownerParagraphs().size()));
+ BOOST_ASSERT(par != int(paragraphs().size()));
cur.par(par);
cur.pos(pos);
cur.boundary(boundary);
// no rows, no fun...
- if (ownerParagraphs().begin()->rows.empty())
+ if (paragraphs().begin()->rows.empty())
return;
// get the cursor y position in text
double last_tmpx = tmpx;
if (body_pos > 0 &&
- (body_pos > end ||
- !pit->isLineSeparator(body_pos - 1)))
+ (body_pos > end || !pit->isLineSeparator(body_pos - 1)))
body_pos = 0;
// check for empty row
DispatchResult LyXText::moveRightIntern(bool front, bool activate_inset, bool selecting)
{
ParagraphList::iterator c_par = cursorPar();
- if (boost::next(c_par) == ownerParagraphs().end()
+ if (boost::next(c_par) == paragraphs().end()
&& cursor.pos() >= c_par->size())
return DispatchResult(false, FINISHED_RIGHT);
if (activate_inset && checkAndActivateInset(front))
return true;
}
- if (cursor.par() + 1 != int(ownerParagraphs().size())) {
+ if (cursor.par() + 1 != int(paragraphs().size())) {
setCursor(cursor.par() + 1, 0);
return true;
}
ParagraphList::iterator cpit = cursorPar();
if (cursor.pos() > 0)
setCursor(cpit, 0);
- else if (cpit != ownerParagraphs().begin())
+ else if (cpit != paragraphs().begin())
setCursor(boost::prior(cpit), 0);
}
ParagraphList::iterator pit = cursorPar();
ParagraphList::iterator next_pit = boost::next(pit);
- if (next_pit != ownerParagraphs().end())
+ if (next_pit != paragraphs().end())
setCursor(next_pit, 0);
else
setCursor(pit, pit->size());
Copy and Paste to hopefully do some sensible things.
There are still some small problems that can lead to
double spaces stored in the document file or space at
- the beginning of paragraphs. This happens if you have
+ the beginning of paragraphs(). This happens if you have
the cursor between to spaces and then save. Or if you
cut and paste and the selection have a space at the
beginning and then save right after the paste. I am
}
// don't delete anything if this is the ONLY paragraph!
- if (ownerParagraphs().size() == 1)
+ if (paragraphs().size() == 1)
return false;
// Do not delete empty paragraphs with keepempty set.
cursor = old_cursor; // that undo can restore the right cursor position
ParagraphList::iterator endpit = boost::next(old_pit);
- while (endpit != ownerParagraphs().end() && endpit->getDepth())
+ while (endpit != paragraphs().end() && endpit->getDepth())
++endpit;
recUndo(parOffset(old_pit), parOffset(endpit) - 1);
// cache cursor pit
ParagraphList::iterator tmppit = cursorPar();
// delete old par
- ownerParagraphs().erase(old_pit);
+ paragraphs().erase(old_pit);
// update cursor par offset
cursor.par(parOffset(tmppit));
redoParagraph();
}
-ParagraphList & LyXText::ownerParagraphs() const
+ParagraphList & LyXText::paragraphs() const
{
- return *paragraphs_;
+ return const_cast<ParagraphList &>(paragraphs_);
}
bool LyXText::isInInset() const
{
- // Sub-level has non-null bv owner and non-null inset owner.
- return inset_owner != 0;
+ return in_inset_;
}
int defaultRowHeight()
{
- LyXFont const font(LyXFont::ALL_SANE);
- return int(font_metrics::maxHeight(font) * 1.2);
+ return int(font_metrics::maxHeight(LyXFont(LyXFont::ALL_SANE)) * 1.2);
}
ParagraphList::iterator pit;
ParagraphList::iterator end;
- getParsInRange(ownerParagraphs(),
+ getParsInRange(paragraphs(),
bv()->top_y() - yo_,
bv()->top_y() - yo_ + bv()->workHeight(),
pit, end);
bool LyXText::gotoNextInset(vector<InsetOld::Code> const & codes,
string const & contents)
{
- ParagraphList::iterator end = ownerParagraphs().end();
+ ParagraphList::iterator end = paragraphs().end();
ParagraphList::iterator pit = cursorPar();
pos_type pos = cursor.pos();
}
if (!gotoNextInset(codes, contents)) {
- if (cursor.pos() || cursorPar() != ownerParagraphs().begin()) {
+ if (cursor.pos() || cursorPar() != paragraphs().begin()) {
LyXCursor tmp = cursor;
cursor.par(0);
cursor.pos(0);
bool start = !pit->params().startOfAppendix();
// ensure that we have only one start_of_appendix in this document
- ParagraphList::iterator tmp = ownerParagraphs().begin();
- ParagraphList::iterator end = ownerParagraphs().end();
+ ParagraphList::iterator tmp = paragraphs().begin();
+ ParagraphList::iterator end = paragraphs().end();
for (; tmp != end; ++tmp) {
if (tmp->params().startOfAppendix()) {
case LFUN_INSET_TOGGLE:
clearSelection();
- toggleInset();
+ if (!toggleInset())
+ return DispatchResult(false);
bv->update();
bv->switchKeyMap();
break;
break;
case LFUN_BEGINNINGBUFSEL:
- if (inset_owner)
+ if (in_inset_)
return DispatchResult(false);
cursorTop();
finishChange(bv, true);
break;
case LFUN_ENDBUFSEL:
- if (inset_owner)
+ if (in_inset_)
return DispatchResult(false);
cursorBottom();
finishChange(bv, true);
// translates LyXText pointer into offset count from document begin
-ParIterator text2pit(BufferView * bv, LyXText * text, int & tcount)
+ParIterator text2pit(Buffer & buf, LyXText * text, int & tcount)
{
tcount = 0;
- Buffer * buf = text->bv()->buffer();
- ParIterator pit = buf->par_iterator_begin();
- ParIterator end = buf->par_iterator_end();
+ ParIterator pit = buf.par_iterator_begin();
+ ParIterator end = buf.par_iterator_end();
for ( ; pit != end; ++pit, ++tcount)
- if (pit.text(bv) == text)
+ if (pit.text(buf) == text)
return pit;
lyxerr << "undo: should not happen" << std::endl;
return end;
// translates offset from buffer begin to ParIterator
-ParIterator num2pit(BufferView * bv, int num)
+ParIterator num2pit(Buffer & buf, int num)
{
- Buffer * buf = bv->buffer();
- ParIterator pit = buf->par_iterator_begin();
- ParIterator end = buf->par_iterator_end();
+ ParIterator pit = buf.par_iterator_begin();
+ ParIterator end = buf.par_iterator_end();
for ( ; num && pit != end; ++pit, --num)
;
// don't crash early...
lyxerr << "undo: num2pit: num: " << num << std::endl;
BOOST_ASSERT(false);
- return buf->par_iterator_begin();
+ return buf.par_iterator_begin();
}
LyXText * text, paroffset_type first_par, paroffset_type last_par,
limited_stack<Undo> & stack)
{
- Buffer * buf = text->bv()->buffer();
+ Buffer & buf = *text->bv()->buffer();
- int const end_par = text->ownerParagraphs().size() - last_par;
+ int const end_par = text->paragraphs().size() - last_par;
// Undo::ATOMIC are always recorded (no overlapping there).
// overlapping only with insert and delete inside one paragraph:
// nobody wants all removed character appear one by one when undoing.
if (!undo_finished && kind != Undo::ATOMIC) {
// Check whether storing is needed.
- if (!buf->undostack().empty()
- && buf->undostack().top().kind == kind
- && buf->undostack().top().first_par == first_par
- && buf->undostack().top().end_par == end_par) {
+ if (!buf.undostack().empty()
+ && buf.undostack().top().kind == kind
+ && buf.undostack().top().first_par == first_par
+ && buf.undostack().top().end_par == end_par) {
// No additonal undo recording needed -
// effectively, we combine undo recordings to one.
return;
// make and push the Undo entry
int textnum;
- ParIterator pit = text2pit(text->bv(), text, textnum);
+ ParIterator pit = text2pit(buf, text, textnum);
stack.push(Undo(kind, textnum, pit.index(),
first_par, end_par, text->cursor.par(), text->cursor.pos()));
lyxerr << "undo record: " << stack.top() << std::endl;
// record the relevant paragraphs
ParagraphList & undo_pars = stack.top().pars;
- ParagraphList & plist = text->ownerParagraphs();
+ ParagraphList & plist = text->paragraphs();
ParagraphList::iterator first = plist.begin();
advance(first, first_par);
ParagraphList::iterator last = plist.begin();
// returns false if no undo possible
bool performUndoOrRedo(BufferView * bv, Undo const & undo)
{
+ Buffer & buf = *bv->buffer();
lyxerr << "undo, performing: " << undo << std::endl;
- ParIterator pit = num2pit(bv, undo.text);
- LyXText * text = pit.text(bv);
- ParagraphList & plist = text->ownerParagraphs();
+ ParIterator pit = num2pit(buf, undo.text);
+ LyXText * text = pit.text(buf);
+ ParagraphList & plist = text->paragraphs();
// remove new stuff between first and last
{
}
// set cursor
- lyxerr << "undo, text: " << undo.text
+ lyxerr << "undo, text: " << undo.text
<< " inset: " << pit.inset()
<< " index: " << undo.index
<< " par: " << undo.cursor_par
text->updateCounters();
// rebreak the entire lyxtext
- bv->text()->fullRebreak();
+ buf.text().fullRebreak();
pit.lockPath(bv);
+ text->setCursor(undo.cursor_par, undo.cursor_pos);
finishUndo();
return true;
bool textUndoOrRedo(BufferView * bv,
limited_stack<Undo> & stack, limited_stack<Undo> & otherstack)
{
+ Buffer & buf = *bv->buffer();
if (stack.empty()) {
// nothing to do
finishUndo();
if (!undo_frozen) {
otherstack.push(undo);
otherstack.top().pars.clear();
- ParIterator pit = num2pit(bv, undo.text);
+ ParIterator pit = num2pit(buf, undo.text);
ParagraphList & plist = pit.plist();
if (undo.first_par + undo.end_par <= int(plist.size())) {
ParagraphList::iterator first = plist.begin();
advance(last, plist.size() - undo.end_par + 1);
otherstack.top().pars.insert(otherstack.top().pars.begin(), first, last);
}
- LyXText * text = pit.text(bv);
+ LyXText * text = pit.text(buf);
otherstack.top().cursor_pos = text->cursor.pos();
otherstack.top().cursor_par = text->cursor.par();
lyxerr << " undo other: " << otherstack.top() << std::endl;