]> git.lyx.org Git - features.git/commitdiff
fix selection bug, use istreambuf_iterator in lyxsum
authorLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 30 May 2001 13:17:50 +0000 (13:17 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 30 May 2001 13:17:50 +0000 (13:17 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2071 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
acconfig.h
configure.in
src/ChangeLog
src/support/ChangeLog
src/support/lyxsum.C
src/text2.C

index 202b5a1b9a358e29aea2210b6111d440c077a74b..5f675221b39ded9ff53fe2a2ebe575b14915bd24 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-05-30  Lars Gullik Bjønnes  <larsbj@birdstep.com>
+
+       * acconfig.h: add entry for HAVE_DECL_ISTREAMBUF_ITERATOR
+
+       * configure.in: check for istreambuf_iterator in <iterator>
+
 2001-05-16  Ruurd Reitsma  <r.a.reitsma@wbmt.tudelft.nl>
 
        * Added README.Win32
index dd219f8bee733fde6b80ab5e92809f14d0f5ef61..b7318d8d0e4f48d4be4b19c13e7f10c0e5954bb0 100644 (file)
 /* Define if you have the function prototype for vsnprintf().  */
 #undef HAVE_DECL_VSNPRINTF
 
+/* Define if you have the function prototype istreambuf_iterator in
+   <iterator> */
+#undef HAVE_DECL_ISTREAMBUF_ITERATOR
+
 @BOTTOM@ 
 
 /************************************************************ 
index efaee32653774987b088a1af1136cf9226904235..126986da57f0b350d44fb4a2c6b001d209fca055 100644 (file)
@@ -272,6 +272,7 @@ fi
 AC_CHECK_FUNCS(snprintf vsnprintf)
 LYX_CHECK_DECL(snprintf, stdio.h)
 LYX_CHECK_DECL(vsnprintf, stdio.h)
+LYX_CHECK_DECL(istreambuf_iterator, iterator)
 
 AC_CHECK_FUNCS(memmove memset strchr putenv setenv mkfifo \
   mkstemp mktemp)
index 52075200b9f4d8c047c8bbba87661e21a8fb09b2..ef0f770df854a6a5722e1409d3bb773b0bb396e1 100644 (file)
@@ -1,3 +1,8 @@
+2001-05-30  Lars Gullik Bjønnes  <larsbj@birdstep.com>
+
+       * text2.C (CutSelection): make the cursor valid before the call to
+       ClearSelection.
+
 2001-05-29  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * kbsequence.C (parse): de-uglify a bit the parsing code, which
index a94949fb445e65ab7d6a883e76f83d9a804e8eac..10a495ef3125d51553f8a0da2c9334f28e0cc2cf 100644 (file)
@@ -1,3 +1,7 @@
+2001-05-30  Lars Gullik Bjønnes  <larsbj@birdstep.com>
+
+       * lyxsum.C (sum): use istreambuf_iterator when available.
+
 2001-05-29  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * lyxsum.C (sum): don't use sstream anymore, use istream_iterator
index 0f8304d11d8e5cc7ee225f0d5a661b862b500b26..ee8dbbbff9063a45157b402b43a66a18520ae00e 100644 (file)
 
 #include "support/lyxlib.h"
 
-using std::ifstream;
-using std::ios;
-using std::istream_iterator;
-
 namespace {
 
 // DO _NOT_ CHANGE _ANYTHING_ IN THIS TABLE
@@ -111,10 +107,18 @@ unsigned long do_crc(InputIterator first, InputIterator last)
 // And this would be the file interface.
 unsigned long lyx::sum(string const & file)
 {
-       ifstream ifs(file.c_str());
+#ifdef HAVE_DECL_ISTREAMBUF_ITERATOR
+       std::ifstream ifs(file.c_str());
+       if (!ifs) return 0;
+       std::istreambuf_iterator<char> beg(ifs);
+       std::istreambuf_iterator<char> end;
+       return do_crc(beg, end);
+#else
+       std::ifstream ifs(file.c_str());
        if (!ifs) return 0;
-       ifs.unsetf(ios::skipws);
-       istream_iterator<char> beg(ifs);
-       istream_iterator<char> end;
+       ifs.unsetf(std::ios::skipws);
+       std::istream_iterator<char> beg(ifs);
+       std::istream_iterator<char> end;
        return do_crc(beg, end);
+#endif
 }
index 84157b6d92294af72ed2cb52840d186dd1ddea98..8587e831cb98063154e48e0f4a1e246c224d33ab 100644 (file)
@@ -1684,7 +1684,7 @@ void LyXText::CutSelection(BufferView * bview, bool doclear)
        // more than one paragraph
        if (sel_start_cursor.par() == sel_end_cursor.par()) {
                // only within one paragraph
-               endpar = sel_start_cursor.par();
+               endpar = sel_end_cursor.par();
                int pos = sel_end_cursor.pos();
                cap.cutSelection(sel_start_cursor.par(), &endpar,
                                 sel_start_cursor.pos(), pos,
@@ -1692,7 +1692,6 @@ void LyXText::CutSelection(BufferView * bview, bool doclear)
                sel_end_cursor.pos(pos);
        } else {
                endpar = sel_end_cursor.par();
-
                int pos = sel_end_cursor.pos();
                cap.cutSelection(sel_start_cursor.par(), &endpar,
                                 sel_start_cursor.pos(), pos,
@@ -1709,9 +1708,14 @@ void LyXText::CutSelection(BufferView * bview, bool doclear)
                sel_start_cursor.par()->StripLeadingSpaces(bview->buffer()->params.textclass);
 
        RedoParagraphs(bview, sel_start_cursor, endpar);
-   
-       ClearSelection(bview);
+
+       // cutSelection can invalidate the cursor so we need to set
+       // it anew. (Lgb)
        cursor = sel_start_cursor;
+
+       // need a valid cursor. (Lgb)
+       ClearSelection(bview);
+
        SetCursor(bview, cursor.par(), cursor.pos());
        sel_cursor = cursor;
        UpdateCounters(bview, cursor.row());
@@ -2197,7 +2201,8 @@ void LyXText::SetCurrentFont(BufferView * bview) const
        if (pos > 0) {
                if (pos == cursor.par()->size())
                        --pos;
-               else if (cursor.par()->IsSeparator(pos)) {
+               else // potentional bug... BUG (Lgb)
+               if (cursor.par()->IsSeparator(pos)) {
                        if (pos > cursor.row()->pos() &&
                            bidi_level(pos) % 2 == 
                            bidi_level(pos - 1) % 2)