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) int width, int height)
: pimpl_(new Pimpl(this, owner, xpos, ypos, width, height)), : pimpl_(new Pimpl(this, owner, xpos, ypos, width, height)),
x_target_(0) x_target_(0)
{ {}
text_ = 0;
}
BufferView::~BufferView() BufferView::~BufferView()
{ {
delete text_;
delete pimpl_; delete pimpl_;
} }
@ -256,10 +253,10 @@ bool BufferView::insertLyXFile(string const & filen)
string const fname = MakeAbsPath(filen); string const fname = MakeAbsPath(filen);
text_->clearSelection(); text()->clearSelection();
text_->breakParagraph(buffer()->paragraphs()); text()->breakParagraph(buffer()->paragraphs());
bool res = buffer()->readFile(fname, text_->cursorPar()); bool res = buffer()->readFile(fname, text()->cursorPar());
resize(); resize();
return res; return res;
} }
@ -290,9 +287,9 @@ void BufferView::setCursorFromRow(int row)
buffer()->texrow().getIdFromRow(row, tmpid, tmppos); buffer()->texrow().getIdFromRow(row, tmpid, tmppos);
if (tmpid == -1) if (tmpid == -1)
text_->setCursor(0, 0); text()->setCursor(0, 0);
else 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; vector<string> labels;
it->getLabelList(*buffer(), labels); it->getLabelList(*buffer(), labels);
if (find(labels.begin(),labels.end(),label) != labels.end()) { if (find(labels.begin(),labels.end(),label) != labels.end()) {
text_->clearSelection(); text()->clearSelection();
text_->setCursor( text()->setCursor(
std::distance(text_->ownerParagraphs().begin(), it.getPar()), std::distance(text()->ownerParagraphs().begin(), it.getPar()),
it.getPos()); it.getPos());
text_->selection.cursor = text_->cursor; text()->selection.cursor = text()->cursor;
update(); update();
return; return;
} }
@ -327,7 +324,7 @@ void BufferView::undo()
return; return;
owner()->message(_("Undo")); owner()->message(_("Undo"));
text_->clearSelection(); text()->clearSelection();
if (!textUndo(this)) if (!textUndo(this))
owner()->message(_("No further undo information")); owner()->message(_("No further undo information"));
update(); update();
@ -341,7 +338,7 @@ void BufferView::redo()
return; return;
owner()->message(_("Redo")); owner()->message(_("Redo"));
text_->clearSelection(); text()->clearSelection();
if (!textRedo(this)) if (!textRedo(this))
owner()->message(_("No further redo information")); owner()->message(_("No further redo information"));
update(); update();
@ -461,3 +458,9 @@ void BufferView::updateParagraphDialog()
{ {
pimpl_->updateParagraphDialog(); pimpl_->updateParagraphDialog();
} }
LyXText * BufferView::text() const
{
return pimpl_->buffer_ ? &pimpl_->buffer_->text() : 0;
}

View File

@ -189,9 +189,7 @@ public:
/// ///
UpdatableInset * innerInset() const; UpdatableInset * innerInset() const;
/// ///
LyXText * text() const { return text_; } LyXText * text() const;
///
void setText(LyXText * t) { text_ = t; }
private: private:
/// ///
@ -201,9 +199,6 @@ private:
/// ///
Pimpl * 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 * The target x position of the cursor. This is used for when
* we have text like : * we have text like :

View File

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

View File

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

View File

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

View File

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