X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftext2.C;h=426cb90be03222c7d00131b5bbe8c411d4429b8f;hb=5c00d0f48978964a576070d5950556787aa365bb;hp=f1725de2a1247523a55eb9cadd58f4ba95ed110c;hpb=303a6c126c3b00a831053897cba7a18615ef60eb;p=lyx.git diff --git a/src/text2.C b/src/text2.C index f1725de2a1..426cb90be0 100644 --- a/src/text2.C +++ b/src/text2.C @@ -110,7 +110,9 @@ LyXFont LyXText::getFont(par_type pit, pos_type pos) const BOOST_ASSERT(pos >= 0); LyXLayout_ptr const & layout = pars_[pit].layout(); +#ifdef WITH_WARNINGS #warning broken? +#endif BufferParams const & params = bv()->buffer()->params(); pos_type const body_pos = pars_[pit].beginOfBody(); @@ -278,18 +280,19 @@ void LyXText::setLayout(LCursor & cur, string const & layout) { BOOST_ASSERT(this == cur.text()); // special handling of new environment insets - BufferParams const & params = bv()->buffer()->params(); + BufferView & bv = cur.bv(); + BufferParams const & params = bv.buffer()->params(); LyXLayout_ptr const & lyxlayout = params.getLyXTextClass()[layout]; if (lyxlayout->is_environment) { // move everything in a new environment inset lyxerr << "setting layout " << layout << endl; - bv()->owner()->dispatch(FuncRequest(LFUN_HOME)); - bv()->owner()->dispatch(FuncRequest(LFUN_ENDSEL)); - bv()->owner()->dispatch(FuncRequest(LFUN_CUT)); + bv.owner()->dispatch(FuncRequest(LFUN_HOME)); + bv.owner()->dispatch(FuncRequest(LFUN_ENDSEL)); + bv.owner()->dispatch(FuncRequest(LFUN_CUT)); InsetBase * inset = new InsetEnvironment(params, layout); insertInset(cur, inset); //inset->edit(cur, true); - //bv()->owner()->dispatch(FuncRequest(LFUN_PASTE)); + //bv.owner()->dispatch(FuncRequest(LFUN_PASTE)); return; } @@ -336,7 +339,7 @@ bool changeDepthAllowed(LyXText::DEPTH_CHANGE type, bool LyXText::changeDepthAllowed(LCursor & cur, DEPTH_CHANGE type) const { BOOST_ASSERT(this == cur.text()); - par_type beg, end; + par_type beg, end; getSelectionSpan(cur, beg, end); int max_depth = 0; if (beg != 0) @@ -394,7 +397,7 @@ void LyXText::setFont(LCursor & cur, LyXFont const & font, bool toggleall) // Update current font real_current_font.update(font, - bv()->buffer()->params().language, + cur.buffer().params().language, toggleall); // Reduce to implicit settings @@ -412,17 +415,23 @@ void LyXText::setFont(LCursor & cur, LyXFont const & font, bool toggleall) par_type const beg = cur.selBegin().par(); par_type const end = cur.selEnd().par(); - DocIterator pos = cur.selectionBegin(); - DocIterator posend = cur.selectionEnd(); + DocIterator pos = cur.selectionBegin(); + DocIterator posend = cur.selectionEnd(); - BufferParams const & params = bv()->buffer()->params(); + lyxerr << "pos: " << pos << " posend: " << posend << endl; + + BufferParams const & params = cur.buffer().params(); - for (; pos != posend; pos.forwardChar()) { - LyXFont f = getFont(pos.par(), pos.pos()); - f.update(font, params.language, toggleall); - setCharFont(pos.par(), pos.pos(), f); + // Don't use forwardChar here as posend might have + // pos() == lastpos() and forwardChar would miss it. + for (; pos != posend; pos.forwardPos()) { + if (pos.pos() != pos.lastpos()) { + LyXFont f = getFont(pos.par(), pos.pos()); + f.update(font, params.language, toggleall); + setCharFont(pos.par(), pos.pos(), f); + } } - + redoParagraphs(beg, end + 1); } @@ -767,10 +776,8 @@ void LyXText::setCounter(Buffer const & buf, par_type pit) par_type tmppit = pit; InsetBase * in = 0; bool isOK = false; - while (tmppit != end && pars_[tmppit].inInset() - // the single '=' is intended below - && (in = pars_[tmppit].inInset())) - { + while (tmppit != end) { + in = pars_[tmppit].inInset(); if (in->lyxCode() == InsetBase::FLOAT_CODE || in->lyxCode() == InsetBase::WRAP_CODE) { isOK = true; @@ -819,7 +826,7 @@ void LyXText::updateCounters() bv()->buffer()->params().getLyXTextClass().counters().reset(); bool update_pos = false; - + par_type end = paragraphs().size(); for (par_type pit = 0; pit != end; ++pit) { string const oldLabel = pars_[pit].params().labelString(); @@ -864,7 +871,7 @@ void LyXText::insertStringAsLines(LCursor & cur, string const & str) // only to be sure, should not be neccessary cur.clearSelection(); - bv()->buffer()->insertStringAsLines(pars_, pit, pos, current_font, str); + cur.buffer().insertStringAsLines(pars_, pit, pos, current_font, str); redoParagraphs(cur.par(), endpit); cur.resetAnchor(); @@ -949,7 +956,7 @@ void LyXText::setCursor(CursorSlice & cur, par_type par, // This shouldn't happen. BOOST_ASSERT(false); } - + if (pos < row.pos()) { lyxerr << "dont like 3 please report pos:" << pos << " size: " << para.size() @@ -993,12 +1000,12 @@ void LyXText::setCurrentFont(LCursor & cur) } } - BufferParams const & bufparams = bv()->buffer()->params(); + BufferParams const & bufparams = cur.buffer().params(); current_font = pars_[pit].getFontSettings(bufparams, pos); real_current_font = getFont(pit, pos); if (cur.pos() == cur.lastpos() - && bidi.isBoundary(*bv()->buffer(), pars_[pit], cur.pos()) + && bidi.isBoundary(cur.buffer(), pars_[pit], cur.pos()) && !cur.boundary()) { Language const * lang = pars_[pit].getParLanguage(bufparams); current_font.setLanguage(lang); @@ -1017,7 +1024,7 @@ pos_type LyXText::getColumnNearX(par_type pit, { x -= xo_; RowMetrics const r = computeRowMetrics(pit, row); - + pos_type vc = row.pos(); pos_type end = row.endpos(); pos_type c = 0; @@ -1141,6 +1148,7 @@ InsetBase * LyXText::editXY(LCursor & cur, int x, int y) // try to descend into nested insets InsetBase * inset = checkInsetHit(x, y); + lyxerr << "inset " << inset << " hit at x: " << x << " y: " << y << endl; if (!inset) return 0; @@ -1177,10 +1185,10 @@ void LyXText::cursorLeft(LCursor & cur) setCursor(cur, cur.par(), cur.pos() - 1, true, false); if (!checkAndActivateInset(cur, false)) { if (false && !boundary && - bidi.isBoundary(*bv()->buffer(), cur.paragraph(), cur.pos() + 1)) + bidi.isBoundary(cur.buffer(), cur.paragraph(), cur.pos() + 1)) setCursor(cur, cur.par(), cur.pos() + 1, true, true); - return; } + return; } if (cur.par() != 0) { @@ -1198,9 +1206,9 @@ void LyXText::cursorRight(LCursor & cur) } if (cur.pos() != cur.lastpos()) { - if (!checkAndActivateInset(cur, true)) { + if (!checkAndActivateInset(cur, true)) { setCursor(cur, cur.par(), cur.pos() + 1, true, false); - if (false && bidi.isBoundary(*bv()->buffer(), cur.paragraph(), + if (false && bidi.isBoundary(cur.buffer(), cur.paragraph(), cur.pos())) setCursor(cur, cur.par(), cur.pos(), true, true); } @@ -1334,7 +1342,8 @@ bool LyXText::deleteEmptyParagraphMechanism(LCursor & cur, LCursor const & old) #endif // correct all cursor parts fixCursorAfterDelete(cur.top(), old.top()); - fixCursorAfterDelete(cur.anchor(), old.top()); +#warning DEPM, look here + //fixCursorAfterDelete(cur.anchor(), old.top()); return false; } } @@ -1376,8 +1385,9 @@ bool LyXText::deleteEmptyParagraphMechanism(LCursor & cur, LCursor const & old) // such events. Maybe even signal/slot? if (cur.par() > old.par()) --cur.par(); - if (cur.anchor().par() > old.par()) - --cur.anchor().par(); +#warning DEPM, look here +// if (cur.anchor().par() > old.par()) +// --cur.anchor().par(); if (selection_position_was_oldcursor_position) { // correct selection