]> git.neil.brown.name Git - edlib.git/log
edlib.git
2 years agodiscard old auto-load code
NeilBrown [Tue, 27 Jun 2023 01:45:36 +0000 (11:45 +1000)]
discard old auto-load code

Now that lib-config can autoload modules, get rid of the old limited
approach.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agopane: if an on-idle event to handle damage cannot be added, don't add damage.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agomessageline: right justify the date/time
NeilBrown [Fri, 23 Jun 2023 10:00:12 +0000 (20:00 +1000)]
messageline: right justify the date/time

Do this because we can.  And because I once wanted to.
I wonder if I'll like it.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agomessageline: use lib-renderline for drawing the message line.
NeilBrown [Fri, 23 Jun 2023 09:24:30 +0000 (19:24 +1000)]
messageline: use lib-renderline for drawing the message line.

This provides more flexibility and already allows long lines to wrap -
as is very obvious in the "spell" test case.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agomessageline: treat an empty message as message-removal.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agorenderline: allow Refresh to be handled.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agorenderline: allow z depth to be given when attaching.
NeilBrown [Fri, 23 Jun 2023 05:39:32 +0000 (15:39 +1000)]
renderline: allow z depth to be given when attaching.

Rather than assuming a negative z depth is always wanted, use ci->num
when the pane is attached.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolib-markup: generate markup with soh/stx/etc rather then <> etc
NeilBrown [Fri, 23 Jun 2023 03:42:43 +0000 (13:42 +1000)]
lib-markup: generate markup with soh/stx/etc rather then <> etc

There is less likelyhood of problems with stray '<' using this form of
markup.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agorender-complete: handle cursor display properly.
NeilBrown [Fri, 23 Jun 2023 03:34:08 +0000 (13:34 +1000)]
render-complete: handle cursor display properly.

If ->mark2 is passed to doc:render-line, do the right this to report the
offiset.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agorender-complete: add highlight more correctly.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agorender-complete: strip new-style attrs when returning result.
NeilBrown [Fri, 23 Jun 2023 02:39:33 +0000 (12:39 +1000)]
render-complete: strip new-style attrs when returning result.

Copy strip_attrs() from lib-linefiler and use that to strip all attrs
from line before returning result.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolib-linefilter: always strip attributes from line before comparing.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agorender-present: don't use doc:render-line to get text.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolib-renderline: make control chars stand out more.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolib-renderline: expect control chars instead of <> for attributes.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agorenderline: fix rendering bug when a TAB wraps.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agomarkup: always convert control characters.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoIntroduce edlib_testing().
NeilBrown [Mon, 19 Jun 2023 11:34:18 +0000 (21:34 +1000)]
Introduce edlib_testing().

Instead of checking getenv("EDLIB_TESTING") in various places, combine
it into a single interface.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoTODO: assorted additions and revisions.
NeilBrown [Mon, 19 Jun 2023 10:45:33 +0000 (20:45 +1000)]
TODO: assorted additions and revisions.

Adding lots of specific things that could be configured via config.ini,
and simplifying some other stuff.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoconfig: support PREFIX commands for module auto-load
NeilBrown [Sun, 18 Jun 2023 22:39:10 +0000 (08:39 +1000)]
config: support PREFIX commands for module auto-load

Now that prefix commands are handled, we can do charet properly and
discard the "ALWAYS" hack.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoIntroduce global-set-command-prefix
NeilBrown [Sun, 18 Jun 2023 22:35:37 +0000 (08:35 +1000)]
Introduce global-set-command-prefix

"global-set-command-prefix" is an analog of key_add_prefix()

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoserver: allow auto-startup to be configurable.
NeilBrown [Sun, 18 Jun 2023 22:08:52 +0000 (08:08 +1000)]
server: allow auto-startup to be configurable.

Use a "startup-" command for starting, and check a config variable to
decide whether to actually start.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoconfig: free triggers on exit.
NeilBrown [Sun, 18 Jun 2023 21:49:43 +0000 (07:49 +1000)]
config: free triggers on exit.

