[Toybox] [PATCH] Ex commands in vi.c slightly improved + Error Fix

Oliver Webb aquahobbyist at proton.me
Sun Sep 24 22:45:26 PDT 2023


I have been changing the ex command processor in vi.c to have things like line
ranges, commands like g, v, d, and p (and s but I haven't gotten to
even starting that yet), System commands and the ability to pipe text into them
and put it back into your file, etc. I have a half finished version of line range
implementation. But rather then submit that half finished version, I'll just submit
the things required for that to work, along with some other small things

The main thing is that strncmp() or just cmd[num] == 'char' (To find a command at a specific location)
be used instead of strstr() (Which finds any mention of the string in the command)
Commands like ":%s/wq!/set nolist/g" would break otherwise.

I added the ability to jump to lines with :[NUMBER], go to the bottom of the file with ":$" and delete lines with the d command,
I know that these commands can be replicated in normal mode (the d command just calls run_vi_command("dd"))
but when combined with things like the g command that I plan to submit in later patches
They can add some power to the text processing capabilities of the editor
(Example: ":g/\s*#/d" to delete all lines with only "#" style comments, ":%d" to clear the buffer)

Other then that, I fixed a error that happens whenever ":w " is inputted by changing
xrename() to rename(), preventing a early exit without properly setting the terminal
back to normal beforehand.

Last thing I did was replacing stuff like 0x20 with ' ', 0x0A with '\n', etc. To make it more clear we
are checking for certain characters. '\t' Conveys more info then 0x09 anyways even _if_
you know the ASCII control codes and their hexadecimal values anyways.
And stuff like "0x4" conveys nothing by being hexadecimal. 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vi.c-Added-line-gotos-in-ex-mode-Replaced-Hex-Values.patch
Type: text/x-patch
Size: 5256 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20230925/4dc23c55/attachment.bin>


More information about the Toybox mailing list