mvi & svi text editor
Rayman
Posts: 14,648
Was able to compile this simple version of vi with FlexSpin C:
https://github.com/byllgrim/mvi
Used curses.h that made to run Rogue game and mostly worked without modification.
Only thing really missing was a cursor.
Here, I just changed the colors of the current location to be block cursor.
Seems to be in a kind of working state. Gets messed up by tabs, have to fix that...
Also, doesn't seem to behave properly when you go beyond the bottom of the screen or off to the right.
Haven't tried saving yet.
But, it's an on chip text editor
Comments
Cool, how big was the binary with the editor?
Here's the current code with binary. It's 224 kB. A lot of that is reserved heap. Maybe it needs more, maybe less, not sure yet.
This is in the "this might actually work" state at the moment. Probably needs a lot of work.
It is supposed to handle UTF-8. I think that means unicode. Might have to try that...
This is configured for the Eval board with A/V accessory on basepin 0 and the file "hello.txt" on the uSD card of the Eval board.
You control it at the moment via computer keyboard and the FlexProp terminal window.
The controls are the same as the original, although I haven't tried them all:
I just got the svi (more advanced version) to run. https://github.com/byllgrim/svi
It adds some useful things like searching:
Tested out search and write to file, appears to work (although search is case sensitive).
So, really just need to fix tabs (or replace them with spaces) to have a working editor...
To test this, just run this svi.c in place of mvi.c of the above zip.
@Rayman , good work on porting the vi code to the P2. I have to try it out when I get a chance.
I had three different editors that ran under spinix on the P1. They were ted, ed and vi. ed is the standard unix line editor. I added a Vn command to ed that would print out "n" lines every time a command was entered. ted is a simpler version of ed with just a few basic commands. My vi editor was fairly complete. It supported yank and push, searches and string replacement. According to my documentation it also supported most of the commands when in the ex mode. It was written in C, but I used CSPIN to convert it to Spin for spinix. I made some attempt to get it to run on the P2, but I don't recall how far I got. I'll have to take a look at it again. Oh, and it supported three different terminal types -- PST, ANSI and dumb terminal.
@"Dave Hein" Looking at your P1 code may have been an easier way to do this...
But, I'm also doing this to learn how to do things in low level C and how other C code from Github works...
I may take this and build it into an editor for my 1080p tile driver with USB keyboard and mouse support.
(or, I may not).
Got a little hung up on UTF-8 and unicode such. Think I understand it now, at least a little.
Think my approach would be to convert the input file from multi-byte to a simple 8-bit representation for use with the P1 font from the tile driver.
This simplifies the code a lot. It could be saved back as multi-byte though as an option.
This would just lose any characters that aren't in the P1 font.
tabs mess everything up too... Might just convert tabs to spaces...
and also have to deal with \n and/or \r..
The \n and/or \r thing is fairly easy to handle. When you read in a file you can keep track of which format it uses, and then use the same format when you write it out. The editor's internal representation can use a different format, such a just null-terminated strings without any \n's or \r's.
Handling tabs is a messing thing. You could assume tabs are aligned on every eighth columns, but that may not be how the file was created. I think in my editors I treat tabs as space, but I might be mistaken about that.