NeilBrown [Fri, 9 Jun 2023 08:18:13 +0000 (18:18 +1000)]
linecount: use pane_too_long() to break up line count
Rather than arbitrary numbers of lines to be counted before we take a
break and check for user activity, use pane_too_long() to decide when to
drop a mark, and when to take a break.
Also reduce the default and minimum timeout to 100ms which should help
interactivity a bit.
NeilBrown [Fri, 9 Jun 2023 02:12:36 +0000 (12:12 +1000)]
event: add on-idle support
The event: library now supports event:on-idle.
There are 3 priorities.
2 - fast immediate action, typically freeing memory that might be been
in use during previous action
1 - slow immediate action, typically pane_refresh()
0 - slow background action, only one of these is performed per loop
NeilBrown [Thu, 8 Jun 2023 23:21:00 +0000 (09:21 +1000)]
libevent: split event_list
Rather than keeping poll events on the same list as events handled by
libevent, split the list in two.
This means we don't need POLL_FD to identify the poll events.
That, combined with the use of event_get_fd() means we don't need to
store the fd in the event struct. Just the 'num' is sufficient.
NeilBrown [Tue, 6 Jun 2023 20:54:23 +0000 (06:54 +1000)]
linecount: when async needs a full count - do it.
If async linecount is asked to find a mark, and we don't have a full
line count, then we aren't going to find the mark (because async
handlers forget about it).
So be honest up front and just forget about it. This ensure
consistency.
NeilBrown [Sun, 4 Jun 2023 02:34:59 +0000 (12:34 +1000)]
Change rules for mark passed to doc:content
The 'start' mark passed to doc:content must not now be changed.
Some handlers did change it, others didn't.
Several callers didn't want it changed (so passed dup), a few didn't
care.
Due to the extra chars that can be passed, it might be awkward to return
a precise mark, and the caller might not care.
So leave it up to the callback to report any marks needed, and always
dup the mark before moving it.
NeilBrown [Sun, 4 Jun 2023 02:08:08 +0000 (12:08 +1000)]
linecount: enable for make-viewer
I don't remember exactly why it was a problem to line-count make-viewer,
possible because make out for the kernel could get very big.
But as linecount is faster and better, re-enable it.
NeilBrown [Sun, 4 Jun 2023 01:53:01 +0000 (11:53 +1000)]
linecount: use extra-text in doc:content
When a doc:content callback is given extra text, use that to expedite
linecount.
This makes it even faster, and justifies doing more work per iteration
for async counting.
NeilBrown [Sun, 4 Jun 2023 00:33:07 +0000 (10:33 +1000)]
format: handle line-count properly for format2
There is along standing bug that the linecount appears to be elevated in
a formatted view anywhere but at the start of the line.
Also word counts don't work properly.
Now that we can attach line counting to a view, this can be fixed.
Also: allow view-based linecount to be disabled by parent. It is
notably slower and for notmuch search view it is too slow.
NeilBrown [Sat, 3 Jun 2023 01:32:55 +0000 (11:32 +1000)]
linecount: intro option of sync/async counting.
lib-view doesn't need a completely up-to-date number. Other callers do.
So add a flag to support this.
CountLines will always be async when no mark is given.
When a mark is given, only async if num==1
CountLinesAsync is always async.
NeilBrown [Sat, 3 Jun 2023 00:55:59 +0000 (10:55 +1000)]
doc-email: be more subtle with default visibility.
We don't want large (base64) attachments to be visible by default, nor
do we want transformations to appear too early.
So mark all spacers, the orig-headers, and the orig first part as
visible, and everything else invisible.
This will, for example, stop LineCount from counting too much of it if
it happens to start before final visibility is configured
NeilBrown [Sat, 3 Jun 2023 00:49:37 +0000 (10:49 +1000)]
linecount: ensure we start a visible beginning of document
The document we are counting might be a 'view' and the early lines might
be clipped off. So use doc:set-ref to move to the beginning as visible
from the focus.
Also simplify the code as two conditions each have exactly the same result.
NeilBrown [Sat, 3 Jun 2023 00:34:08 +0000 (10:34 +1000)]
Always call CountLines on the focus
A view might hide some lines, and might intercept CountLines so exclude
those lines from the count.
As a line count is a particular view on the file, it should be
consistent with other views.
So always use the current focus when calling CountLines.
NeilBrown [Fri, 2 Jun 2023 07:24:00 +0000 (17:24 +1000)]
python: change how modules are loaded into the interpreter
Each edlib module is now a separate python module.
They must all "import edlib" and can find the editor pane in
"edlib.editor"
They must also import any modules they use.
NeilBrown [Fri, 2 Jun 2023 03:07:28 +0000 (13:07 +1000)]
ncurses: don't block in nc_external_viewer
Rather than blocking the whole editor while waiting for use to
copy/paste for plain-text screen, set a flag to say that the display is
suspended, and resume on next key stroke collected in the normal way.
NeilBrown [Wed, 31 May 2023 11:12:32 +0000 (21:12 +1000)]
rexel: don't accidentally make back-refs with impossible capnum.
If we try to make a backref with an impossible CAPture NUMber, it will
look like an invalid opcode, and rexel will abort() (which it
shouldn't...). So make sure it doesn't happen.
NeilBrown [Sun, 28 May 2023 07:58:03 +0000 (17:58 +1000)]
pdf,doc: mark urls.
Copy the url-marking code from notmuch as use it to mark urls in
converted pdf and doc.
I don't know that this is a good idea.. Let's see if I find it useful.
NeilBrown [Sun, 28 May 2023 07:25:27 +0000 (17:25 +1000)]
multipart: don't assume sub-panes never disappear.
If a part-pane sends a Notify:Close we REALLY mustn't touch it again.
So we must set the pointer to NULL. Even though we start closing down,
something bad could happen.
I had a crash where the attempt to send "doc:closed" to all panes
crashed on one that had already been closed.
So remove the 'safe' marking, handle the fall-out, and set .pane to NULL
when told to.
NeilBrown [Sun, 28 May 2023 06:59:54 +0000 (16:59 +1000)]
tests: filter out duplicate "Display" lines.
The 02-grep often duplicates some Display lines, apparently at random.
I don't know why and it doesn't show a display bug.
So filter them out to avoid unnecessary test failure.
NeilBrown [Sun, 28 May 2023 02:34:01 +0000 (12:34 +1000)]
Change rules for doc:render-line with mark2
When doc:render-line is called with mark2, this doesn't interrupt the
rendering, but simply reports (via ->num in the callback) the offset
where mark2 was found.
Now ->num is either negative, or the number of chars to process.
NO_NUMERIC is no longer relevant and is not tested for.
I think this is simpler as ->num and ->mark2 are not independent.
NeilBrown [Sun, 28 May 2023 02:16:21 +0000 (12:16 +1000)]
renderline: fix cursor pos after early wrap.
If a line wraps before he end, due to an early wrap marker, the cursor
will appear where it would have been if the line had been truncated
rather then wrapped.
We need to detect when a "flush" stopped because if found a wrap marker,
and to adjust the cursor pos in that case.
NeilBrown [Sat, 27 May 2023 07:46:18 +0000 (17:46 +1000)]
mark: separate mark:moving from mark:arrived
The mark:moving notification was originally for when a specific mark
moved at all.
For b64 I extended it to also notify when *any* mark moved to a specific
mark.
This can cause illegal nested notification if a mark:moving handler
tries to move a (non-specific) mark. That is bad.
So separate the two: Add mark:arrived for when a mark is moved to a
flagged marks.
Also make sure all new marks aren't flagged. I invert the sense of the
flag and call it "MARK_FLAG_WATCHED". This will be clear by default,
and only set once the (renamed) mark_watch() is called.
NeilBrown [Fri, 26 May 2023 22:14:13 +0000 (08:14 +1000)]
notmuch: use mark:moving to avoid getting stuck in quoted lines
Currently the 'point' can get stuck in hidden quoted-line and 'up'
movements get lost.
Use mark:moving (which is always sent on 'point') to see when this
happens, and to escape.
NeilBrown [Fri, 26 May 2023 03:38:12 +0000 (13:38 +1000)]
introduce doc:append:...
doc:append: is similar to doc:set:, but the given value is appended to
the attr if it exists.
The value should start with a separator character, and this is removed
if it is the first item to be appended.
NeilBrown [Thu, 25 May 2023 23:47:35 +0000 (09:47 +1000)]
doc: add default doc:get-attr which returns pane attribute.
Sometimes we want an attribute which can vary with location in the document,
but offen i satisfied with a document-wide value.
fill:start-re is a good example.
Provide a default doc:get-attr, which will be called if no attr can be
found at the specific location. This returns a pane attribute is
possible.
Also ensure all current doc:get-attr function fall through if they
cannot find a value.
NeilBrown [Mon, 22 May 2023 10:53:47 +0000 (20:53 +1000)]
handle text-fill in .md files better.
Enhance text-fill so that various style attributes can be on the pane
rather than on the character, and set pane attributes for markdown to
notice the starts of various paragraph types, particularly the various
list entries.