]> git.neil.brown.name Git - edlib.git/log
edlib.git
2 years agodoc-list: use embedded data
NeilBrown [Tue, 4 Jul 2023 04:41:31 +0000 (14:41 +1000)]
doc-list: use embedded data

doc-list panes now embed the data.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agodoc-dir: switch to embedded data
NeilBrown [Tue, 4 Jul 2023 04:29:56 +0000 (14:29 +1000)]
doc-dir: switch to embedded data

the pane or doc-dir now embeds the data.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolog: switch to embedding data in pane
NeilBrown [Tue, 4 Jul 2023 04:16:56 +0000 (14:16 +1000)]
log: switch to embedding data in pane

log panes now have data embedded.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agocore-editor: embed ed_info in the struct pane
NeilBrown [Tue, 4 Jul 2023 03:58:17 +0000 (13:58 +1000)]
core-editor: embed ed_info in the struct pane

This makes all content of ed_info just one pointer dereference away from
any pane.  We can start putting content that is current global, into
ed_info.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoSupport inline pane data.
NeilBrown [Tue, 4 Jul 2023 03:14:15 +0000 (13:14 +1000)]
Support inline pane data.

If a NULL data pointer is passed to __pane_register(), then a larger
memory allocation will be made to hold both the pane and the data.

If a type is defined with PANE_DATA_TYPE then that will be the size
passed to __pane_register by pane_register().

Similarly DOC_DATA_TYPE can give a type for a document.  The "struct
doc" must appear first in this type.

If PANE_DATA_TYPE is defined, then "core-pane.h" must be included after
the type has been declared, which will usually be after "core.h" is included.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoAlways handle pane_register failure immediately.
NeilBrown [Mon, 3 Jul 2023 22:38:09 +0000 (08:38 +1000)]
Always handle pane_register failure immediately.

Rather then
 p = pane_register();
 if (p)
     ....

Use

 p = pane_register();
 if (!p)
    return FAIL
 ...

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoInclude some include files where there are needed in include files.
NeilBrown [Mon, 3 Jul 2023 22:30:28 +0000 (08:30 +1000)]
Include some include files where there are needed in include files.

This makes it easier to move includes around in .c files.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoIntroduce point_new()
NeilBrown [Sun, 2 Jul 2023 12:03:38 +0000 (22:03 +1000)]
Introduce point_new()

point_new() is vmark_new() for MARK_POINT.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoIntroduce mark_new()
NeilBrown [Sun, 2 Jul 2023 12:01:04 +0000 (22:01 +1000)]
Introduce mark_new()

mark_new() is vmark_new() for MARK_UNGROUPED.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: allow attachment to a viewer stack.
NeilBrown [Sun, 2 Jul 2023 11:42:57 +0000 (21:42 +1000)]
linecount: allow attachment to a viewer stack.

Sometimes we want linecount to count lines in a view, not in a document.

Instead of having the view pretend to be a document for linecount,
change it to explicitly support attachment.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: fix mark used for 'goto'.
NeilBrown [Sun, 2 Jul 2023 11:39:47 +0000 (21:39 +1000)]
linecount: fix mark used for 'goto'.

The mark passed to CountLines/goto:line as 'mark' is handed to
doc:GotoLine as 'mark2', but that function expects 'mark'.

This works as the doc: function always gets point for mark if nothing
else is given.  But it is wrong. Let's fix it.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoview: fix scroll bar on directories etc.
NeilBrown [Sun, 2 Jul 2023 11:31:56 +0000 (21:31 +1000)]
view: fix scroll bar on directories etc.

When linecount is attached to a view, as with lib-format (directories)
and emails, the location of the scroll bar handle is wrong.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoDisable pane_too_long() with edlib_timing_allowed = False.
NeilBrown [Sun, 2 Jul 2023 10:29:24 +0000 (20:29 +1000)]
Disable pane_too_long() with edlib_timing_allowed = False.

edlib_timing_allowed = False
now disables pane_too_long() too.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: run the on-idle event on the linecount pane.
NeilBrown [Sun, 2 Jul 2023 10:26:07 +0000 (20:26 +1000)]
linecount: run the on-idle event on the linecount pane.

We currently queue the on-idle event on the document.  That is untidy.
The event belongs to the linecount pane, so that is where it should run.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoemacs: allow :C-q to be repeated when a unicode name was found.
NeilBrown [Sun, 2 Jul 2023 05:33:57 +0000 (15:33 +1000)]
emacs: allow :C-q to be repeated when a unicode name was found.

