From: Jean-Marc Lasgouttes Date: Mon, 25 Mar 2002 17:00:04 +0000 (+0000) Subject: fix to #241 and #300 from John X-Git-Tag: 1.6.10~19574 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=34046e3c4df63b34bd75d5bca09ee3809815b7fc;p=lyx.git fix to #241 and #300 from John git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3827 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 05c59edf11..18c7167bd9 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -397,10 +397,8 @@ void BufferView::Pimpl::updateScreen() void BufferView::Pimpl::updateScrollbar() { - /* If the text is smaller than the working area, the scrollbar - * maximum must be the working area height. No scrolling will - * be possible */ if (!bv_->text) { + lyxerr[Debug::GUI] << "no text in updateScrollbar" << endl; workarea_.setScrollbar(0, 1.0); return; } @@ -408,42 +406,36 @@ void BufferView::Pimpl::updateScrollbar() long const text_height = bv_->text->height; long const work_height = workarea_.height(); + double const lineh = bv_->text->defaultHeight(); + double const slider_size = + (text_height == 0) ? 1.0 : 1.0 / double(text_height); + + lyxerr[Debug::GUI] << "text_height now " << text_height << endl; + lyxerr[Debug::GUI] << "work_height " << work_height << endl; + + /* If the text is smaller than the working area, the scrollbar + * maximum must be the working area height. No scrolling will + * be possible */ if (text_height <= work_height) { + lyxerr[Debug::GUI] << "doc smaller than workarea !" << endl; workarea_.setScrollbarBounds(0.0, 0.0); current_scrollbar_value = bv_->text->first_y; workarea_.setScrollbar(current_scrollbar_value, 1.0); return; } - double const lineh = bv_->text->defaultHeight(); - double const slider_size = - (text_height == 0) ? 1.0 : 1.0 / double(text_height); - - static long old_text_height; - static double old_lineh; - static double old_slider_size; - - if (text_height != old_text_height) { - workarea_.setScrollbarBounds(0.0, - text_height - work_height); - old_text_height = text_height; - } - if (lineh != old_lineh) { - workarea_.setScrollbarIncrements(lineh); - old_lineh = lineh; - } - if (current_scrollbar_value != bv_->text->first_y - || slider_size != old_slider_size) { - current_scrollbar_value = bv_->text->first_y; - workarea_.setScrollbar(current_scrollbar_value, slider_size); - old_slider_size = slider_size; - } + workarea_.setScrollbarBounds(0.0, text_height - work_height); + workarea_.setScrollbarIncrements(lineh); + current_scrollbar_value = bv_->text->first_y; + workarea_.setScrollbar(current_scrollbar_value, slider_size); } // Callback for scrollbar slider void BufferView::Pimpl::scrollCB(double value) { + lyxerr[Debug::GUI] << "scrollCB of " << value << endl; + if (!buffer_) return; current_scrollbar_value = long(value); diff --git a/src/ChangeLog b/src/ChangeLog index 0aa02389ce..4b19ac89aa 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,7 +1,17 @@ +2002-03-25 John Levon + + * BufferView_pimpl.C (updateScrollbar): update on buffer switch + properly + +2002-03-19 John Levon + + * CutAndPaste.C: change layouts earlier on paste + to avoid crashing when calling getFont() + 2002-03-22 Angus Leeming - * PrinterParams.h: #include "lyxrc.h" and remove that bloody irritating - #error. + * PrinterParams.h: #include "lyxrc.h" and remove that bloody + irritating #error. 2002-03-21 Lars Gullik Bjønnes diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index c6eec1d8b6..d5306afd31 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -283,7 +283,13 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar, // temporary set *par as previous of tmpbuf as we might have to realize // the font. tmpbuf->previous(*par); + + // make sure there is no class difference + SwitchLayoutsBetweenClasses(textclass, tc, tmpbuf, + current_view->buffer()->params); + Paragraph::depth_type max_depth = (*par)->getMaxDepthAfter(current_view->buffer()); + while(tmpbuf) { // if we have a negative jump so that the depth would go below // 0 depth then we have to redo the delta to this new max depth @@ -322,10 +328,6 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar, // now reset it to 0 buf->previous(0); - // make sure there is no class difference - SwitchLayoutsBetweenClasses(textclass, tc, buf, - current_view->buffer()->params); - // make the buf exactly the same layout than // the cursor paragraph buf->makeSameLayout(*par);