[Toybox] generic editor code
David Seikel
onefang at gmail.com
Sun Jan 26 17:26:16 PST 2014
I'm finally getting back to working on my editor. At least for the
next week. I broke this out of the other thread, it should have it's
own.
On Tue, 24 Dec 2013 10:41:39 -0800 ibid.ag at gmail.com wrote:
> On Tue, Dec 24, 2013 at 01:18:46PM +1000, David Seikel wrote:
> > >
> > > I note that patch does something really similar to this.
> > > Maintaining these kind of line buffers is something we've got
> > > code and there might be some opportunities for code sharing. I'll
> > > have to look...
> >
> > This is why I wanted to include sed as one of the various editors I
> > wanted to support in my generic editor code. Less, grep, sed, vi,
> > emacs, etc. all need to deal with line buffers. s/foo/bar/g works
> > in most of the editors, including sed. Lots and lots of common code
> > there. Still on my TODO list to cut it down into easier to digest
> > bits for you, which is like your TODO, it runneth over, several
> > times.
> >
> FYI, there are a few small build fixes I needed:
>
> diff --git a/boxes.c b/boxes.c
> index 5945308..2eb1308 100644
> --- a/boxes.c
> +++ b/boxes.c
> @@ -35,11 +35,11 @@ config BOXES
> */
>
> #include "toys.h"
> -#include "toynet.h"
>
> -DEFINE_GLOBALS(
> +GLOBALS(
> char *mode;
> - long h, w;
> + long h;
> + long w;
> // TODO - actually, these should be globals in the library,
> and leave this buffer alone. int stillRunning;
> int overWriteMode;
Yes, it bit rotted a little. Splitting the long deceleration didn't
seem to be needed. Unless it's a style thing, I think there was a
toybox style change since I first wrote this. I'll be going over the
entire thing and making it pretty and clean soon.
> But for reasons unknown to myself, boxes does not seem to ever exit
> (apart from Ctrl-C; tested with joe and vi modes), I get the
> impression it doesn't save,
Saves and exits fine in the default mcedit / cooledit mode. Joe mode
seems to be broken currently, thought I had it working. For vi and
other editors that can deal with shortcuts for their commands, the
shortcuts are not implemented yet. So the ex mode ":write" and ":quit"
commands work fine, just not ":q" or similar.
> and vi never clears the ":" once you run
> a command of that sort. I'd suspect it got stuck in ex mode, but
> since none of the commands have an effect I can't tell...
> Is that expected behavior at this point?
There's various methods of escaping from ex mode. You can just
backspace out of it, or use Ctrl-[. Ctrl-C should escape, but I'm not
catching that at the moment. It also should escape after a command,
but that's not implemented yet. There are actually two ex modes, but
they are currently treated the same. The temporary one is invoked
by ":", that's the one you can backspace out of, or returns to visual
mode on command completion. The other one is invoked by "Q", it's not
supposed to back out on backspace or command, only the control keys
mentioned above.
Treating the : and Q ex modes differently is a complication. Catching
Ctrl-C is a complication. Command shortcuts is a complication. All
such complications I'll deal with later, but first I need to simplify
it enough so that Rob can accept an initial version. Fixing joe mode
may or may not be a complication, some debugging needed there.
Squeezing it down to manageable by Rob bits might be tricky due to -
On Thu, 27 Dec 2012 06:06:53 -0600 Rob Landley <rob at landley.net> wrote:
> Basically what I'd like is a self-contained line reader. More or less
> a getline variant that can handle cursoring left and right to insert
> stuff, handle backspace past a wordwrap (which on unix requires
> knowing the screen width and your current cursor position), and one
> that lets up/down escape sequences be hooked for less/more screen
> scrolling, vi line movement, shell command history, and so on.
Which is most of the editor already.
--
A big old stinking pile of genius that no one wants
coz there are too many silver coated monkeys in the world.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20140127/689e89da/attachment-0001.sig>
More information about the Toybox
mailing list