NeilBrown [Wed, 28 Jun 2023 20:40:20 +0000 (06:40 +1000)]
Finish attach-display-foo commands with doc:attach-view
And attach-display-* command must now be called on a document or on the
root.
If it was on a document, that document is viewed in the created display
using doc:attach-view.
This makes it easier for a caller to create a useful window in a single
command.
NeilBrown [Wed, 28 Jun 2023 09:22:49 +0000 (19:22 +1000)]
call editor:activate-display from the display code.
Any command that creates a display pane now also calls
editor:activate-display and returns the result.
That means other code what wants a display doesn't need to know about
activating the display.
NeilBrown [Wed, 28 Jun 2023 09:11:43 +0000 (19:11 +1000)]
server: don't hold reference to the display pane.
The display pane will soon not be available as creation a display will
transparently stack various things on top of it.
So use "Display:close" instead of .close() and just hold the top level.
.term and .disp are often the same now. I wonder if we need both.
NeilBrown [Wed, 28 Jun 2023 09:04:01 +0000 (19:04 +1000)]
add window:set: and use it to set attributes for displays.
We sometimes need to set DISPLAY etc so it is visible to the display
handler, particularly for ncurses.
Use new window:set: to set these on the window-core pane.
This means that editor:active-display is now always immediately after
the display pane is created, so we are closer to letting that be called
as part of creating the display pane.
NeilBrown [Wed, 28 Jun 2023 08:08:15 +0000 (18:08 +1000)]
handle Display:close in window-core
When a display/window is closed, the whole stack needs to go including
the window-core pane. So let the Display:close request get down to
there, and close everything.
NeilBrown [Wed, 28 Jun 2023 06:56:39 +0000 (16:56 +1000)]
introduce core-window.c
core-window provides a window-core pane which provides core
functionality for all windows. Some functionality is moved out of
lib-input where it doesn't really belong.
NeilBrown [Wed, 28 Jun 2023 06:54:41 +0000 (16:54 +1000)]
input: don't use pane_notify to send window notification.
input can currently use pane_notify directly instead all calling
window:notify:foo because it manages these notifications.
But soon it won't, so call("window:notify:foo") like everyone else has
too.
NeilBrown [Wed, 28 Jun 2023 06:03:07 +0000 (16:03 +1000)]
Move parse_ini() into a separate include file.
This makes it easy for it to be reused, or even take out into another
package. Unlike the rest of edlib, it can be used under any popular
open source license.
NeilBrown [Wed, 28 Jun 2023 05:43:18 +0000 (15:43 +1000)]
compose: run notmuch-addr asynchronously.
We can no longer call pane.root.refresh(), so we cannot update the
display while waiting for something - which is good: we shouldn't wait
for things.
So arrange for an even when notmuch-addr reports some data and insert
the first match then - if point hasn't moved.
NeilBrown [Tue, 27 Jun 2023 22:20:03 +0000 (08:20 +1000)]
Split module list into a separate ini file
One day the list of module dependencies will be mechanically generated
from all available modules. To prepare for that, and to keep edlib.ini
small, split out modules.ini.
NeilBrown [Tue, 27 Jun 2023 01:43:32 +0000 (11:43 +1000)]
pane: if an on-idle event to handle damage cannot be added, don't add damage.
If pane_damaged() is called before the event handler is ready, the
on-idle doesn't get registered properly and will never get called.
So check for errors, and leave damage unset so the next pane_damaged()
call can schedule the on-idle event.
NeilBrown [Fri, 23 Jun 2023 07:17:16 +0000 (17:17 +1000)]
messageline: treat an empty message as message-removal.
If a Message command provides a zero-lenth message, remove any current
message rather than setting a explicit empty message. This allows a
default to appear.
NeilBrown [Fri, 23 Jun 2023 05:47:03 +0000 (15:47 +1000)]
renderline: allow Refresh to be handled.
If the requested z depth (at attach time) is >= 0, then Refresh messages
will be sent.
They can now be handled.
The cursor pos for the refresh can now be set with renderline:set.
This ->num is only used for Refresh.
NeilBrown [Fri, 23 Jun 2023 03:09:48 +0000 (13:09 +1000)]
render-complete: add highlight more correctly.
As the original might have attributes in it, we need to find the
character that we want to highlight, and highlight just those. Possibly
there will be multiple ranges if the characters already have differing
highlights.
NeilBrown [Fri, 23 Jun 2023 02:17:22 +0000 (12:17 +1000)]
lib-linefilter: always strip attributes from line before comparing.
If the key is an attribute, tell the callback using ci->key=="attr"
rather than the magic of -num2 == -1, which can get set by other
doc:render-line functions.
When the key is a line from doc:render-line, properly strip all
attributes, both old and new style.
NeilBrown [Thu, 22 Jun 2023 23:02:55 +0000 (09:02 +1000)]
render-present: don't use doc:render-line to get text.
doc:render-line returns a line that can include markup. But
render-present doesn't expect or handle markup.
So use doc:get-str to get the line, and quote and '<' characters.
NeilBrown [Wed, 21 Jun 2023 07:53:03 +0000 (17:53 +1000)]
lib-renderline: make control chars stand out more.
Conrtol chars should not appear in the line given to lib-renderline.
We try to handle them, but let us make them much more obvious so they
look wrong as well as being wrong.
NeilBrown [Wed, 21 Jun 2023 07:48:57 +0000 (17:48 +1000)]
lib-renderline: expect control chars instead of <> for attributes.
Using <> to distinguish attributes is clumsy as it requires that '<' be
quoted.
We already quote control characters, making them <red>^X</red> so use
control characters for distinguishing attributes.
SOH (\1) marks start of attrs
STX (\2) marks end of attrs, start of text
ETX (\3) marks end of the text for those attrs.
ACK (\6) is used as a filler when needed.
A string that start \6 or \1 is assumed not to contain meaningful <>
Otherwise we translate to remain compatible with old code.
NeilBrown [Wed, 21 Jun 2023 07:03:14 +0000 (17:03 +1000)]
renderline: fix rendering bug when a TAB wraps.
If a tab wraps, we show the character immediately before the tab at the
start of the next line, which is wrong.
It is particularly weird when that char is the '>' at the end of an
attribute marking.
NeilBrown [Wed, 21 Jun 2023 04:35:50 +0000 (14:35 +1000)]
markup: always convert control characters.
I don't know why this is_true_eol test is here, but is is NEVER set at
this point, so it breaks control characters - leaving them to
lib-renderline to handle, which I don't want.
NeilBrown [Sun, 18 Jun 2023 21:46:27 +0000 (07:46 +1000)]
config: ensure new config overrides earlier config.
Config must be applied in the order is read. So when recording filename
triggers, always add to the end of the list. And when including
per-user configuration, read it after the global configuration.
NeilBrown [Sun, 18 Jun 2023 07:54:12 +0000 (17:54 +1000)]
diff: fix occasional slowness.
If a diff region was marked before it was completely generated, an
attempt to mark the word-diff regions could create over-lapping vmark
ranges, which causes confusion.
So always remove old vmark ranges before adding new ones.
NeilBrown [Sun, 18 Jun 2023 00:03:25 +0000 (10:03 +1000)]
doc: allow key to be passed to doc:set: in ->str2
If "doc:set:" or "doc:append:" is called with an empty key appended to
the name, find the key in ->str2.
This avoids the need for string allocation if the key is in a variable.
NeilBrown [Sat, 10 Jun 2023 04:03:34 +0000 (14:03 +1000)]
Introduce pane_register_root()
pane_register_root() is an internal interface, called only by
editor_new(), which creates a root pane, with ->parent pointing to
itself.
pane_register() and doc_register() must now be given a non-NULL parent.
as a pane that handles one typically needs to handle them all.
The difference notifications are reflected in ->num:
1 : new child registered - ->focus is the child
-1 : existing child is being closed - ->focus is that child
-2 : existing child is being moved away - ->focus is tha child
2 : existing child replaced - ->focus in the new child
This follows a "-2" where the old was moved away.
Several handlers are extended to handle all possibilities.
NeilBrown [Fri, 16 Jun 2023 11:19:15 +0000 (21:19 +1000)]
tile: be extra careful when merging a tile into it's parent.
When a parent tile gets down to just one child, the child is subsumed
into the parent.
This requires that the parent really is a tile pane. As pane_reparent()
and change parantage, it is possible that it isn't.
So add extra checks before assuming the types of things.
NeilBrown [Wed, 14 Jun 2023 10:21:58 +0000 (20:21 +1000)]
Add a config-file parser.
An "ini" style file can be read to set global attributes, configure
auto-loading of modules (listing commands that they define) and
eventually per-doc configurations based on file name.
NeilBrown [Wed, 14 Jun 2023 10:25:33 +0000 (20:25 +1000)]
core-keymap: handle map changing when command is run.
Even if a command returns Efallthrough, it could have changed the map
(by auto-loading a module).
So we cannot assume the "pos" is still correct. So recalculate it each
time when scanning all commands with a given prefix.
NeilBrown [Mon, 12 Jun 2023 11:46:01 +0000 (21:46 +1000)]
mergeview: capture < and > on marker lines.
When cursor is on a marker line, capture < and > for manipulating the
merge.
On the first marker: lines are moved between top of orig and preceding
content.
On the second marker: lines are moved between bottom of orig and
following content.
NeilBrown [Mon, 12 Jun 2023 09:40:56 +0000 (19:40 +1000)]
mergeview/wiggle: improvements for space-only conflicts.
1/ change how the "wiggle" is reported. It is no longer reported
by "set-wiggle". Instead a new "get-result" function returns
various results including the "wiggle".
2/ count how many conflicts only involve white space. If that is
all the conflicts, then still calculate the wiggle.
3/ If a merge only has space conflicts, use blue for the merge
markers rather the red (or green).
4/ mark the green merge markers bold so they stand out more
5/ When adding attrs, annotate conflicts which are space only,
and respond to that with underlines instead of inverse red.
NeilBrown [Mon, 12 Jun 2023 05:14:01 +0000 (15:14 +1000)]
mergeview: add commands to apply the merge.
If :A-m has a numeric arg, then it now behaves differently and often
edits the merge rather than finding another:
-ve: discard the patch and just keep the original.
0 : if no conflicts remain, apply the patch
1 : discard the original and just keep the "after" part.
9 : if there is a selected merge, cut the path and leave the original
if there is no selected merge, paste the recently cut diff,
using the selection as the original.
NeilBrown [Mon, 12 Jun 2023 05:11:24 +0000 (15:11 +1000)]
wiggle: return the wiggled result from set-wiggle.
If set-wiggle is given ->comm2, and if there are no conflicts, return
the successful wiggle as a string.
Also if the attribute passed is an empty string, don't add any markup.
This can be used to only get the wiggle.
The intention of the "wiggle" command was to return the wiggle, but
there is some much commonality with set-wiggle that it seemed easiest to
add the functionality there.
So discard the unimplemented 'wiggle' command.
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.