]> git.lyx.org Git - features.git/commitdiff
pass LyXText as agument to LyXScreen instead of storing a pointer
authorLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 20 Jun 2000 13:49:07 +0000 (13:49 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 20 Jun 2000 13:49:07 +0000 (13:49 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@824 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
src/BufferView2.C
src/BufferView_pimpl.C
src/lyxscreen.h
src/screen.C

index 3283844f92231187e8e633f821d19184fafb9fcd..d6ed026a4ebf829e20d2932cd5a56b89351f79df 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+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
index ecc4c117188ffafbc2d4be73f239ed7803761a13..da743e0753e6d86fe7587ea9e0823a41735b2163 100644 (file)
@@ -763,7 +763,7 @@ void BufferView::fitLockedInsetCursor(long x, long y, int asc, int desc)
 {
        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();
        }
 }
index 7ec6c4902e4f6973f8e8051aba4910fc061b5dca..1229b15e022053f74dce176670a5084f36a8a5e4 100644 (file)
@@ -135,7 +135,7 @@ void BufferView::Pimpl::buffer(Buffer * b)
                        updateScreen();
                        updateScrollbar();
                }
-               screen_->first = screen_->TopCursorVisible();
+               screen_->first = screen_->TopCursorVisible(bv_->text);
                redraw();
                owner_->getDialogs()->updateBufferDependent();
                bv_->insetWakeup();
@@ -186,7 +186,7 @@ bool BufferView::Pimpl::fitCursor()
 {
        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;
 }
@@ -266,10 +266,11 @@ int BufferView::Pimpl::resizeCurrentBuffer()
                        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();
@@ -319,7 +320,7 @@ void BufferView::Pimpl::updateScreen()
 {
        // Regenerate the screen.
        delete screen_;
-       screen_ = new LyXScreen(*workarea_, bv_->text);
+       screen_ = new LyXScreen(*workarea_); //, bv_->text);
 }
 
 
@@ -398,7 +399,7 @@ void BufferView::Pimpl::scrollCB(double value)
        if (!screen_)
                return;
 
-       screen_->Draw(current_scrollbar_value);
+       screen_->Draw(bv_->text, current_scrollbar_value);
 
        if (cursor_follows_scrollbar) {
                LyXText * vbt = bv_->text;
@@ -508,9 +509,9 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
                        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;
 }
@@ -577,10 +578,10 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
                // 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.
@@ -609,10 +610,10 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
        }
        
        // 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?
@@ -666,9 +667,9 @@ void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, unsigned int button)
        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);
@@ -682,12 +683,12 @@ void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, unsigned int button)
        // 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);
@@ -999,7 +1000,7 @@ void BufferView::Pimpl::workAreaExpose()
                        // ...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();
@@ -1014,7 +1015,7 @@ void BufferView::Pimpl::workAreaExpose()
 
 void BufferView::Pimpl::update()
 {
-       if (screen_) screen_->Update();
+       if (screen_) screen_->Update(bv_->text);
 }
 
 // Values used when calling update:
@@ -1137,7 +1138,7 @@ void BufferView::Pimpl::cursorToggle()
 
        if (lyx_focus && work_area_focus) {
                if (!bv_->the_locking_inset) {
-                       screen_->CursorToggle();
+                       screen_->CursorToggle(bv_->text);
                } else {
                        bv_->the_locking_inset->
                                ToggleInsetCursor(bv_);
@@ -1146,7 +1147,7 @@ void BufferView::Pimpl::cursorToggle()
        } 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->
@@ -1199,10 +1200,11 @@ void BufferView::Pimpl::cursorPrevious()
                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();
 }
 
@@ -1222,7 +1224,7 @@ void BufferView::Pimpl::cursorNext()
                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();
 }
@@ -1348,7 +1350,7 @@ bool BufferView::Pimpl::belowMouse() const
 void BufferView::Pimpl::showCursor()
 {
        if (screen_)
-               screen_->ShowCursor();
+               screen_->ShowCursor(bv_->text);
 }
 
 
@@ -1362,14 +1364,14 @@ void BufferView::Pimpl::hideCursor()
 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);
 }
 
 
@@ -1377,9 +1379,9 @@ void BufferView::Pimpl::center()
 {
        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();
index f70254e24f047c2d93ec60c69e32c0fef05b0cc9..c63337d2592a640d833aa8e81bc2688de9ed5299 100644 (file)
@@ -44,41 +44,41 @@ public:
        };
 
        ///
-       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;
@@ -90,16 +90,16 @@ private:
        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;
index 16b64314e270135cab42841a2db5ed0c20261fb8..efb13aafa787fc89db1dd3decbddc123cd539117 100644 (file)
@@ -45,8 +45,8 @@ GC createGC()
 
 
 // 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;
    
@@ -63,13 +63,13 @@ LyXScreen::LyXScreen(WorkArea & o, LyXText * text_ptr)
 }
 
 
-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);
        }
 }
 
@@ -87,7 +87,7 @@ void LyXScreen::expose(int x, int y, int exp_width, int exp_height)
 }
 
 
-void LyXScreen::DrawFromTo(int y1, int y2)
+void LyXScreen::DrawFromTo(LyXText * text, int y1, int y2)
 {
        long y_text = first + y1;
    
@@ -114,7 +114,7 @@ void LyXScreen::DrawFromTo(int y1, int y2)
 }
 
 
-void LyXScreen::DrawOneRow(Row * row, long y_text)
+void LyXScreen::DrawOneRow(LyXText * text, Row * row, long y_text)
 {
        long y = y_text - first;
       
@@ -128,7 +128,7 @@ void LyXScreen::DrawOneRow(Row * row, long y_text)
 
 /* 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();
 
@@ -139,7 +139,7 @@ void LyXScreen::Draw(unsigned long y)
        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(),
@@ -156,8 +156,8 @@ void LyXScreen::Draw(unsigned long y)
                               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(),
@@ -175,13 +175,13 @@ void LyXScreen::Draw(unsigned long y)
                }
        } 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;
@@ -200,7 +200,8 @@ void LyXScreen::ShowCursor()
 
 
 /* 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;
   
@@ -214,7 +215,7 @@ bool LyXScreen::FitManualCursor(long /*x*/, long y, int asc, int desc)
        newtop = max(newtop, 0L); // can newtop ever be < 0? (Lgb)
   
        if (newtop != long(first)) {
-               Draw(newtop);
+               Draw(text, newtop);
                first = newtop;
                return true;
        }
@@ -317,17 +318,17 @@ void LyXScreen::HideCursor()
 }
 
 
-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;
 
@@ -362,25 +363,25 @@ unsigned long LyXScreen::TopCursorVisible()
 
 /* 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,
@@ -390,7 +391,7 @@ void LyXScreen::Update()
        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());
@@ -403,7 +404,7 @@ void LyXScreen::Update()
 }
 
 
-void LyXScreen::ToggleSelection(bool kill_selection)
+void LyXScreen::ToggleSelection(LyXText * text, bool kill_selection)
 {
        // only if there is a selection
        if (!text->selection) return;
@@ -418,14 +419,14 @@ void LyXScreen::ToggleSelection(bool kill_selection)
 
        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())
@@ -442,7 +443,7 @@ void LyXScreen::ToggleToggle()
        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));
 }