move the LyXText member

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8148 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-11-28 15:08:38 +00:00
parent e8185081bc
commit 741064fa58
6 changed files with 56 additions and 29 deletions

View File

@ -59,14 +59,11 @@ BufferView::BufferView(LyXView * owner, int xpos, int ypos,
int width, int height)
: pimpl_(new Pimpl(this, owner, xpos, ypos, width, height)),
x_target_(0)
{
text_ = 0;
}
{}
BufferView::~BufferView()
{
delete text_;
delete pimpl_;
}
@ -256,10 +253,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 +287,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 +306,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 +324,7 @@ void BufferView::undo()
return;
owner()->message(_("Undo"));
text_->clearSelection();
text()->clearSelection();
if (!textUndo(this))
owner()->message(_("No further undo information"));
update();
@ -341,7 +338,7 @@ void BufferView::redo()
return;
owner()->message(_("Redo"));
text_->clearSelection();
text()->clearSelection();
if (!textRedo(this))
owner()->message(_("No further redo information"));
update();
@ -461,3 +458,9 @@ void BufferView::updateParagraphDialog()
{
pimpl_->updateParagraphDialog();
}
LyXText * BufferView::text() const
{
return pimpl_->buffer_ ? &pimpl_->buffer_->text() : 0;
}

View File

@ -189,9 +189,7 @@ public:
///
UpdatableInset * innerInset() const;
///
LyXText * text() const { return text_; }
///
void setText(LyXText * t) { text_ = t; }
LyXText * text() const;
private:
///
@ -201,9 +199,6 @@ private:
///
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,12 +287,15 @@ void BufferView::Pimpl::buffer(Buffer * b)
<< b << ')' << endl;
if (buffer_) {
disconnectBuffer();
delete bv_->text();
bv_->setText(0);
//delete bv_->text();
//bv_->setText(0);
}
// set current buffer
buffer_ = b;
buffer_->text().init(bv_);
buffer_->text().textwidth_ = workarea().workWidth();
buffer_->text().fullRebreak();
top_y_ = 0;
@ -380,7 +383,11 @@ void BufferView::Pimpl::resizeCurrentBuffer()
owner_->message(_("Formatting document..."));
if (bv_->text()) {
lyxerr << "### resizeCurrentBuffer: text" << bv_->text() << endl;
if (!bv_->text())
return;
//if (bv_->text()) {
par = bv_->text()->cursor.par();
pos = bv_->text()->cursor.pos();
selstartpar = bv_->text()->selection.start.par();
@ -391,10 +398,10 @@ void BufferView::Pimpl::resizeCurrentBuffer()
mark_set = bv_->text()->selection.mark();
bv_->text()->fullRebreak();
update();
} else {
bv_->setText(new LyXText(bv_, 0, false, bv_->buffer()->paragraphs()));
bv_->text()->init(bv_);
}
//} else {
// bv_->setText(new LyXText(bv_, 0, false, bv_->buffer()->paragraphs()));
// bv_->text()->init(bv_);
//}
if (par != -1) {
bv_->text()->selection.set(true);

View File

@ -3,6 +3,13 @@
* factory.C: Syntax change for CharStyles
2003-11-28 André Pönitz <poenitz@gmx.net>
* BufferView.[Ch]:
* BufferView.[Ch]:
* buffer.[Ch]:
* buffer.[Ch]: move LyXText member
2003-11-28 André Pönitz <poenitz@gmx.net>
* BufferView.[Ch]: make LyXText * text a private member

View File

@ -31,6 +31,7 @@
#include "LaTeXFeatures.h"
#include "LyXAction.h"
#include "lyxlex.h"
#include "lyxtext.h"
#include "lyxrc.h"
#include "lyxvc.h"
#include "messages.h"
@ -179,13 +180,17 @@ struct Buffer::Impl
* and by the citation inset.
*/
bool file_fully_loaded;
/// our Text
LyXText text;
};
Buffer::Impl::Impl(Buffer & parent, string const & file, bool readonly_)
: nicefile(true),
lyx_clean(true), bak_clean(true), unnamed(false), read_only(readonly_),
filename(file), filepath(OnlyPath(file)), file_fully_loaded(false)
filename(file), filepath(OnlyPath(file)), file_fully_loaded(false),
text(0, 0, 0, paragraphs)
{
lyxvc.buffer(&parent);
if (readonly_ || lyxrc.use_tempdir)
@ -220,6 +225,12 @@ Buffer::~Buffer()
}
LyXText & Buffer::text() const
{
return const_cast<LyXText &>(pimpl_->text);
}
limited_stack<Undo> & Buffer::undostack()
{
return pimpl_->undostack;

View File

@ -34,6 +34,7 @@ class FuncRequest;
class LyXFont;
class LyXLex;
class LyXRC;
class LyXText;
class LyXVC;
class LaTeXFeatures;
class OutputParams;
@ -367,6 +368,9 @@ public:
/// Set by buffer_funcs' newFile.
void fully_loaded(bool);
///
LyXText & text() const;
private:
/** Inserts a file into a document
\param par if != 0 insert the file.