X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferView_pimpl.C;h=5b41de1b1e806d0e0f6edd6d98c72e69c91aad2a;hb=27290f151b160dd4763a41976af3451755cd03cf;hp=c1c04f4c1ecd5cf9865d8f644f5bb8eaf1daeff7;hpb=2fbc66100c01461e32d7c79500ac8b9db993a7b0;p=lyx.git diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index c1c04f4c1e..5b41de1b1e 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -176,7 +176,9 @@ void BufferView::Pimpl::buffer(Buffer * b) lyxerr[Debug::INFO] << "Setting buffer in BufferView (" << b << ")" << endl; if (buffer_) { +#if 0 insetSleep(); +#endif buffer_->delUser(bv_); // Put the old text into the TextCache, but @@ -222,7 +224,9 @@ void BufferView::Pimpl::buffer(Buffer * b) // require bv_->text. owner_->getDialogs()->updateBufferDependent(true); redraw(); +#if 0 insetWakeup(); +#endif } else { lyxerr[Debug::INFO] << " No Buffer!" << endl; owner_->updateMenubar(); @@ -326,10 +330,12 @@ int BufferView::Pimpl::resizeCurrentBuffer() selection = bv_->text->selection.set(); mark_set = bv_->text->selection.mark(); the_locking_inset = bv_->theLockingInset(); + buffer_->resizeInsets(bv_); + // I don't think the delete and new are necessary here we just could + // call only init! (Jug 20020419) delete bv_->text; bv_->text = new LyXText(bv_); bv_->text->init(bv_); - buffer_->resizeInsets(bv_); } else { // See if we have a text in TextCache that fits // the new buffer_ with the correct width. @@ -470,19 +476,24 @@ void BufferView::Pimpl::scrollCB(double value) int BufferView::Pimpl::scrollUp(long time) { - if (!buffer_) return 0; - if (!screen_.get()) return 0; + if (!buffer_ || !screen_.get()) + return 0; double value = workarea_.getScrollbarValue(); - if (value == 0) return 0; + if (value == 0) + return 0; +#if 1 float add_value = (bv_->text->defaultHeight() + float(time) * float(time) * 0.125); if (add_value > workarea_.height()) add_value = float(workarea_.height() - bv_->text->defaultHeight()); +#else + float add_value = float(workarea_.height()) * float(time) / 100; +#endif value -= add_value; @@ -498,21 +509,26 @@ int BufferView::Pimpl::scrollUp(long time) int BufferView::Pimpl::scrollDown(long time) { - if (!buffer_) return 0; - if (!screen_.get()) return 0; + if (!buffer_ || !screen_.get()) + return 0; double value = workarea_.getScrollbarValue(); pair p = workarea_.getScrollbarBounds(); double const max = p.second; - if (value == max) return 0; + if (value == max) + return 0; +#if 1 float add_value = (bv_->text->defaultHeight() + float(time) * float(time) * 0.125); if (add_value > workarea_.height()) add_value = float(workarea_.height() - bv_->text->defaultHeight()); +#else + float add_value = float(workarea_.height()) * float(time) / 100; +#endif value += add_value; @@ -603,9 +619,8 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, if (!buffer_ || !screen_.get()) return; - Inset * inset_hit = checkInsetHit(bv_->text, xpos, ypos); - // ok ok, this is a hack. + // Why??? (Jug20020424) if (button == 4 || button == 5) { switch (button) { case 4: @@ -615,8 +630,14 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, scrollDown(lyxrc.wheel_jump); break; } + // We shouldn't go further down as we really should only do the + // scrolling and be done with this. Otherwise we may open some + // dialogs (Jug 20020424). + return; } + Inset * inset_hit = checkInsetHit(bv_->text, xpos, ypos); + // Middle button press pastes if we have a selection // We do this here as if the selection was inside an inset // it could get cleared on the unlocking of the inset so @@ -820,7 +841,9 @@ void BufferView::Pimpl::leaveView() void BufferView::Pimpl::workAreaButtonRelease(int x, int y, unsigned int button) { - if (!buffer_ || !screen_.get()) return; + // do nothing if we used the mouse wheel + if (!buffer_ || !screen_.get() || button == 4 || button == 5) + return; // If we hit an inset, we have the inset coordinates in these // and inset_hit points to the inset. If we do not hit an @@ -1069,12 +1092,19 @@ void BufferView::Pimpl::update() screen_->update(bv_->text, bv_); bool fitc = false; while (bv_->text->status() == LyXText::CHANGED_IN_DRAW) { - if (bv_->text->fullRebreak(bv_)) { - st = LyXText::NEED_MORE_REFRESH; - bv_->text->setCursor(bv_, bv_->text->cursor.par(), - bv_->text->cursor.pos()); - fitc = true; + bv_->text->fullRebreak(bv_); + st = LyXText::NEED_MORE_REFRESH; + bv_->text->setCursor(bv_, bv_->text->cursor.par(), + bv_->text->cursor.pos()); + if (bv_->text->selection.set()) { + bv_->text->setCursor(bv_, bv_->text->selection.start, + bv_->text->selection.start.par(), + bv_->text->selection.start.pos()); + bv_->text->setCursor(bv_, bv_->text->selection.end, + bv_->text->selection.end.par(), + bv_->text->selection.end.pos()); } + fitc = true; bv_->text->status(bv_, st); screen_->update(bv_->text, bv_); } @@ -1261,7 +1291,7 @@ void BufferView::Pimpl::cursorNext(LyXText * text) // span several workarea-heights) we'll move to the top again, but this // is better than just jump down and only display part of the row. new_y = bv_->text->first_y + workarea_.height(); - } else { + } else { if (text->inset_owner) { new_y = bv_->text->cursor.iy() + bv_->theLockingInset()->insetInInsetY() @@ -1370,6 +1400,7 @@ void BufferView::Pimpl::setState() } +#if 0 void BufferView::Pimpl::insetSleep() { if (bv_->theLockingInset() && !inset_slept) { @@ -1387,6 +1418,7 @@ void BufferView::Pimpl::insetWakeup() inset_slept = false; } } +#endif void BufferView::Pimpl::insetUnlock() @@ -1622,6 +1654,8 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) lyxerr[Debug::ACTION] << "BufferView::Pimpl::Dispatch: action[" << action <<"] arg[" << argument << "]" << endl; + LyXTextClass const & tclass = textclasslist[buffer_->params.textclass]; + switch (action) { // --- Misc ------------------------------------------- case LFUN_APPENDIX: @@ -1642,7 +1676,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) InsetCommandParams p; p.setCmdName("tableofcontents"); Inset * inset = new InsetTOC(p); - if (!insertInset(inset, "Standard")) + if (!insertInset(inset, tclass.defaultLayoutName())) delete inset; break; } @@ -1769,15 +1803,12 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) // Derive layout number from given argument (string) // and current buffer's textclass (number). */ - textclass_type tclass = buffer_->params.textclass; - bool hasLayout = - textclasslist[tclass].hasLayout(argument); + bool hasLayout = tclass.hasLayout(argument); string layout = argument; // If the entry is obsolete, use the new one instead. if (hasLayout) { - string const & obs = textclasslist[tclass][layout] - .obsoleted_by(); + string const & obs = tclass[layout].obsoleted_by(); if (!obs.empty()) layout = obs; } @@ -1789,8 +1820,21 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) break; } - if (current_layout != layout) { - LyXText * lt = bv_->getLyXText(); + bool change_layout = (current_layout != layout); + LyXText * lt = bv_->getLyXText(); + if (!change_layout && lt->selection.set() && + lt->selection.start.par() != lt->selection.end.par()) + { + Paragraph * spar = lt->selection.start.par(); + Paragraph * epar = lt->selection.end.par()->next(); + while(spar != epar) { + if (spar->layout() != current_layout) { + change_layout = true; + break; + } + } + } + if (change_layout) { hideCursor(); current_layout = layout; update(lt, @@ -2442,7 +2486,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) { LyXText * lt = bv_->getLyXText(); - LyXLayout const & style = textclasslist[buffer_->params.textclass][lt->cursor.par()->layout()]; + LyXLayout const & style = tclass[lt->cursor.par()->layout()]; if (style.free_spacing) { lt->insertChar(bv_, ' '); @@ -2882,23 +2926,17 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) break; case LFUN_INSET_WIDE_FLOAT: - { // check if the float type exist if (floatList.typeExist(argument)) { InsetFloat * new_inset = new InsetFloat(buffer_->params, argument); new_inset->wide(true); - if (insertInset(new_inset)) - new_inset->edit(bv_); - else - delete new_inset; + insertAndEditInset(new_inset); } else { lyxerr << "Non-existent float type: " << argument << endl; } - - } - break; + break; #if 0 case LFUN_INSET_LIST: @@ -3169,7 +3207,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) { InsetCommandParams p("printindex"); Inset * inset = new InsetPrintIndex(p); - if (!insertInset(inset, "Standard")) + if (!insertInset(inset, tclass.defaultLayoutName())) delete inset; } break; @@ -3178,7 +3216,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) { InsetCommandParams p("lyxparent", argument); Inset * inset = new InsetParent(p, *buffer_); - if (!insertInset(inset, "Standard")) + if (!insertInset(inset, tclass.defaultLayoutName())) delete inset; } @@ -3201,13 +3239,15 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) break; case LFUN_FLOAT_LIST: - { - // We should check the argument for validity. (Lgb) - Inset * inset = new InsetFloatList(argument); - if (!insertInset(inset, "Standard")) - delete inset; - } - break; + if (floatList.typeExist(argument)) { + Inset * inset = new InsetFloatList(argument); + if (!insertInset(inset, tclass.defaultLayoutName())) + delete inset; + } else { + lyxerr << "Non-existent float type: " + << argument << endl; + } + break; case LFUN_THESAURUS_ENTRY: {