From: André Pönitz Date: Wed, 7 Apr 2004 13:15:34 +0000 (+0000) Subject: small stuff X-Git-Tag: 1.6.10~15344 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=7d4c0027d8d52642dec8b3fdb9699c0084b2df73;p=features.git small stuff git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8620 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/cursor.C b/src/cursor.C index 6e91d9d9c2..409c366a41 100644 --- a/src/cursor.C +++ b/src/cursor.C @@ -314,33 +314,19 @@ bool LCursor::posRight() } -CursorSlice & LCursor::anchor() +CursorSlice LCursor::anchor() const { - if (anchor_.size() < size()) { - lyxerr << "anchor_.size() < cursor_.size() " - "should not happen when accessing the anchor" << endl; - BOOST_ASSERT(false); - } - BOOST_ASSERT(!anchor_.empty()); - // this size is cursor_.size() - return anchor_[size() - 1]; -} - - -CursorSlice const & LCursor::anchor() const -{ - if (anchor_.size() < size()) { - lyxerr << "anchor_.size() < cursor_.size() " - "should not happen when accessing the anchor" << endl; - BOOST_ASSERT(false); + BOOST_ASSERT(anchor_.size() >= size()); + CursorSlice normal = anchor_[size() - 1]; + if (size() < anchor_.size() && back() <= normal) { + // anchor is behind cursor -> move anchor behind the inset + ++normal.pos(); } - // this size is cursor_.size() - BOOST_ASSERT(!anchor_.empty()); - return anchor_[size() - 1]; + return normal; } -CursorSlice const & LCursor::selBegin() const +CursorSlice LCursor::selBegin() const { if (!selection()) return back(); @@ -348,7 +334,7 @@ CursorSlice const & LCursor::selBegin() const } -CursorSlice const & LCursor::selEnd() const +CursorSlice LCursor::selEnd() const { if (!selection()) return back(); @@ -920,18 +906,6 @@ int LCursor::targetX() const } -void LCursor::adjust(pos_type from, int diff) -{ - if (pos() > from) - pos() += diff; - if (anchor().pos() > from) - anchor().pos() += diff; - // just to be on the safe side - // theoretically unecessary - normalize(); -} - - bool LCursor::inMacroMode() const { if (!pos() != 0) @@ -1160,25 +1134,6 @@ void LCursor::bruteFind2(int x, int y) } -CursorSlice LCursor::normalAnchor() -{ - if (anchor_.size() < depth()) { - resetAnchor(); - lyxerr << "unusual Anchor size" << endl; - } - //lyx::BOOST_ASSERT(Anchor_.size() >= cursor.depth()); - // use Anchor on the same level as Cursor - CursorSlice normal = anchor_[size() - 1]; -#if 0 - if (depth() < anchor_.size() && !(normal < xx())) { - // anchor is behind cursor -> move anchor behind the inset - ++normal.pos_; - } -#endif - return normal; -} - - void LCursor::handleFont(string const & font) { lyxerr << "LCursor::handleFont: " << font << endl; diff --git a/src/cursor.h b/src/cursor.h index d59e4312bb..c254f11659 100644 --- a/src/cursor.h +++ b/src/cursor.h @@ -72,9 +72,9 @@ public: /// void clearSelection(); /// access start of selection - CursorSlice const & selBegin() const; + CursorSlice selBegin() const; /// access end of selection - CursorSlice const & selEnd() const; + CursorSlice selEnd() const; /// access start of selection DocIterator selectionBegin() const; /// access start of selection @@ -140,10 +140,8 @@ public: /// clear target x position of cursor void clearTargetX(); - /// access to selection anchor - CursorSlice & anchor(); - /// access to selection anchor - CursorSlice const & anchor() const; + /// access to normalized selection anchor + CursorSlice anchor() const; /// cache the absolute coordinate from the top inset void updatePos(); /// sets anchor to cursor position @@ -245,8 +243,6 @@ public: void setScreenPos(int x, int y); /// in pixels from left of screen int targetX() const; - /// adjust anchor position after deletions/insertions - void adjust(pos_type from, int diff); /// current offset in the top cell /// interpret name a name of a macro void macroModeClose(); @@ -266,9 +262,6 @@ public: /// mark current cursor trace for redraw void touch(); - /// returns the normalized anchor of the selection - CursorSlice normalAnchor(); - /// hack for reveal codes void markInsert(); void markErase(); diff --git a/src/cursor_slice.C b/src/cursor_slice.C index 2f8bb87857..f891844e19 100644 --- a/src/cursor_slice.C +++ b/src/cursor_slice.C @@ -166,6 +166,12 @@ bool operator>(CursorSlice const & p, CursorSlice const & q) } +bool operator<=(CursorSlice const & p, CursorSlice const & q) +{ + return !(q < p); +} + + std::ostream & operator<<(std::ostream & os, CursorSlice const & item) { return os diff --git a/src/cursor_slice.h b/src/cursor_slice.h index f50820549a..230a9ad839 100644 --- a/src/cursor_slice.h +++ b/src/cursor_slice.h @@ -153,5 +153,7 @@ bool operator!=(CursorSlice const &, CursorSlice const &); bool operator<(CursorSlice const &, CursorSlice const &); /// test for order bool operator>(CursorSlice const &, CursorSlice const &); +/// test for order +bool operator<=(CursorSlice const &, CursorSlice const &); #endif diff --git a/src/mathed/math_support.C b/src/mathed/math_support.C index 148d33e54e..29e117df28 100644 --- a/src/mathed/math_support.C +++ b/src/mathed/math_support.C @@ -554,19 +554,19 @@ fontinfo fontinfos[] = { {"mathit", inh_family, inh_series, LyXFont::ITALIC_SHAPE, LColor::math}, {"cmex", LyXFont::CMEX_FAMILY, inh_series, - inh_shape, LColor::none}, + inh_shape, LColor::math}, {"cmm", LyXFont::CMM_FAMILY, inh_series, - inh_shape, LColor::none}, + inh_shape, LColor::math}, {"cmr", LyXFont::CMR_FAMILY, inh_series, - inh_shape, LColor::none}, + inh_shape, LColor::math}, {"cmsy", LyXFont::CMSY_FAMILY, inh_series, - inh_shape, LColor::none}, + inh_shape, LColor::math}, {"eufrak", LyXFont::EUFRAK_FAMILY, inh_series, - inh_shape, LColor::none}, + inh_shape, LColor::math}, {"msa", LyXFont::MSA_FAMILY, inh_series, - inh_shape, LColor::none}, + inh_shape, LColor::math}, {"msb", LyXFont::MSB_FAMILY, inh_series, - inh_shape, LColor::none}, + inh_shape, LColor::math}, {"wasy", LyXFont::WASY_FAMILY, inh_series, inh_shape, LColor::none}, diff --git a/src/metricsinfo.C b/src/metricsinfo.C index 1283c687f2..9e50cd0683 100644 --- a/src/metricsinfo.C +++ b/src/metricsinfo.C @@ -145,9 +145,11 @@ FontSetChanger::FontSetChanger(MetricsBase & mb, char const * name) : Changer(mb) { save_ = mb; + LyXFont::FONT_SIZE oldsize = save_.font.size(); mb.fontname = name; mb.font = LyXFont(); augmentFont(mb.font, name); + mb.font.setSize(oldsize); }