ismall stuff

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8144 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-11-28 08:55:12 +00:00
parent a9cd48f40e
commit 84b462dd37
25 changed files with 222 additions and 260 deletions

View File

@ -60,13 +60,13 @@ BufferView::BufferView(LyXView * owner, int xpos, int ypos,
: pimpl_(new Pimpl(this, owner, xpos, ypos, width, height)),
x_target_(0)
{
text = 0;
text_ = 0;
}
BufferView::~BufferView()
{
delete text;
delete text_;
delete pimpl_;
}
@ -256,10 +256,10 @@ bool BufferView::insertLyXFile(string const & filen)
string const fname = MakeAbsPath(filen);
text->clearSelection();
text->breakParagraph(buffer()->paragraphs());
text_->clearSelection();
text_->breakParagraph(buffer()->paragraphs());
bool res = buffer()->readFile(fname, text->cursorPar());
bool res = buffer()->readFile(fname, text_->cursorPar());
resize();
return res;
}
@ -290,9 +290,9 @@ void BufferView::setCursorFromRow(int row)
buffer()->texrow().getIdFromRow(row, tmpid, tmppos);
if (tmpid == -1)
text->setCursor(0, 0);
text_->setCursor(0, 0);
else
text->setCursor(buffer()->getParFromID(tmpid).pit(), tmppos);
text_->setCursor(buffer()->getParFromID(tmpid).pit(), tmppos);
}
@ -309,11 +309,11 @@ void BufferView::gotoLabel(string const & label)
vector<string> labels;
it->getLabelList(*buffer(), labels);
if (find(labels.begin(),labels.end(),label) != labels.end()) {
text->clearSelection();
text->setCursor(
std::distance(text->ownerParagraphs().begin(), it.getPar()),
text_->clearSelection();
text_->setCursor(
std::distance(text_->ownerParagraphs().begin(), it.getPar()),
it.getPos());
text->selection.cursor = text->cursor;
text_->selection.cursor = text_->cursor;
update();
return;
}
@ -327,7 +327,7 @@ void BufferView::undo()
return;
owner()->message(_("Undo"));
text->clearSelection();
text_->clearSelection();
if (!textUndo(this))
owner()->message(_("No further undo information"));
update();
@ -341,7 +341,7 @@ void BufferView::redo()
return;
owner()->message(_("Redo"));
text->clearSelection();
text_->clearSelection();
if (!textRedo(this))
owner()->message(_("No further redo information"));
update();
@ -354,14 +354,14 @@ void BufferView::replaceWord(string const & replacestring)
if (!available())
return;
LyXText * text = getLyXText();
LyXText * t = getLyXText();
text->replaceSelectionWithString(replacestring);
text->setSelectionRange(replacestring.length());
t->replaceSelectionWithString(replacestring);
t->setSelectionRange(replacestring.length());
// Go back so that replacement string is also spellchecked
for (string::size_type i = 0; i < replacestring.length() + 1; ++i)
text->cursorLeft(this);
t->cursorLeft(this);
// FIXME: should be done through LFUN
buffer()->markDirty();
@ -410,13 +410,13 @@ Language const * BufferView::getParentLanguage(InsetOld * inset) const
Encoding const * BufferView::getEncoding() const
{
LyXText * text = getLyXText();
if (!text)
LyXText * t = getLyXText();
if (!t)
return 0;
return text->cursorPar()->getFont(
return t->cursorPar()->getFont(
buffer()->params(),
text->cursor.pos(),
outerFont(text->cursorPar(), text->ownerParagraphs())
t->cursor.pos(),
outerFont(t->cursorPar(), t->ownerParagraphs())
).language()->encoding();
}

View File

@ -104,11 +104,6 @@ public:
/// return the current change at the cursor
Change const getCurrentChange();
/**
* This holds the mapping between buffer paragraphs and screen rows.
* This should be private...but not yet. (Lgb)
*/
LyXText * text;
/// return the lyxtext we are using
LyXText * getLyXText() const;
@ -193,13 +188,22 @@ public:
LCursor const & cursor() const;
///
UpdatableInset * innerInset() const;
///
LyXText * text() const { return text_; }
///
void setText(LyXText * t) { text_ = t; }
private:
///
struct Pimpl;
///
friend struct BufferView::Pimpl;
///
Pimpl * pimpl_;
/// This holds the mapping between buffer paragraphs and screen rows.
LyXText * text_;
/**
* The target x position of the cursor. This is used for when
* we have text like :

View File

@ -287,8 +287,8 @@ void BufferView::Pimpl::buffer(Buffer * b)
<< b << ')' << endl;
if (buffer_) {
disconnectBuffer();
delete bv_->text;
bv_->text = 0;
delete bv_->text();
bv_->setText(0);
}
// set current buffer
@ -309,7 +309,7 @@ void BufferView::Pimpl::buffer(Buffer * b)
connectBuffer(*buffer_);
// If we don't have a text object for this, we make one
if (bv_->text == 0)
if (bv_->text() == 0)
resizeCurrentBuffer();
// FIXME: needed when ?
@ -333,7 +333,7 @@ void BufferView::Pimpl::buffer(Buffer * b)
// Don't forget to update the Layout
if (buffer_)
owner_->setLayout(bv_->text->cursorPar()->layout()->name());
owner_->setLayout(bv_->text()->cursorPar()->layout()->name());
if (lyx::graphics::Previews::activated() && buffer_)
lyx::graphics::Previews::get().generateBufferPreviews(*buffer_);
@ -354,7 +354,7 @@ bool BufferView::Pimpl::fitCursor()
void BufferView::Pimpl::redoCurrentBuffer()
{
lyxerr[Debug::INFO] << "BufferView::redoCurrentBuffer" << endl;
if (buffer_ && bv_->text) {
if (buffer_ && bv_->text()) {
resizeCurrentBuffer();
updateScrollbar();
owner_->updateLayoutChoice();
@ -380,37 +380,37 @@ void BufferView::Pimpl::resizeCurrentBuffer()
owner_->message(_("Formatting document..."));
if (bv_->text) {
par = bv_->text->cursor.par();
pos = bv_->text->cursor.pos();
selstartpar = bv_->text->selection.start.par();
selstartpos = bv_->text->selection.start.pos();
selendpar = bv_->text->selection.end.par();
selendpos = bv_->text->selection.end.pos();
selection = bv_->text->selection.set();
mark_set = bv_->text->selection.mark();
bv_->text->fullRebreak();
if (bv_->text()) {
par = bv_->text()->cursor.par();
pos = bv_->text()->cursor.pos();
selstartpar = bv_->text()->selection.start.par();
selstartpos = bv_->text()->selection.start.pos();
selendpar = bv_->text()->selection.end.par();
selendpos = bv_->text()->selection.end.pos();
selection = bv_->text()->selection.set();
mark_set = bv_->text()->selection.mark();
bv_->text()->fullRebreak();
update();
} else {
bv_->text = new LyXText(bv_, 0, false, bv_->buffer()->paragraphs());
bv_->text->init(bv_);
bv_->setText(new LyXText(bv_, 0, false, bv_->buffer()->paragraphs()));
bv_->text()->init(bv_);
}
if (par != -1) {
bv_->text->selection.set(true);
bv_->text()->selection.set(true);
// At this point just to avoid the Delete-Empty-Paragraph-
// Mechanism when setting the cursor.
bv_->text->selection.mark(mark_set);
bv_->text()->selection.mark(mark_set);
if (selection) {
bv_->text->setCursor(selstartpar, selstartpos);
bv_->text->selection.cursor = bv_->text->cursor;
bv_->text->setCursor(selendpar, selendpos);
bv_->text->setSelection();
bv_->text->setCursor(par, pos);
bv_->text()->setCursor(selstartpar, selstartpos);
bv_->text()->selection.cursor = bv_->text()->cursor;
bv_->text()->setCursor(selendpar, selendpos);
bv_->text()->setSelection();
bv_->text()->setCursor(par, pos);
} else {
bv_->text->setCursor(par, pos);
bv_->text->selection.cursor = bv_->text->cursor;
bv_->text->selection.set(false);
bv_->text()->setCursor(par, pos);
bv_->text()->selection.cursor = bv_->text()->cursor;
bv_->text()->selection.set(false);
}
}
@ -428,13 +428,13 @@ void BufferView::Pimpl::resizeCurrentBuffer()
void BufferView::Pimpl::updateScrollbar()
{
if (!bv_->text) {
if (!bv_->text()) {
lyxerr[Debug::GUI] << "no text in updateScrollbar" << endl;
workarea().setScrollbarParams(0, 0, 0);
return;
}
LyXText const & t = *bv_->text;
LyXText const & t = *bv_->text();
lyxerr[Debug::GUI] << "Updating scrollbar: h " << t.height << ", top_y() "
<< top_y() << ", default height " << defaultRowHeight() << endl;
@ -462,7 +462,7 @@ void BufferView::Pimpl::scrollDocView(int value)
int const first = top_y() + height;
int const last = top_y() + workarea().workHeight() - height;
LyXText * text = bv_->text;
LyXText * text = bv_->text();
if (text->cursor.y() < first)
text->setCursorFromCoordinates(0, first);
else if (text->cursor.y() > last)
@ -477,7 +477,7 @@ void BufferView::Pimpl::scroll(int lines)
if (!buffer_)
return;
LyXText const * t = bv_->text;
LyXText const * t = bv_->text();
int const line_height = defaultRowHeight();
// The new absolute coordinate
@ -523,15 +523,15 @@ void BufferView::Pimpl::selectionRequested()
LyXText * text = bv_->getLyXText();
if (text->selection.set() &&
(!bv_->text->xsel_cache.set() ||
text->selection.start != bv_->text->xsel_cache.start ||
text->selection.end != bv_->text->xsel_cache.end))
(!bv_->text()->xsel_cache.set() ||
text->selection.start != bv_->text()->xsel_cache.start ||
text->selection.end != bv_->text()->xsel_cache.end))
{
bv_->text->xsel_cache = text->selection;
bv_->text()->xsel_cache = text->selection;
sel = text->selectionAsString(*bv_->buffer(), false);
} else if (!text->selection.set()) {
sel = string();
bv_->text->xsel_cache.set(false);
bv_->text()->xsel_cache.set(false);
}
if (!sel.empty()) {
workarea().putClipboard(sel);
@ -544,7 +544,7 @@ void BufferView::Pimpl::selectionLost()
if (available()) {
screen().hideCursor();
bv_->getLyXText()->clearSelection();
bv_->text->xsel_cache.set(false);
bv_->text()->xsel_cache.set(false);
}
}
@ -590,7 +590,7 @@ void BufferView::Pimpl::update()
getParsInRange(buffer_->paragraphs(),
top_y(), top_y() + workarea().workHeight(),
beg, end);
bv_->text->redoParagraphs(beg, end);
bv_->text()->redoParagraphs(beg, end);
bv_->getLyXText()->redoCursor();
updateScrollbar();
}
@ -613,7 +613,7 @@ void BufferView::Pimpl::cursorToggle()
bool BufferView::Pimpl::available() const
{
return buffer_ && bv_->text;
return buffer_ && bv_->text();
}
@ -637,8 +637,8 @@ void BufferView::Pimpl::savePosition(unsigned int i)
if (i >= saved_positions_num)
return;
saved_positions[i] = Position(buffer_->fileName(),
bv_->text->cursorPar()->id(),
bv_->text->cursor.pos());
bv_->text()->cursorPar()->id(),
bv_->text()->cursor.pos());
if (i > 0)
owner_->message(bformat(_("Saved bookmark %1$s"), tostr(i)));
}
@ -651,7 +651,7 @@ void BufferView::Pimpl::restorePosition(unsigned int i)
string const fname = saved_positions[i].filename;
bv_->text->clearSelection();
bv_->text()->clearSelection();
if (fname != buffer_->fileName()) {
Buffer * b = 0;
@ -669,7 +669,7 @@ void BufferView::Pimpl::restorePosition(unsigned int i)
if (par == buffer_->par_iterator_end())
return;
bv_->text->setCursor(par.pit(),
bv_->text()->setCursor(par.pit(),
min(par->size(), saved_positions[i].par_pos));
if (i > 0)
@ -701,7 +701,7 @@ void BufferView::Pimpl::switchKeyMap()
void BufferView::Pimpl::center()
{
LyXText * text = bv_->text;
LyXText * text = bv_->text();
text->clearSelection();
int const half_height = workarea().workHeight() / 2;
@ -843,7 +843,7 @@ void BufferView::Pimpl::trackChanges()
buf->undostack().clear();
} else {
update();
bv_->text->setCursor(0, 0);
bv_->text()->setCursor(0, 0);
#warning changes FIXME
bool found = lyx::find::findNextChange(bv_);
if (found) {
@ -867,7 +867,7 @@ namespace {
InsetOld * insetFromCoords(BufferView * bv, int x, int y)
{
LyXText * text = bv->text;
LyXText * text = bv->text();
InsetOld * inset = 0;
theTempCursor = LCursor(bv);
while (true) {
@ -1208,7 +1208,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
break;
case LFUN_ACCEPT_ALL_CHANGES: {
bv_->text->setCursor(0, 0);
bv_->text()->setCursor(0, 0);
#warning FIXME changes
while (lyx::find::findNextChange(bv_))
bv_->getLyXText()->acceptChange();
@ -1217,7 +1217,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
}
case LFUN_REJECT_ALL_CHANGES: {
bv_->text->setCursor(0, 0);
bv_->text()->setCursor(0, 0);
#warning FIXME changes
while (lyx::find::findNextChange(bv_))
bv_->getLyXText()->rejectChange();
@ -1262,25 +1262,25 @@ bool BufferView::Pimpl::insertInset(InsetOld * inset, string const & lout)
#endif
// not quite sure if we want this...
bv_->text->recUndo(bv_->text->cursor.par());
bv_->text()->recUndo(bv_->text()->cursor.par());
freezeUndo();
bv_->text->clearSelection();
bv_->text()->clearSelection();
if (!lout.empty()) {
bv_->text->breakParagraph(bv_->buffer()->paragraphs());
bv_->text()->breakParagraph(bv_->buffer()->paragraphs());
if (!bv_->text->cursorPar()->empty()) {
bv_->text->cursorLeft(bv_);
bv_->text->breakParagraph(bv_->buffer()->paragraphs());
if (!bv_->text()->cursorPar()->empty()) {
bv_->text()->cursorLeft(bv_);
bv_->text()->breakParagraph(bv_->buffer()->paragraphs());
}
string lres = lout;
LyXTextClass const & tclass = buffer_->params().getLyXTextClass();
bool hasLayout = tclass.hasLayout(lres);
bv_->text->setLayout(hasLayout ? lres : tclass.defaultLayoutName());
bv_->text()->setLayout(hasLayout ? lres : tclass.defaultLayoutName());
bv_->text->setParagraph(
bv_->text()->setParagraph(
VSpace(VSpace::NONE), VSpace(VSpace::NONE),
Spacing(),
LYX_ALIGN_LAYOUT,
@ -1297,7 +1297,7 @@ bool BufferView::Pimpl::ChangeInsets(InsetOld::Code code,
string const & from, string const & to)
{
bool need_update = false;
LyXCursor cursor = bv_->text->cursor;
LyXCursor cursor = bv_->text()->cursor;
LyXCursor tmpcursor = cursor;
cursor.par(tmpcursor.par());
cursor.pos(tmpcursor.pos());
@ -1324,12 +1324,12 @@ bool BufferView::Pimpl::ChangeInsets(InsetOld::Code code,
// The test it.size()==1 was needed to prevent crashes.
// How to set the cursor correctly when it.size()>1 ??
if (it.size() == 1) {
bv_->text->setCursorIntern(bv_->text->parOffset(it.pit()), 0);
bv_->text->redoParagraph(bv_->text->cursorPar());
bv_->text()->setCursorIntern(bv_->text()->parOffset(it.pit()), 0);
bv_->text()->redoParagraph(bv_->text()->cursorPar());
}
}
}
bv_->text->setCursorIntern(cursor.par(), cursor.pos());
bv_->text()->setCursorIntern(cursor.par(), cursor.pos());
return need_update;
}

View File

@ -1,4 +1,21 @@
2003-11-28 André Pönitz <poenitz@gmx.net>
* BufferView.[Ch]: make LyXText * text a private member
* BufferView_pimpl.C:
* cursor.C:
* iterators.C:
* lyx_cb.C:
* lyxfind.C:
* lyxtext.h:
* rowpainter.[Ch]:
* text.C:
* text2.C:
* undo.C: adjust
* output_plaintext.C: cleanup
2003-11-27 Martin Vermeer <martin.vermeer@hut.fi>
* buffer.C:

View File

@ -101,8 +101,8 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
break;
}
}
lyxerr << "trying to dispatch to main text " << bv_->text << endl;
DispatchResult res = bv_->text->dispatch(cmd);
lyxerr << "trying to dispatch to main text " << bv_->text() << endl;
DispatchResult res = bv_->text()->dispatch(cmd);
lyxerr << " result: " << res.val() << endl;
if (!res.dispatched()) {
@ -160,7 +160,7 @@ LyXText * LCursor::innerText() const
if (data_[i].text())
return data_[i].text();
}
return bv_->text;
return bv_->text();
}
@ -187,8 +187,8 @@ void LCursor::getDim(int & asc, int & desc) const
void LCursor::getPos(int & x, int & y) const
{
if (data_.empty()) {
x = bv_->text->cursor.x();
y = bv_->text->cursor.y();
x = bv_->text()->cursor.x();
y = bv_->text()->cursor.y();
// y -= bv_->top_y();
} else {
// Would be nice to clean this up to make some understandable sense...
@ -201,7 +201,6 @@ void LCursor::getPos(int & x, int & y) const
// inset.top_baseline, so getCursor() returns an old value.
// Ugly as you like.
//inset->getCursorPos(bv_, x, y);
//y = inset->insetInInsetY() + bv_->text->cursor.y();
inset->getCursorPos(x, y);
x += inset->x();
y += cached_y_;

View File

@ -242,7 +242,7 @@ bool LyXScreen::fitCursor(BufferView * bv)
void LyXScreen::redraw(BufferView & bv)
{
greyed_out_ = !bv.text;
greyed_out_ = !bv.text();
if (greyed_out_) {
greyOut();
@ -257,7 +257,7 @@ void LyXScreen::redraw(BufferView & bv)
// maybe we have to clear the screen at the bottom
int const y2 = workarea().workHeight();
if (y < y2 && !bv.text->isInInset()) {
if (y < y2 && !bv.text()->isInInset()) {
workarea().getPainter().fillRectangle(0, y,
workarea().workWidth(), y2 - y,
LColor::bottomarea);

View File

@ -1,3 +1,14 @@
2003-11-28 André Pönitz <poenitz@gmx.net>
* updatableinset.h: remove insetInInsetY
* insetcollapsable.[Ch]:
* insetnewline.C:
* insettabular.[Ch]:
* insettext.[Ch]: adjust
2003-11-27 Alfredo Braunstein <abraunst@lyx.org>
* insettext.[Ch]:

View File

@ -318,12 +318,6 @@ InsetCollapsable::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
}
int InsetCollapsable::insetInInsetY() const
{
return inset.y() - yo_ + inset.insetInInsetY();
}
void InsetCollapsable::validate(LaTeXFeatures & features) const
{
inset.validate(features);

View File

@ -61,8 +61,6 @@ public:
///
bool isTextInset() const { return true; }
///
int insetInInsetY() const;
///
int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
///

View File

@ -89,7 +89,7 @@ void InsetNewline::draw(PainterInfo & pi, int x, int y) const
// hack, and highly dubious
lyx::pos_type pos = ownerPar(*pi.base.bv->buffer(), this)
.getPositionOfInset(this);
bool const ltr_pos = (pi.base.bv->text->bidi.level(pos) % 2 == 0);
bool const ltr_pos = (pi.base.bv->text()->bidi.level(pos) % 2 == 0);
int xp[3];
int yp[3];

View File

@ -388,14 +388,6 @@ void InsetTabular::updateLocal(BufferView * bv) const
}
int InsetTabular::insetInInsetY() const
{
if (the_locking_inset)
return cursory_ + the_locking_inset->insetInInsetY();
return 0;
}
bool InsetTabular::insertInset(BufferView * bv, InsetOld * inset)
{
return the_locking_inset && the_locking_inset->insertInset(bv, inset);

View File

@ -80,8 +80,6 @@ public:
///
void updateLocal(BufferView *) const;
///
int insetInInsetY() const;
///
bool insertInset(BufferView *, InsetOld *);
///
bool insetAllowed(InsetOld::Code code) const;

View File

@ -78,7 +78,6 @@ InsetText::InsetText(BufferParams const & bp)
frame_color_(LColor::insetframe),
text_(0, this, true, paragraphs)
{
textwidth_ = 0; // broken
paragraphs.begin()->layout(bp.getLyXTextClass().defaultLayout());
if (bp.tracking_changes)
paragraphs.begin()->trackChanges();
@ -102,7 +101,6 @@ void InsetText::operator=(InsetText const & in)
autoBreakRows_ = in.autoBreakRows_;
drawFrame_ = in.drawFrame_;
frame_color_ = in.frame_color_;
textwidth_ = in.textwidth_;
text_ = LyXText(in.text_.bv_owner, this, true, paragraphs);
init();
}
@ -218,7 +216,6 @@ void InsetText::read(Buffer const & buf, LyXLex & lex)
void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
{
//lyxerr << "InsetText::metrics: width: " << mi.base.textwidth << endl;
textwidth_ = mi.base.textwidth;
mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET;
setViewCache(mi.base.bv);
text_.metrics(mi, dim);
@ -236,24 +233,21 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const
xo_ = x;
yo_ = y;
BufferView * bv = pi.base.bv;
Painter & pain = pi.pain;
// repaint the background if needed
x += TEXT_TO_INSET_OFFSET;
if (backgroundColor() != LColor::background)
clearInset(bv, xo_ + TEXT_TO_INSET_OFFSET, y);
clearInset(pain, x, y);
BufferView * bv = pi.base.bv;
bv->hideCursor();
if (!owner())
x += scroll();
x += TEXT_TO_INSET_OFFSET;
y += bv->top_y() - text_.firstRow()->ascent_of_text();
text_.xo_ = x;
text_.yo_ = y;
paintTextInset(*bv, text_, x, y);
text_.draw(pi, x, y);
if (drawFrame_ == ALWAYS || drawFrame_ == LOCKED)
drawFrame(pain, xo_);
@ -271,7 +265,7 @@ void InsetText::drawFrame(Painter & pain, int x) const
}
void InsetText::updateLocal(BufferView * bv, bool /*mark_dirty*/)
void InsetText::updateLocal(BufferView * bv)
{
if (!bv)
return;
@ -286,7 +280,7 @@ void InsetText::updateLocal(BufferView * bv, bool /*mark_dirty*/)
bv->owner()->updateMenubar();
bv->owner()->updateToolbar();
if (old_par != text_.cursor.par()) {
bv->owner()->setLayout(cpar()->layout()->name());
bv->owner()->setLayout(text_.cursorPar()->layout()->name());
old_par = text_.cursor.par();
}
}
@ -326,7 +320,7 @@ void InsetText::edit(BufferView * bv, bool left)
text_.setCursor(paragraphs.size() - 1, paragraphs.back().size());
sanitizeEmptyText(bv);
updateLocal(bv, false);
updateLocal(bv);
bv->updateParagraphDialog();
}
@ -341,7 +335,7 @@ void InsetText::edit(BufferView * bv, int x, int y)
text_.clearSelection();
finishUndo();
updateLocal(bv, false);
updateLocal(bv);
bv->updateParagraphDialog();
}
@ -437,17 +431,12 @@ void InsetText::getCursorPos(int & x, int & y) const
}
int InsetText::insetInInsetY() const
{
return 0;
}
bool InsetText::insertInset(BufferView * bv, InsetOld * inset)
{
inset->setOwner(this);
text_.insertInset(inset);
updateLocal(bv, true);
updateLocal(bv);
#warning should we mark the buffer dirty?
return true;
}
@ -540,24 +529,6 @@ void InsetText::setFrameColor(LColor_color col)
}
pos_type InsetText::cpos() const
{
return text_.cursor.pos();
}
ParagraphList::iterator InsetText::cpar() const
{
return text_.cursorPar();
}
RowList::iterator InsetText::crow() const
{
return cpar()->getRow(cpos());
}
void InsetText::setViewCache(BufferView const * bv) const
{
if (bv && bv != text_.bv_owner) {
@ -585,15 +556,8 @@ int InsetText::scroll(bool /*recursive*/) const
}
void InsetText::clearSelection(BufferView *)
void InsetText::clearInset(Painter & pain, int x, int y) const
{
text_.clearSelection();
}
void InsetText::clearInset(BufferView * bv, int x, int y) const
{
Painter & pain = bv->painter();
int w = dim_.wid;
int h = dim_.asc + dim_.des;
int ty = y - dim_.asc;

View File

@ -59,11 +59,11 @@ public:
/// empty inset to empty par, or just mark as erased
void clear(bool just_mark_erased);
///
void read(Buffer const &, LyXLex &);
void read(Buffer const & buf, LyXLex & lex);
///
void write(Buffer const &, std::ostream &) const;
void write(Buffer const & buf, std::ostream & os) const;
///
void metrics(MetricsInfo &, Dimension &) const;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///
@ -89,8 +89,6 @@ public:
/// FIXME, document
void getCursorPos(int & x, int & y) const;
///
int insetInInsetY() const;
///
bool insertInset(BufferView *, InsetOld *);
///
bool insetAllowed(InsetOld::Code) const;
@ -129,8 +127,6 @@ public:
UpdatableInset::scroll(bv, offset);
}
///
void clearSelection(BufferView * bv);
///
ParagraphList * getParagraphs(int) const;
///
LyXText * getText(int) const;
@ -165,14 +161,12 @@ public:
int numParagraphs() const { return 1; }
///
mutable ParagraphList paragraphs;
protected:
private:
///
DispatchResult
priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
///
void updateLocal(BufferView *, bool mark_dirty);
private:
void updateLocal(BufferView *);
///
void init();
// If the inset is empty set the language of the current font to the
@ -183,15 +177,9 @@ private:
///
void removeNewlines();
///
lyx::pos_type cpos() const;
///
ParagraphList::iterator cpar() const;
///
RowList::iterator crow() const;
///
void drawFrame(Painter &, int x) const;
///
void clearInset(BufferView *, int start_x, int baseline) const;
void clearInset(Painter &, int x, int y) const;
///
void collapseParagraphs(BufferView *);
@ -205,8 +193,6 @@ private:
*/
int frame_color_;
///
bool no_selection;
///
mutable lyx::paroffset_type old_par;
/** to remember old painted frame dimensions to clear it on
@ -216,7 +202,5 @@ private:
public:
///
mutable LyXText text_;
///
mutable int textwidth_;
};
#endif

View File

@ -35,8 +35,6 @@ public:
virtual void getCursorDim(int &, int &) const;
///
virtual bool insertInset(BufferView *, InsetOld *) { return false; }
///
virtual int insetInInsetY() const { return 0; }
// We need this method to not clobber the real method in Inset
int scroll(bool recursive = true) const
{ return InsetOld::scroll(recursive); }

View File

@ -153,7 +153,7 @@ LyXText * ParIterator::text(BufferView * bv) const
{
//lyxerr << "positions.size: " << pimpl_->positions.size() << std::endl;
if (pimpl_->positions.size() <= 1)
return bv->text;
return bv->text();
ParPosition const & pos = pimpl_->positions[pimpl_->positions.size() - 2];
return (*pos.it)->inset->getText(*pos.index);

View File

@ -353,8 +353,8 @@ void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
return;
// clear the selection
if (bv->text == bv->getLyXText())
bv->text->clearSelection();
if (bv->text() == bv->getLyXText())
bv->text()->clearSelection();
if (asParagraph)
bv->getLyXText()->insertStringAsParagraphs(tmpstr);
else

View File

@ -159,8 +159,7 @@ int replaceAll(BufferView * bv,
if (!searchAllowed(bv, searchstr) || buf.isReadonly())
return 0;
recordUndo(Undo::ATOMIC, bv->text, 0,
buf.paragraphs().size() - 1);
recordUndo(Undo::ATOMIC, bv->text(), 0, buf.paragraphs().size() - 1);
PosIterator cur = buf.pos_iterator_begin();
PosIterator const end = buf.pos_iterator_end();
@ -181,7 +180,7 @@ int replaceAll(BufferView * bv,
}
PosIterator beg = buf.pos_iterator_begin();
bv->text->init(bv);
bv->text()->init(bv);
put_selection_at(bv, beg, 0, false);
if (num)
buf.markDirty();
@ -201,8 +200,7 @@ bool stringSelected(BufferView * bv,
string const & str1 = searchstr;
string const str2 = text->selectionAsString(*bv->buffer(),
false);
if ((cs && str1 != str2)
|| lowercase(str1) != lowercase(str2)) {
if ((cs && str1 != str2) || lowercase(str1) != lowercase(str2)) {
find(bv, searchstr, cs, mw, fw);
return false;
}

View File

@ -128,6 +128,8 @@ public:
void fullRebreak();
/// compute text metrics
void metrics(MetricsInfo & mi, Dimension & dim);
/// draw text (only used for insets)
void draw(PainterInfo & pi, int x, int y) const;
///
DispatchResult dispatch(FuncRequest const & cmd);
@ -418,8 +420,8 @@ public:
ParagraphList * paragraphs_;
/// absolute document pixel coordinates of this LyXText
int xo_;
int yo_;
mutable int xo_;
mutable int yo_;
private:

View File

@ -144,7 +144,7 @@ void asciiParagraph(Buffer const & buf,
//--
// we should probably change to the paragraph language in the
// gettext here (if possible) so that strings are outputted in
// gettext here (if possible) so that strings are output in
// the correct language! (20012712 Jug)
//--
switch (ltype) {
@ -152,6 +152,7 @@ void asciiParagraph(Buffer const & buf,
case 4: // (Sub)Paragraph
case 5: // Description
break;
case 6: // Abstract
if (runparams.linelen > 0) {
os << _("Abstract") << "\n\n";
@ -162,6 +163,7 @@ void asciiParagraph(Buffer const & buf,
currlinelen += abst.length();
}
break;
case 7: // Bibliography
if (!ref_printed) {
if (runparams.linelen > 0) {
@ -172,17 +174,16 @@ void asciiParagraph(Buffer const & buf,
os << refs;
currlinelen += refs.length();
}
ref_printed = true;
}
break;
default:
{
string const parlab = par.params().labelString();
os << parlab << ' ';
currlinelen += parlab.length() + 1;
default: {
string const label = par.params().labelString();
os << label << ' ';
currlinelen += label.length() + 1;
break;
}
break;
}
}
@ -202,59 +203,52 @@ void asciiParagraph(Buffer const & buf,
for (pos_type i = 0; i < par.size(); ++i) {
char c = par.getUChar(buf.params(), i);
switch (c) {
case Paragraph::META_INSET:
{
case Paragraph::META_INSET: {
InsetOld const * inset = par.getInset(i);
if (inset) {
if (runparams.linelen > 0) {
os << word;
currlinelen += word.length();
word.erase();
}
if (inset->plaintext(buf, os, runparams)) {
// to be sure it breaks paragraph
currlinelen += runparams.linelen;
}
if (runparams.linelen > 0) {
os << word;
currlinelen += word.length();
word.erase();
}
if (inset->plaintext(buf, os, runparams)) {
// to be sure it breaks paragraph
currlinelen += runparams.linelen;
}
break;
}
break;
case ' ':
if (runparams.linelen > 0 &&
currlinelen + word.length() > runparams.linelen - 10) {
os << "\n";
pair<int, string> p = addDepth(depth, ltype_depth);
os << p.second;
currlinelen = p.first;
}
os << word << ' ';
currlinelen += word.length() + 1;
word.erase();
break;
case '\0':
lyxerr[Debug::INFO] <<
"writeAsciiFile: NULL char in structure." << endl;
break;
default:
if (c == ' ') {
if (runparams.linelen > 0 &&
currlinelen + word.length() > runparams.linelen - 10) {
os << "\n";
pair<int, string> p = addDepth(depth, ltype_depth);
os << p.second;
currlinelen = p.first;
}
os << word << ' ';
currlinelen += word.length() + 1;
word.erase();
} else {
if (c != '\0') {
word += c;
} else {
lyxerr[Debug::INFO] <<
"writeAsciiFile: NULL char in structure." << endl;
}
if ((runparams.linelen > 0) &&
(currlinelen + word.length()) > runparams.linelen)
{
os << "\n";
pair<int, string> p =
addDepth(depth, ltype_depth);
os << p.second;
currlinelen = p.first;
}
word += c;
if (runparams.linelen > 0 &&
currlinelen + word.length() > runparams.linelen)
{
os << "\n";
pair<int, string> p = addDepth(depth, ltype_depth);
os << p.second;
currlinelen = p.first;
}
break;
}
}
os << word;
}

View File

@ -129,7 +129,7 @@ RowPainter::RowPainter(BufferView const & bv, LyXText const & text,
x_ += xo_;
// background has already been cleared.
if (&text_ == bv_.text)
if (&text_ == bv_.text())
paintBackground();
// paint the selection background
@ -960,15 +960,15 @@ int paintPars(BufferView const & bv, LyXText const & text,
} // namespace anon
int paintText(BufferView & bv)
int paintText(BufferView const & bv)
{
ParagraphList::iterator pit;
bv.text->getRowNearY(bv.top_y(), pit);
return paintPars(bv, *bv.text, pit, 0, 0, pit->y);
bv.text()->getRowNearY(bv.top_y(), pit);
return paintPars(bv, *bv.text(), pit, 0, 0, pit->y);
}
void paintTextInset(BufferView & bv, LyXText & text, int xo, int yo)
void paintTextInset(BufferView const & bv, LyXText const & text, int xo, int yo)
{
paintPars(bv, text, text.ownerParagraphs().begin(), xo, yo, 0);
}

View File

@ -21,9 +21,9 @@ class VSpace;
int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp);
/// paint the rows of the main text, return last drawn y value
int paintText(BufferView & bv);
int paintText(BufferView const & bv);
/// paint the rows of a text inset
void paintTextInset(BufferView & bv, LyXText & text, int x, int y);
void paintTextInset(BufferView const & bv, LyXText const & text, int x, int y);
#endif // ROWPAINTER_H

View File

@ -1641,6 +1641,15 @@ void LyXText::metrics(MetricsInfo & mi, Dimension & dim)
}
// only used for inset right now. should also be used for main text
void LyXText::draw(PainterInfo & pi, int x, int y) const
{
xo_ = x;
yo_ = y;
paintTextInset(*bv(), *this, x, y);
}
bool LyXText::isLastRow(ParagraphList::iterator pit, Row const & row) const
{
return row.endpos() >= pit->size()

View File

@ -506,8 +506,8 @@ void LyXText::clearSelection()
TextCursor::clearSelection();
// reset this in the bv()!
if (bv() && bv()->text)
bv()->text->xsel_cache.set(false);
if (bv() && bv()->text())
bv()->text()->xsel_cache.set(false);
}

View File

@ -188,7 +188,7 @@ bool performUndoOrRedo(BufferView * bv, Undo const & undo)
text->updateCounters();
// rebreak the entire lyxtext
bv->text->fullRebreak();
bv->text()->fullRebreak();
pit.lockPath(bv);
@ -292,5 +292,5 @@ void recordUndo(Undo::undo_kind kind, LyXText const * text, paroffset_type par)
void recordUndo(BufferView * bv, Undo::undo_kind kind)
{
recordUndo(kind, bv->text, bv->text->cursor.par());
recordUndo(kind, bv->text(), bv->text()->cursor.par());
}