When config is freed, free all the triggers.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoconfig: ensure new config overrides earlier config.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agodiff: fix occasional slowness.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoconfig: support [file:glob] config setting.
NeilBrown [Sun, 18 Jun 2023 01:45:04 +0000 (11:45 +1000)]
config: support [file:glob] config setting.

Make a list of attrs to be added to documents based on file name, and
register a doc:appeared- handler to apply them.

This makes the config.py script irrelevant.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoconfig: allocate a local data
NeilBrown [Sat, 17 Jun 2023 23:27:57 +0000 (09:27 +1000)]
config: allocate a local data

config will need to store data, so it needs storage.
So create that storage with the command the first
time config:load is called.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoIntroduce strstarts()
NeilBrown [Sun, 18 Jun 2023 00:44:39 +0000 (10:44 +1000)]
Introduce strstarts()

It is a common pattern to check if a string starts with a fixed string.
So match this a #defined thing.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agodoc: allow key to be passed to doc:set: in ->str2
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoIntroduce ->root pointer in panes.
NeilBrown [Mon, 12 Jun 2023 00:47:27 +0000 (10:47 +1000)]
Introduce ->root pointer in panes.

pane->root gets straight to the root, so we can efficiently access
global state.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoIntroduce pane_register_root()
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoRevise pane_reparent()
NeilBrown [Thu, 15 Jun 2023 06:12:35 +0000 (16:12 +1000)]
Revise pane_reparent()

Treating a disconnected pane (p->parent == p) as a special cas in
pane_reparent() is unpleasant as disconnected panes are not something I
want.

So change pane_reparent() to have a different rule for determining
whether the new parent needs to be attached below p->parent first.

Also ensure Child-Notify notifications are consistant.

If the reparent fails, LOG an error and teach python interface to
trigger an exception.

Finally, only notmuch depended on the special meaning of disconnected
panes, so change it to fit the new model and add better explanations.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoIntroduce Child-Notify
NeilBrown [Sat, 17 Jun 2023 06:40:39 +0000 (16:10 +0930)]
Introduce Child-Notify

Child-Notify replaces
  ChildClosed
  ChildRegistered
  ChildMoved
  ChildReplaced

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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoCombine doc_attach() and do_doc_assign()
NeilBrown [Sat, 17 Jun 2023 11:41:49 +0000 (21:41 +1000)]
Combine doc_attach() and do_doc_assign()

These are always called together, so make them one function.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoAllow do_doc_assign() to fail.
NeilBrown [Sat, 17 Jun 2023 11:34:26 +0000 (21:34 +1000)]
Allow do_doc_assign() to fail.

do_doc_assign() can fail.  If it does, point will be NULL and can get
derefed.
So allow it to fail and close the pane.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agotile: be extra careful when merging a tile into it's parent.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoAdd a config-file parser.
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.

All module loading requests are now in edlib.ini.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoglobal-set-attr: support append.
NeilBrown [Wed, 14 Jun 2023 10:27:51 +0000 (20:27 +1000)]
global-set-attr: support append.

Make it easy to append to a global attr.  Note the semantics are a bit
different to appending to a pane attr. I wonder what is best.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agocore-keymap: handle map changing when command is run.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agomergeview: auto-position on merge at first visit.
NeilBrown [Tue, 13 Jun 2023 22:22:21 +0000 (08:22 +1000)]
mergeview: auto-position on merge at first visit.

When first visiting a file with a merge, auto-find that merge.

I'm not sure this is a good idea, and won't know until I try.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agomergeview: handle mode-swap-mark
NeilBrown [Tue, 13 Jun 2023 22:08:20 +0000 (08:08 +1000)]
mergeview: handle mode-swap-mark

Intercept the swap-mark command and instead cycle among corresponding
places in the three branches.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoemacs: handle cx:c-x by resending the equivalent command.
NeilBrown [Mon, 12 Jun 2023 12:01:45 +0000 (22:01 +1000)]
emacs: handle cx:c-x by resending the equivalent command.

This allows the command to be intercepted without encode emacs code
bindings elsewhere.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agowiggle: include merge number in attached attributes.
NeilBrown [Mon, 12 Jun 2023 11:53:37 +0000 (21:53 +1000)]
wiggle: include merge number in attached attributes.