If we found a unicode char with a given name, there might be another
one.
So allow the command to be repeated.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoAdd lib-unicode-names and use it for emacs :C-q
NeilBrown [Sun, 2 Jul 2023 05:14:58 +0000 (15:14 +1000)]
Add lib-unicode-names and use it for emacs :C-q

:C-q can now be given a unicode name from NamesList.txt and it will
insert the first match - which might not be the one you want.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agosearch: various fixes for searching a string in a string
NeilBrown [Sun, 2 Jul 2023 05:11:28 +0000 (15:11 +1000)]
search: various fixes for searching a string in a string

I guess I hadn't tested this, but searching for a string in a string
didn't work for various reasons.

Also allow max length to search to be given.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoUse XDG standard to find config (and data) files.
NeilBrown [Sun, 2 Jul 2023 01:31:42 +0000 (11:31 +1000)]
Use XDG standard to find config (and data) files.

Provide an interface to search for config and data files in appropriate
XDG locations.  Enhance this by looking in the directory that contains
the main shared library - after HOME but before system locations.
Use this for config files.  This removes the need to use ARGV[0]
to find the initial ini file.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agorender-lines: fix vline positioning.
NeilBrown [Sat, 1 Jul 2023 00:42:06 +0000 (10:42 +1000)]
render-lines: fix vline positioning.

When we want to position the cursor line precisely, we need
consume_space to consume at most one line each top a bottom else we
might miss the target line.

Also document how find_lines() works with a bit more detail.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agorender-lines: don't change y_pre or y_post after found_start/end set
NeilBrown [Sat, 1 Jul 2023 00:35:14 +0000 (10:35 +1000)]
render-lines: don't change y_pre or y_post after found_start/end set

To be able to achieve precise positioning on the display (e.g.  with
vline) we need to stop changing y_pre or y_post once found_start or
found_end are set - respectively.

So when we hit EOF and set a 10% y_post, we should NOT set found_end
yet.

This shows an off-by-one error in vline calculation which was previously
hidden as consume_space() would always move us to the start of that line.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agohistory: support searching history of entries
NeilBrown [Fri, 30 Jun 2023 01:16:02 +0000 (11:16 +1000)]
history: support searching history of entries

C-S searches forward, but the more useful is C-R which searches
backward.

Search doesn't wrap - I wonder if it should.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agopygtk: discard new_display2
NeilBrown [Wed, 28 Jun 2023 21:01:46 +0000 (07:01 +1000)]
pygtk: discard new_display2

new_display and new_display2 are now sufficiently similar that we can
merge them.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolib-glibevents: catch errors from callbacks.
NeilBrown [Wed, 28 Jun 2023 21:00:45 +0000 (07:00 +1000)]
lib-glibevents: catch errors from callbacks.

The on-idle and poll callbacks didn't catch errors, would cause be
fatal.

Also change on-idle callbacks to not return errors, on Efalse.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agodisplay-xcb: merge display_xcb and xcb_new_display
NeilBrown [Wed, 28 Jun 2023 20:44:50 +0000 (06:44 +1000)]
display-xcb: merge display_xcb and xcb_new_display

These two function are largely equivalent, so xcb_new_display does a
couple of step that are not harmful for display_xcb.

So discard display_xcb and just use xcb_new_display.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoFinish attach-display-foo commands with doc:attach-view
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agocall editor:activate-display from the display code.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoserver: don't hold reference to the display pane.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoadd window:set: and use it to set attributes for displays.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agohandle Display:close in window-core
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agointroduce core-window.c
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoinput: don't use pane_notify to send window notification.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agomacro: don't walk up tree to "find" input.
NeilBrown [Wed, 28 Jun 2023 06:52:35 +0000 (16:52 +1000)]
macro: don't walk up tree to "find" input.

We can send "Keystroke" to the focus and it will find the right target.
We don't need to "find" the target first.  Doing so is fragile.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoMove parse_ini() into a separate include file.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agocompose: run notmuch-addr asynchronously.
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.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoconfig: allow initial panes to be set in config file.
NeilBrown [Tue, 27 Jun 2023 22:35:47 +0000 (08:35 +1000)]
config: allow initial panes to be set in config file.

Changing the initial panes for a display give lots of control to the
user, and particularly will allow alternate key mapping to emacs.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoSplit module list into a separate ini file
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.

Signed-off-by: NeilBrown <neil@brown.name>
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>