Re: [dev] [edit] Introducing edit, a simple text editor

From: Arthur Jacquin <arthur_AT_jacquin.xyz>
Date: Sun, 22 Oct 2023 11:12:09 +0200

> This looks pretty nice, I also like the fact that bindings
> are easily configurables.
> I have a few patches that I'll propose later after more usage.

Thanks for your nice reply! Can't wait to see your patches ;)

> One thing that I miss there though, as a luser, is editing history.
> To me, undo-ing is very handy. I haven't looked
> at the data structure yet, and I get that this isn't implemented
> by design, but do you recall that would something complex to add?

I understand that some people may miss the undo feature, as it's so
common in others tools. I've given it a lot of thought when designing
edit. As you pointed out, undo-ing is tightly linked to the data
structures, so leaving it aside had major implications on the
developement.

Undo-ing is clearly a non-trivial feature. Most operations are not
injective, meaning one cannot deduce the previous content only from
the new, modified content. Thus implementing undo-ing recquires
storing and managing more content. How much complexity it adds very
much depends on the data structures.

vis[0] (after a quick inspection) seems to have found a good balance
between simplicity and compatibility with features such as undo-ing.
I felt that going the undo path would result in a cheap and
non-innovative vis imitation.

Besides, I found out I was saving so frequently in vim that undo-ing
was most of the time equivalent to reloading. Going without undo-ing
was not a real issue for me.

So I took edit as an opportunity to explore how much complexity can be
stripped off by not implementing the undo feature. There are very few
defined structures. Content is simply stored line by line in a doubly
linked list, as UTF-8 strings:

typedef struct Line { // doubly linked list of lines
     struct Line *prev, *next;
     int line_nb; // between 1 and nb_lines
     int ml, dl; // length in memory, on screen
     char *chars; // content (UTF-8, NULL-ended
string)
} Line;

So that's for the the explanation, but to be honest your mail
triggered me to think of undo-ing again. As I don't intend to change
the central data structures, undo-ing won't be as good as in vis, but
I have a few ideas... I'll come back to you if I have some news.

[0]: https://sr.ht/~martanne/vis/
Received on Sun Oct 22 2023 - 11:12:09 CEST

This archive was generated by hypermail 2.3.0 : Sun Oct 22 2023 - 11:12:33 CEST