Alfredo Braunstein wrote:

> John Levon wrote:
> 
>> But the stuff you do with last par is better than what I did. We just
>> need to combine the two :)
> 
> How about this one?

This one should actually work ;)

Regards, Alfredo

Index: CutAndPaste.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/CutAndPaste.C,v
retrieving revision 1.103
diff -u -r1.103 CutAndPaste.C
--- CutAndPaste.C       17 Jun 2003 15:33:45 -0000      1.103
+++ CutAndPaste.C       17 Jun 2003 21:41:46 -0000
@@ -31,6 +31,8 @@
 #include "support/lstrings.h"
 #include "support/limited_stack.h"
 
+#include <algorithm>
+
 using std::endl;
 using std::pair;
 using std::make_pair;
@@ -58,8 +60,23 @@
        CutStack::const_iterator end = cuts.end();
        for (; cit != end; ++cit) {
                ParagraphList const & pars = cit->first;
-               string asciiPar(pars.front().asString(&buffer, false), 0, 25);
-               selList.push_back(asciiPar);
+               string frontpar = pars.front().asString(&buffer, false);
+               string shown;
+               int size = pars.size();
+               if (size > 1 && frontpar.size() == 0) {
+                       frontpar = boost::next(pars.begin())->asString(&buffer, false);
+                       --size;
+               }
+               if (size == 1 && frontpar.size() < 25)
+                       shown = frontpar;
+               else {
+                       string backpar = pars.back().asString(&buffer, false);
+                       int frontsize = std::min(int(frontpar.size()), 10);
+                       int backstart = std::max(0, int(backpar.size()) - 10);
+                       shown = frontpar.substr(0, frontsize) + "..." + 
+                               backpar.substr(backstart);
+               }
+               selList.push_back(shown);
        }
 
        return selList;

Reply via email to