By including the merge number, it is possible to find corresponding
locations in the different branches.

Also add a leading 'M' if this is the start of a merge, or 'L' if the
start of a line within a merge.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agodetect and limit recursion
NeilBrown [Mon, 12 Jun 2023 22:42:31 +0000 (08:42 +1000)]
detect and limit recursion

If depth of recursion every reaches 100, fail any request.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agomergeview: capture < and > on marker lines.
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.

I don't know what I want on other marker lines.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agomergeview/wiggle: improvements for space-only conflicts.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agomergeview: add commands to apply the merge.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agowiggle: return the wiggled result from set-wiggle.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agorexel: remove abort() calls not in #ifdef DEBUG
NeilBrown [Mon, 12 Jun 2023 01:26:41 +0000 (11:26 +1000)]
rexel: remove abort() calls not in #ifdef DEBUG

if DEBUG is set, it is OK to abort.  If not, don't.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoMark various 'static' values as 'const'.
NeilBrown [Mon, 12 Jun 2023 01:21:37 +0000 (11:21 +1000)]
Mark various 'static' values as 'const'.

Anything that can be const now it.

 git grep -nH 'static[^(]*[=;]' | grep -v const | grep -v 'struct map'

can help find things that should be const, or maybe should put moved to
the 'editor' pane.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoTODO.md: various revisions.
NeilBrown [Fri, 9 Jun 2023 23:27:16 +0000 (09:27 +1000)]
TODO.md: various revisions.

Remove things that are done
Choose things to do next
give more detail for mergeview changes

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoautospell: use pane_too_long() to limit background work.
NeilBrown [Fri, 9 Jun 2023 08:26:02 +0000 (18:26 +1000)]
autospell: use pane_too_long() to limit background work.

Rather than an arbitrary count limit, use pane_too_long() to limit how
much work is done in the background.

But keep the low limit when TESTING so the test has something
interesting too see.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: use pane_too_long() to break up line count
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoUse event:on-idle for short-timeout background tasks.
NeilBrown [Fri, 9 Jun 2023 03:41:35 +0000 (13:41 +1000)]
Use event:on-idle for short-timeout background tasks.

Background tasks like linecount, spell check, and make parsing now use
the background queue of event:on-idle

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoDrop the on_idle- multicall.
NeilBrown [Fri, 9 Jun 2023 03:25:15 +0000 (13:25 +1000)]
Drop the on_idle- multicall.

event:on-idle is doing all on-idle stuff, so we don't need the on_idle-
multicall any more.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoeditor: use event:on-idle to delayed-free the store.
NeilBrown [Fri, 9 Jun 2023 03:23:22 +0000 (13:23 +1000)]
editor: use event:on-idle to delayed-free the store.

Now there is nothing for editor_clean_up to do, so discard that.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoeditor: use event:on-idle to free marks.
NeilBrown [Fri, 9 Jun 2023 03:21:27 +0000 (13:21 +1000)]
editor: use event:on-idle to free marks.

Delayed-free of marks now happens with event:on-idle

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoeditor: move delayed free of panes to event:on-idle
NeilBrown [Fri, 9 Jun 2023 03:18:33 +0000 (13:18 +1000)]
editor: move delayed free of panes to event:on-idle

Schedule an on-idle event when we queue the first pane to free, and use
it to free them all.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agodiscard editor-on-idle in favour of event:on-idle.
NeilBrown [Fri, 9 Jun 2023 03:08:25 +0000 (13:08 +1000)]
discard editor-on-idle in favour of event:on-idle.

editor-on-idle calls now use event:on-idle.  Priority 1 for closing
panes, priority 0 for other things.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoCall pane_refresh() from event:on-idle
NeilBrown [Fri, 9 Jun 2023 03:05:55 +0000 (13:05 +1000)]
Call pane_refresh() from event:on-idle

pane_refresh is now integral to core-pane - external code cannot call it.

When the root pane is first damaged, we schedule the refresh to happen
on-idle at priority 1 - before any background task.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoevent: add on-idle support
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

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolibevent: split out run_list()
NeilBrown [Thu, 8 Jun 2023 23:38:14 +0000 (09:38 +1000)]
libevent: split out run_list()

