]> git.neil.brown.name Git - edlib.git/commitdiff
linecount: make it possible to disable
authorNeilBrown <neil@brown.name>
Sun, 4 Jun 2023 23:40:48 +0000 (09:40 +1000)
committerNeilBrown <neil@brown.name>
Wed, 28 Jun 2023 05:40:21 +0000 (15:40 +1000)
Make it possible to disable linecount ...  because sometime it is too
slow.

Also make it easier to tune the timing.
And slow it down a bit because it sometimes impacts usability.

Signed-off-by: NeilBrown <neil@brown.name>
DOC/TODO.md
lib-linecount.c

index 310e7b24c535df5bfacf9e59639999013a26de2c..8f7d7caba9687880e805e33f7308596a31513810 100644 (file)
@@ -9,6 +9,7 @@ the file.
 
 ### Trivial
 
+- [ ] Unify edlib_timing and pane_too_long ??
 - [X] If an email part doesn't end with newline, last character is swallowed.
 - [X] What is rule for doc:content?  Does the mark move and get passed
       down, or is it copied and left unchanged?
@@ -27,6 +28,7 @@ the file.
 
 ### Medium
 
+- [ ] add event:on-idle with 3 priority levels
 - [X] Always do word-count async.
 - [ ] lib-url
 - [ ] lib-mergeview improvements
@@ -63,6 +65,15 @@ Requirements for a v1.0 release
 Core features
 -------------
 
+- [ ] add event:on-idle with 3 priority levels
+      2 - fast cleanup that must be run immediately
+      1 - slower general response to recent command: typically
+          pane_refresh
+      0 - do one of these before checking of other events
+      Use 2 for freeing panes and marks and other memory
+      Use 1 for pane_refresh
+      Use 0 for splitting up background tasks like spell and linecount
+      simplify main loop in edlib.c to:  call("event:run", ed)
 - [ ] teach input to allow a repeat command to be registered so that e.g.
       search/replace and do a bit of work, then ask to be called again.
       input can cancel this on suitable input.
index 407ecd3b01c7c881f548769316a622b7650d3c18..c9352f1b03a6ed9de41917c4ba5450cc465681ad 100644 (file)
@@ -38,7 +38,8 @@
 static struct map *linecount_map;
 DEF_LOOKUP_CMD(handle_count_lines, linecount_map);
 
-static const int batch_marks = 6;
+static const int batch_marks = 1;
+static const int batch_timer = 20;
 static bool testing = False;
 
 struct count_info {
@@ -190,10 +191,24 @@ static void count_calculate(struct pane *p safe,
 {
        int lines, words, chars, l, w, c;
        struct mark *m, *m2;
+       char *disable;
 
        if (testing)
                sync = True;
 
+       disable = pane_attr_get(p, "linecount-disable");
+       if (disable && strcmp(disable, "yes") == 0) {
+               if (end) {
+                       attr_set_str(&end->attrs, "line", "??");
+                       attr_set_str(&end->attrs, "word", "??");
+                       attr_set_str(&end->attrs, "char", "??");
+               }
+               attr_set_str(&p->attrs, "lines", "-");
+               attr_set_str(&p->attrs, "words", "-");
+               attr_set_str(&p->attrs, "chars", "-");
+               return;
+       }
+
        if (!end && attr_find(p->attrs, "lines"))
                /* nothing to do */
                return;
@@ -207,7 +222,7 @@ static void count_calculate(struct pane *p safe,
                call("doc:set-ref", p, 1, m);
                do_count(p, owner, m, vmark_next(m), &l, &w, &c, sync ? -1 : batch_marks);
                if (!sync) {
-                       call_comm("event:timer", p, &linecount_restart, 10, end);
+                       call_comm("event:timer", p, &linecount_restart, batch_timer, end);
                        return;
                }
        }
@@ -216,7 +231,7 @@ static void count_calculate(struct pane *p safe,
                /* need to update this one */
                do_count(p, owner, m, vmark_next(m), &l, &w, &c, sync ? -1 : batch_marks);
                if (!sync) {
-                       call_comm("event:timer", p, &linecount_restart, 10, end);
+                       call_comm("event:timer", p, &linecount_restart, batch_timer, end);
                        return;
                }
        }
@@ -234,7 +249,7 @@ static void count_calculate(struct pane *p safe,
                        continue;
                do_count(p, owner, m, vmark_next(m), &l, &w, &c, sync ? -1 : batch_marks);
                if (!sync) {
-                       call_comm("event:timer", p, &linecount_restart, 10, end);
+                       call_comm("event:timer", p, &linecount_restart, batch_timer, end);
                        return;
                }
        }