Bennett Helm a écrit :
On Apr 5, 2006, at 6:27 AM, Abdelrazak Younes wrote:

I seem to remember remember some problem like this on Mac also. Bennet could you try test this patch?

I haven't been following this carefully. What exactly should I be testing?

Paragraph creation/deletion induce a delay on windows. The attached patch get rid of the delay for two common cases. I am not sure there's a problem on Mac if you could try, that would be great.

Abdel.

Index: buffer_funcs.C
===================================================================
--- buffer_funcs.C      (revision 13538)
+++ buffer_funcs.C      (working copy)
@@ -328,7 +328,6 @@
        }
 }
 
-
 bool needEnumCounterReset(ParIterator const & it)
 {
        Paragraph const & par = *it;
@@ -345,6 +344,33 @@
        return true;
 }
 
+void setItemLabel(Paragraph & par)
+{
+       BOOST_ASSERT(par.layout()->labeltype == LABEL_ITEMIZE);
+       
+       // At some point of time we should do something more
+       // clever here, like:
+       //   par.params().labelString(
+       //    bufparams.user_defined_bullet(par.itemdepth).getText());
+       // for now, use a simple hardcoded label
+       string itemlabel;
+       switch (par.itemdepth) {
+       case 0:
+               itemlabel = "*";
+               break;
+       case 1:
+               itemlabel = "-";
+               break;
+       case 2:
+               itemlabel = "@";
+               break;
+       case 3:
+               itemlabel = "·";
+               break;
+       }
+       
+       par.params().labelString(itemlabel);
+}
 
 // set the counter of a paragraph. This includes the labels
 void setCounter(Buffer const & buf, ParIterator & it)
@@ -390,28 +416,9 @@
                        par.params().labelString(label);
                }
        } else if (layout->labeltype == LABEL_ITEMIZE) {
-               // At some point of time we should do something more
-               // clever here, like:
-               //   par.params().labelString(
-               //    bufparams.user_defined_bullet(par.itemdepth).getText());
-               // for now, use a simple hardcoded label
-               string itemlabel;
-               switch (par.itemdepth) {
-               case 0:
-                       itemlabel = "*";
-                       break;
-               case 1:
-                       itemlabel = "-";
-                       break;
-               case 2:
-                       itemlabel = "@";
-                       break;
-               case 3:
-                       itemlabel = "·";
-                       break;
-               }
 
-               par.params().labelString(itemlabel);
+               setItemLabel(par);
+
        } else if (layout->labeltype == LABEL_ENUMERATE) {
                // FIXME
                // Yes I know this is a really, really! bad solution
@@ -522,7 +529,30 @@
        }
 }
 
+bool needsUpdateCounters(size_t const pit, ParagraphList & pars,
+                                               Buffer const & buf)
+{
+       Paragraph & current_par = pars[pit];
 
+       switch (current_par.layout()->labeltype) {
+       // layout that has no label at all (ex: standard layout)
+       case LABEL_NO_LABEL:
+               return false;
+
+       // layout that has no label at all (ex: standard layout)
+       case LABEL_ITEMIZE:
+               setItemLabel(current_par);
+               return false;
+
+//     case LABEL_ENUMERATE:
+//             setEnumLabel(pit, pars, buf);
+//             return false;
+       
+       default:
+               return true;
+       }
+}
+
 string expandLabel(Buffer const & buf,
        LyXLayout_ptr const & layout, bool appendix)
 {
Index: buffer_funcs.h
===================================================================
--- buffer_funcs.h      (revision 13538)
+++ buffer_funcs.h      (working copy)
@@ -13,6 +13,7 @@
 #define BUFFER_FUNCS_H
 
 #include "lyxlayout_ptr_fwd.h"
+#include "ParagraphList_fwd.h"
 
 #include <string>
 
@@ -48,6 +49,14 @@
 std::string expandLabel(Buffer const & buf, LyXLayout_ptr const & layout,
                        bool appendix);
 
+/// updates current counter and/or label if possible.
+/**
+\retval true if a full updateCounters is required.
+\retval false if a full updateCounters is not required.
+*/
+bool needsUpdateCounters(size_t const pit, ParagraphList & pars,
+                                                Buffer const & buf);
+
 /// updates all counters
 void updateCounters(Buffer const &);
 
Index: text.C
===================================================================
--- text.C      (revision 13538)
+++ text.C      (working copy)
@@ -1087,7 +1087,8 @@
        while (!pars_[next_par].empty() && pars_[next_par].isNewline(0))
                pars_[next_par].erase(0);
 
-       updateCounters(cur.buffer());
+       if (needsUpdateCounters(next_par, pars_, cur.buffer()))
+               updateCounters(cur.buffer());
 
        // Mark "carriage return" as inserted if change tracking:
        if (cur.buffer().params().tracking_changes) {
@@ -1669,7 +1670,9 @@
                                --cur.pos();
 
                // the counters may have changed
-               updateCounters(cur.buffer());
+               if (needsUpdateCounters(cpit, pars_, cur.buffer()))
+                       updateCounters(cur.buffer());
+
                setCursor(cur, cur.pit(), cur.pos(), false);
        }
        return needsUpdate;

Reply via email to