+2000-06-20 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * src/BufferView_pimpl.C: changes because of the one below
+
+ * src/screen.[Ch]: Made the lyxscreen take LyXText as argument
+ instead of storing a pointer to a LyXText.
+
+ * src/buffer.[Ch]: apply Baruch's remove isdviclean patch.
+
2000-06-10 Dekel Tsur <dekel@math.tau.ac.il>
* src/lyxparagraph.h
{
if (the_locking_inset && available()){
y += text->cursor.y() + the_locking_inset->InsetInInsetY();
- if (pimpl_->screen_->FitManualCursor(x, y, asc, desc))
+ if (pimpl_->screen_->FitManualCursor(text, x, y, asc, desc))
updateScrollbar();
}
}
updateScreen();
updateScrollbar();
}
- screen_->first = screen_->TopCursorVisible();
+ screen_->first = screen_->TopCursorVisible(bv_->text);
redraw();
owner_->getDialogs()->updateBufferDependent();
bv_->insetWakeup();
{
Assert(screen_); // it is a programming error to call fitCursor
// without a valid screen.
- bool ret = screen_->FitCursor();
+ bool ret = screen_->FitCursor(bv_->text);
if (ret) updateScrollbar();
return ret;
}
bv_->text->selection = false;
}
}
- screen_->first = screen_->TopCursorVisible(); /* this will scroll the
- * screen such that the
- * cursor becomes
- * visible */
+ screen_->first = screen_->TopCursorVisible(bv_->text);
+ /* this will scroll the
+ * screen such that the
+ * cursor becomes
+ * visible */
updateScrollbar();
redraw();
owner_->getMiniBuffer()->Init();
{
// Regenerate the screen.
delete screen_;
- screen_ = new LyXScreen(*workarea_, bv_->text);
+ screen_ = new LyXScreen(*workarea_); //, bv_->text);
}
if (!screen_)
return;
- screen_->Draw(current_scrollbar_value);
+ screen_->Draw(bv_->text, current_scrollbar_value);
if (cursor_follows_scrollbar) {
LyXText * vbt = bv_->text;
update(BufferView::UPDATE); // Maybe an empty line was deleted
bv_->text->SetSelection();
- screen_->ToggleToggle();
+ screen_->ToggleToggle(bv_->text);
fitCursor();
- screen_->ShowCursor();
+ screen_->ShowCursor(bv_->text);
}
return;
}
// Hit above or below the table?
if (doit) {
if (!bv_->text->selection) {
- screen_->ToggleSelection();
+ screen_->ToggleSelection(bv_->text);
bv_->text->ClearSelection();
bv_->text->FullRebreak(bv_);
- screen_->Update();
+ screen_->Update(bv_->text);
updateScrollbar();
}
// Popup table popup when on a table.
}
// Clear the selection
- screen_->ToggleSelection();
+ screen_->ToggleSelection(bv_->text);
bv_->text->ClearSelection();
bv_->text->FullRebreak(bv_);
- screen_->Update();
+ screen_->Update(bv_->text);
updateScrollbar();
// Single left click in math inset?
if (buffer_ && !bv_->the_locking_inset) {
if (screen_ && button == 1) {
screen_->HideCursor();
- screen_->ToggleSelection();
+ screen_->ToggleSelection(bv_->text);
bv_->text->SelectWord(bv_);
- screen_->ToggleSelection(false);
+ screen_->ToggleSelection(bv_->text, false);
/* This will fit the cursor on the screen
* if necessary */
update(BufferView::SELECT|BufferView::FITCUR);
// select a line
if (buffer_ && screen_ && button == 1) {
screen_->HideCursor();
- screen_->ToggleSelection();
+ screen_->ToggleSelection(bv_->text);
bv_->text->CursorHome(bv_);
bv_->text->sel_cursor = bv_->text->cursor;
bv_->text->CursorEnd(bv_);
bv_->text->SetSelection();
- screen_->ToggleSelection(false);
+ screen_->ToggleSelection(bv_->text, false);
/* This will fit the cursor on the screen
* if necessary */
update(BufferView::SELECT|BufferView::FITCUR);
// ...including the minibuffer
owner_->getMiniBuffer()->Init();
- } else if (screen_) screen_->Redraw();
+ } else if (screen_) screen_->Redraw(bv_->text);
} else {
// Grey box when we don't have a buffer
workarea_->greyOut();
void BufferView::Pimpl::update()
{
- if (screen_) screen_->Update();
+ if (screen_) screen_->Update(bv_->text);
}
// Values used when calling update:
if (lyx_focus && work_area_focus) {
if (!bv_->the_locking_inset) {
- screen_->CursorToggle();
+ screen_->CursorToggle(bv_->text);
} else {
bv_->the_locking_inset->
ToggleInsetCursor(bv_);
} else {
// Make sure that the cursor is visible.
if (!bv_->the_locking_inset) {
- screen_->ShowCursor();
+ screen_->ShowCursor(bv_->text);
} else {
if (!bv_->the_locking_inset->isCursorVisible())
bv_->the_locking_inset->
bv_->text->CursorUp(bv_);
if (bv_->text->cursor.row()->height() < workarea_->height())
- screen_->Draw(bv_->text->cursor.y()
- - bv_->text->cursor.row()->baseline()
- + bv_->text->cursor.row()->height()
- - workarea_->height() + 1 );
+ screen_->Draw(bv_->text,
+ bv_->text->cursor.y()
+ - bv_->text->cursor.row()->baseline()
+ + bv_->text->cursor.row()->height()
+ - workarea_->height() + 1 );
updateScrollbar();
}
bv_->text->CursorDown(bv_);
if (bv_->text->cursor.row()->height() < workarea_->height())
- screen_->Draw(bv_->text->cursor.y()
+ screen_->Draw(bv_->text, bv_->text->cursor.y()
- bv_->text->cursor.row()->baseline());
updateScrollbar();
}
void BufferView::Pimpl::showCursor()
{
if (screen_)
- screen_->ShowCursor();
+ screen_->ShowCursor(bv_->text);
}
void BufferView::Pimpl::toggleSelection(bool b)
{
if (screen_)
- screen_->ToggleSelection(b);
+ screen_->ToggleSelection(bv_->text, b);
}
void BufferView::Pimpl::toggleToggle()
{
if (screen_)
- screen_->ToggleToggle();
+ screen_->ToggleToggle(bv_->text);
}
{
beforeChange();
if (bv_->text->cursor.y() > workarea_->height() / 2) {
- screen_->Draw(bv_->text->cursor.y() - workarea_->height() / 2);
+ screen_->Draw(bv_->text, bv_->text->cursor.y() - workarea_->height() / 2);
} else {
- screen_->Draw(0);
+ screen_->Draw(bv_->text, 0);
}
update(BufferView::SELECT|BufferView::FITCUR);
redraw();
};
///
- LyXScreen(WorkArea &, LyXText * text_ptr);
+ LyXScreen(WorkArea &); //, LyXText * text_ptr);
/** Draws the screen form textposition y. Uses as much of
the already printed pixmap as possible */
- void Draw(unsigned long y );
+ void Draw(LyXText *, unsigned long y);
/// Redraws the screen, without using existing pixmap
- void Redraw();
+ void Redraw(LyXText *);
/// Returns a new top so that the cursor is visible
- unsigned long TopCursorVisible();
+ unsigned long TopCursorVisible(LyXText const *);
/// Redraws the screen such that the cursor is visible
- bool FitCursor();
+ bool FitCursor(LyXText *);
///
- void ShowCursor();
+ void ShowCursor(LyXText const *);
///
void HideCursor();
///
- void CursorToggle();
+ void CursorToggle(LyXText const *);
///
void ShowManualCursor(long x, long y, int asc, int desc,
Cursor_Shape shape);
/// returns 1 if first has changed, otherwise 0
- bool FitManualCursor(long, long, int, int);
+ bool FitManualCursor(LyXText *, long, long, int, int);
///
- void ToggleSelection(bool = true);
+ void ToggleSelection(LyXText *, bool = true);
///
- void ToggleToggle();
+ void ToggleToggle(LyXText *);
/** Updates part of the screen. If text->status is
LyXText::NEED_MORE_REFRESH, we update from the
point of change and to the end of the screen.
If text->status is LyXText::NEED_VERY_LITTLE_REFRESH,
we only update the current row. */
- void Update();
+ void Update(LyXText *);
/// first visible pixel-row
unsigned long first;
void expose(int x, int y, int exp_width, int exp_height);
/// y1 and y2 are coordinates of the screen
- void DrawFromTo(int y1, int y2);
+ void DrawFromTo(LyXText *, int y1, int y2);
/// y is a coordinate of the text
- void DrawOneRow(Row * row, long y_text);
+ void DrawOneRow(LyXText *, Row * row, long y_text);
///
WorkArea & owner;
///
- LyXText * text;
+ //LyXText * text;
///
Pixmap cursor_pixmap;
// Constructor
-LyXScreen::LyXScreen(WorkArea & o, LyXText * text_ptr)
- : owner(o), text(text_ptr)
+LyXScreen::LyXScreen(WorkArea & o) //, LyXText * text_ptr)
+ : owner(o) //, text(text_ptr)
{
first = 0;
}
-void LyXScreen::Redraw()
+void LyXScreen::Redraw(LyXText * text)
{
- DrawFromTo(0, owner.height());
+ DrawFromTo(text, 0, owner.height());
expose(0, 0, owner.workWidth(), owner.height());
if (cursor_visible) {
cursor_visible = false;
- ShowCursor();
+ ShowCursor(text);
}
}
}
-void LyXScreen::DrawFromTo(int y1, int y2)
+void LyXScreen::DrawFromTo(LyXText * text, int y1, int y2)
{
long y_text = first + y1;
}
-void LyXScreen::DrawOneRow(Row * row, long y_text)
+void LyXScreen::DrawOneRow(LyXText * text, Row * row, long y_text)
{
long y = y_text - first;
/* draws the screen, starting with textposition y. uses as much already
* printed pixels as possible */
-void LyXScreen::Draw(unsigned long y)
+void LyXScreen::Draw(LyXText * text, unsigned long y)
{
if (cursor_visible) HideCursor();
if ((y - old_first) < owner.height()
&& (old_first - y) < owner.height()) {
if (first < old_first) {
- DrawFromTo(0, old_first - first);
+ DrawFromTo(text, 0, old_first - first);
XCopyArea (fl_display,
owner.getWin(),
owner.getWin(),
owner.workWidth(),
old_first - first);
} else {
- DrawFromTo(
- owner.height() + old_first - first,
+ DrawFromTo(text,
+ owner.height() + old_first - first,
owner.height());
XCopyArea (fl_display,
owner.getWin(),
}
} else {
// make a dumb new-draw
- DrawFromTo(0, owner.height());
+ DrawFromTo(text, 0, owner.height());
expose(0, 0, owner.workWidth(), owner.height());
}
}
-void LyXScreen::ShowCursor()
+void LyXScreen::ShowCursor(LyXText const * text)
{
if (!cursor_visible) {
Cursor_Shape shape = BAR_SHAPE;
/* returns true if first has changed, otherwise false */
-bool LyXScreen::FitManualCursor(long /*x*/, long y, int asc, int desc)
+bool LyXScreen::FitManualCursor(LyXText * text,
+ long /*x*/, long y, int asc, int desc)
{
long newtop = first;
newtop = max(newtop, 0L); // can newtop ever be < 0? (Lgb)
if (newtop != long(first)) {
- Draw(newtop);
+ Draw(text, newtop);
first = newtop;
return true;
}
}
-void LyXScreen::CursorToggle()
+void LyXScreen::CursorToggle(LyXText const * text)
{
if (cursor_visible)
HideCursor();
else
- ShowCursor();
+ ShowCursor(text);
}
/* returns a new top so that the cursor is visible */
-unsigned long LyXScreen::TopCursorVisible()
+unsigned long LyXScreen::TopCursorVisible(LyXText const * text)
{
long newtop = first;
/* scrolls the screen so that the cursor is visible, if necessary.
* returns true if a change was made, otherwise false */
-bool LyXScreen::FitCursor()
+bool LyXScreen::FitCursor(LyXText * text)
{
// Is a change necessary?
- unsigned long newtop = TopCursorVisible();
+ unsigned long newtop = TopCursorVisible(text);
bool result = (newtop != first);
if (result)
- Draw(newtop);
+ Draw(text, newtop);
return result;
}
-void LyXScreen::Update()
+void LyXScreen::Update(LyXText * text)
{
switch(text->status) {
case LyXText::NEED_MORE_REFRESH:
{
long y = max(text->refresh_y - long(first), 0L);
- DrawFromTo(y, owner.height());
+ DrawFromTo(text, y, owner.height());
text->refresh_y = 0;
text->status = LyXText::UNCHANGED;
expose(0, y,
case LyXText::NEED_VERY_LITTLE_REFRESH:
{
// ok I will update the current cursor row
- DrawOneRow(text->refresh_row, text->refresh_y);
+ DrawOneRow(text, text->refresh_row, text->refresh_y);
text->status = LyXText::UNCHANGED;
expose(0, text->refresh_y - first,
owner.workWidth(), text->refresh_row->height());
}
-void LyXScreen::ToggleSelection(bool kill_selection)
+void LyXScreen::ToggleSelection(LyXText * text, bool kill_selection)
{
// only if there is a selection
if (!text->selection) return;
if (kill_selection)
text->selection = 0;
- DrawFromTo(top - first, bottom - first);
+ DrawFromTo(text, top - first, bottom - first);
expose(0, top - first,
owner.workWidth(),
bottom - first - (top - first));
}
-void LyXScreen::ToggleToggle()
+void LyXScreen::ToggleToggle(LyXText * text)
{
if (text->toggle_cursor.par() == text->toggle_end_cursor.par()
&& text->toggle_cursor.pos() == text->toggle_end_cursor.pos())
bottom = min(max(ulong(bottom), first), first + owner.height());
top = min(max(ulong(top), first), first + owner.height());
- DrawFromTo(top - first, bottom - first);
+ DrawFromTo(text, top - first, bottom - first);
expose(0, top - first, owner.workWidth(),
bottom - first - (top - first));
}