I'll want more places that run a list of events, so split out this
functionality.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolibevent: split event_list
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolibevent: minor fixes.
NeilBrown [Thu, 8 Jun 2023 23:15:04 +0000 (09:15 +1000)]
libevent: minor fixes.

1/ event_del can be called unconditionally.  It is a no-op if it has
already been called.
2/ missing event_free calls.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolibevent: don't store mseconds separate from num.
NeilBrown [Thu, 8 Jun 2023 11:44:11 +0000 (21:44 +1000)]
libevent: don't store mseconds separate from num.

When mseconds is used it is alway identical to num.
So just use num.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agonotmuch: when moving among messages, set focus to query pane.
NeilBrown [Thu, 8 Jun 2023 10:47:34 +0000 (20:47 +1000)]
notmuch: when moving among messages, set focus to query pane.

Leaving the focus in the message pane feels clumsy.  So let's try always
moving back to the query pane.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoemacs: add CX-< and CX-> to scroll left or right.
NeilBrown [Thu, 8 Jun 2023 05:54:34 +0000 (15:54 +1000)]
emacs: add CX-< and CX-> to scroll left or right.

The first CX-< switch from wrapping to no-wrapping.  Then it shifts 8
units at a time, unless a number is given.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolib-url: only follow link one it has been shown in message-line
NeilBrown [Wed, 7 Jun 2023 22:36:45 +0000 (08:36 +1000)]
lib-url: only follow link one it has been shown in message-line

The first time a url is activated, only display it and don't follow it.
The second time it can be followed.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agorender-lines: add "Activate" support.
NeilBrown [Wed, 7 Jun 2023 22:30:58 +0000 (08:30 +1000)]
render-lines: add "Activate" support.

When render-lines gets "Activate" it looks up the attrs at the mark and
if there is an active-tag, it calls "Activate:tag".

This makes email:select unnecessary.

lib-url uses Activate to respond to K:Enter

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoChange "Mouse-Activate:" to simply "Activate:"
NeilBrown [Wed, 7 Jun 2023 22:03:58 +0000 (08:03 +1000)]
Change "Mouse-Activate:" to simply "Activate:"

I want to activate buttons with the keyboard, so change the command to
drop the "Mouse-" prefix.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoIntroduce lib-url
NeilBrown [Sun, 4 Jun 2023 11:28:12 +0000 (21:28 +1000)]
Introduce lib-url

lib-url isolates the url-handling: finding in a document, adding
markup,a and responding to that markup to highlight and activate.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: when async needs a full count - do it.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: make it possible to disable
NeilBrown [Sun, 4 Jun 2023 23:40:48 +0000 (09:40 +1000)]
linecount: make it possible to disable

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>
2 years agodoc-email: ensure doc:get-boundary skips invisible parts
NeilBrown [Sun, 4 Jun 2023 03:41:00 +0000 (13:41 +1000)]
doc-email: ensure doc:get-boundary skips invisible parts

A boundary must be at the start of a VISIBLE part to be useful.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agomarkup: do boundary checks *before* getting a char.
NeilBrown [Sun, 4 Jun 2023 03:40:09 +0000 (13:40 +1000)]
markup: do boundary checks *before* getting a char.

If we do the boundary check after, we drop a character.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoChange rules for mark passed to doc:content
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: enable for make-viewer
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agotests: 02-grep failure should not be fatal.
NeilBrown [Sun, 4 Jun 2023 01:59:29 +0000 (11:59 +1000)]
tests: 02-grep failure should not be fatal.

02-grep has been flakey for a while and now it never succeeds.
Fix it a bit so it sometimes passes, and make it non-fatal until I can
fix the problem.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: use extra-text in doc:content
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: use doc:content to scan more quickly.
NeilBrown [Sun, 4 Jun 2023 01:41:12 +0000 (11:41 +1000)]
linecount: use doc:content to scan more quickly.

Rather than calling doc:char repeatedly, use doc:content.  It is faster.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agodoc: fix doc_default_content
NeilBrown [Sun, 4 Jun 2023 01:18:42 +0000 (11:18 +1000)]
doc: fix doc_default_content

We were ignoring ->mark2 (endpoint) and sending a CHAR_RET() rather than
a char.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agorender-format: fix off-by-one in doc:content
NeilBrown [Sun, 4 Jun 2023 01:17:50 +0000 (11:17 +1000)]
render-format: fix off-by-one in doc:content

When an end mark was given we didn't collect the last character.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoformat: handle line-count properly for format2
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: enable async line-counts
NeilBrown [Sat, 3 Jun 2023 02:38:03 +0000 (12:38 +1000)]
linecount: enable async line-counts

When requested, linecounts progress about 300 lines at a time with only
the first 1000 done sync.  The rest happen on a timer.

Don't test the async line count though - it is too hard to match the timing.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: intro option of sync/async counting.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: fix need_recalc()
NeilBrown [Sat, 3 Jun 2023 06:13:25 +0000 (16:13 +1000)]
linecount: fix need_recalc()

I was testing the wrong thing - or freeing the wrong thing.

If a range is small - clear the first mark and discard the second.  Then
from the first to whatever comes next will be recalculated.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: ensure counts are uptodate for goto-line
NeilBrown [Sat, 3 Jun 2023 01:27:56 +0000 (11:27 +1000)]
linecount: ensure counts are uptodate for goto-line

We need fully up-to-date counts for goto.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: optimise when no counting needed.
NeilBrown [Sat, 3 Jun 2023 01:20:51 +0000 (11:20 +1000)]
linecount: optimise when no counting needed.

If a mark wasn't passed, and the pane count is up to date, there is no
need to do anything, so optimise it all away.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agodoc-email: support linecount
NeilBrown [Sat, 3 Jun 2023 00:59:38 +0000 (10:59 +1000)]
doc-email: support linecount

doc-email-view now intercepts linecount requests and ensures they happen
against the view, rather against the raw document.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agodoc-email: be more subtle with default visibility.
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

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: ensure we start a visible beginning of document
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoAlways call CountLines on the focus
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: improve notify:replaced handling
NeilBrown [Fri, 2 Jun 2023 22:25:37 +0000 (08:25 +1000)]
linecount: improve notify:replaced handling

If the region being replaced is large, me might need to discard marks
that are in it.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: simplify count_calculate()
NeilBrown [Fri, 2 Jun 2023 22:04:59 +0000 (08:04 +1000)]
linecount: simplify count_calculate()

There is no need to make a special case of m being after end, because m
is always at the start of the file.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: remove 'start' arg from count_calculate()
NeilBrown [Fri, 2 Jun 2023 09:32:10 +0000 (19:32 +1000)]
linecount: remove 'start' arg from count_calculate()

We always pass NULL for the 'srart' to count_calculate().  So remove all
code that only runs if start != NULL, and remove 'start'.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: don't pass mark to doc:CountLines at startup
NeilBrown [Fri, 2 Jun 2023 09:27:58 +0000 (19:27 +1000)]
linecount: don't pass mark to doc:CountLines at startup

When we create line CountLines pane, we jut want to initialise the line
count.  So don't pass in ->mark.  It is meaningless and is ignored.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: ignore Notify:Clip
NeilBrown [Fri, 2 Jun 2023 09:14:03 +0000 (19:14 +1000)]
linecount: ignore Notify:Clip

We cannot possible get a Notify:Clip message, so don't try to handle it.

Notify:Clip comes from a child, and we don't have any.
The only commands we can get are ones we have explicitly requested from
the doc.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: use a more natural means of registering Notify:Close
NeilBrown [Fri, 2 Jun 2023 09:10:12 +0000 (19:10 +1000)]
linecount: use a more natural means of registering Notify:Close

Rather than overloading doc:Countlines, use the normal doc:request:
to register for Notify:Close.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoline-count: limit ranges based on words and chars as well as lines.
NeilBrown [Fri, 2 Jun 2023 08:40:34 +0000 (18:40 +1000)]
line-count: limit ranges based on words and chars as well as lines.

Increase the gap between markers from 50 to 100 - just because.
Also limit to 1000 words or 10,000 chars, just in case there are
some very big lines.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agopython: change how modules are loaded into the interpreter
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.

Signed-off-by: NeilBrown <neil@brown.name>