Anyone write a text editor for the Propeller ?
Bean
Posts: 8,129
I need a simple text editor for PEBasic and I didn't see one in the OBEX.
So I thought I would whip one up in spin, but it's not as easy as I thought it would be.
Has anyone written one ?
Bean
So I thought I would whip one up in spin, but it's not as easy as I thought it would be.
Has anyone written one ?
Bean
Comments
http://forums.parallax.com/showthread.php?112344-Coming-soon-to-a-Prop-near-you-PrEditor&highlight=Editor
Where has he been lately?
(comments say so, just want to make sure.)
Another question... This is for editing over serial connection to a terminal program on a PC, right?
It can't use connected VGA and keyboard (?)
This showed up in your "similar threads" - it might give you a skeleton to incorporate into PEBasic.
This version only works with a serial port. I was working on an 80x24 character VGA driver a few months ago, but I put it aside for a while. I hope to get it working with VGA and a keyboard in the future.
Any pointers on changes to use vi without SD card?
Thanks.
I think Phil already adapted it for VGA-basic? look there too...
Enjoy!
Mike
-Phil
I need something really small though. Maybe I'll try that "Split-buffer" method that was mentioned.
I'm using the vga_hires_text because I need to support 640x480. This gives me an 80x40 character display.
I'll post whatever I get working.
Bean
Uses Propeller Demo board, VGA and Keyboard
Comments welcome...
Bean
Traditional Linux/Unix editors such as Vi and Nano may be a bit annoying to the uninitiated, but Nedit will do a generic ASCII file in a simple and direct manner. I imagine the C-code could be a useful place to start even if you don't use the whole thing.
http://www.nedit.org/
OR take a look at Nano, it is not an X-Windows editor - just generates ASCII for a Terminal window in Linux.
http://www.nano-editor.org/dist/v2.2/faq.html#1.3
http://mintaka.sdsu.edu/reu/nano.html
Edit: I managed to run it with keyboard driver from femtobasic. It works
Still, it seems that if you have an SD card in the system, you could just use HUB ram as a change buffer with the original file on SD card. Then, every once in a while, write the updated file to SD and clear the change buffer... Then, you could edit arbitrarily large files (right?)
I'm intrigued - why do you need a Text editor in a Prop ?
Is this as a Source Code editor for a Basic (or similar) ?
So you are targeting something like the first Turbo Pascal, which I think included Editor/Debug/Compiler in ~39K ?
Might be a tad tight on a Prop 1, but certainly doable on a Prop 2.
-Phil
Yes for an embedded BASIC for the Prop1.
Needs to run on the Propeller Demo board, so only 32K EEPROM and no SD or SRAM. This is why it must be a very small editor (small in code space terms).
Something like femtoBasic, only (hopefully) much faster and more modern. Closer to PBASIC 2.5.
Bean
Specifically, I'd like to be able to edit all of the Prop Tool Library files on the Propeller...
I see two problem:
1. Some of these files are >100 kB (much greater than HUB RAM) and
2. Some of these are in Unicode and I'd also like to use Sphinx
I like the split-buffer approach, but I think that is only viable for small text files or with external RAM.
So, the approach I have in mind is to use a list of pointers to lines.
The pointers will either be to the original file data on SD card, or to modified lines in HUB RAM.
So, there will be some limit to the amount of edits possible. The the limit is reached, the file will have to be
saved to SD card and then editing can start again. I'd need some temporary file at this point so as not to overwrite the original.
Problem #2 may not be so bad because I think the Prop tool only allows certain unicode characters. I can easily make a map to
translate these characters into ascii codes. I think I have a font that can show these special characters using a Parallax code page.
If this is true, then I can either save to ascii before calling Sphinx or save back as unicode.
And here .. contains some nice ASCII arts that describe the gap-buffer: http://forums.parallax.com/showthread.php/118487-GAP-Buffer-Needed-functions-...and-Display-Portability-Thoughts?highlight=gap-buffer
File editing in Preditor works like that:
There is a SWAP-file which contains the gap-buffer
Load the file into the gap-buffer
Do the editing
When done, save the text from gap-buffer back to the file
Also with gap-buffer a list of linestarts helps a lot. The list can also be created in SWAP-file in gap-buffer style, so that you don't run out of HUB-RAM when editing huge files.
Maybe implementing the HUB line buffers each as a split buffer.
MagIO2, that gap buffer looks like a refinement of the split buffer. It would still require a lot of RAM to edit a large file, right?
Looks like you were going to do it by writing back to SD every time the cursor moved to a new line, is that right?
It just occurred to me that when my HUB line buffers get full, maybe I can append them to the end of the SD file that I'm editing. Need to see if I can then simply resize the file, if I don't want to save the edits... Or, maybe I'll create a new file just for the temporary edits. I think fsrw will let me open two files for reading at the same time. So, my doubly-linked list could point to original file on SD, scratch file on SD, or HUB...
This means scrolling forward, insert a character, scrolling backward, inserting a character, scrolling forward, insert ..... is the worst case scenario which would write each sector after you scrolled through it.
But the same vMem functions could also be used with a SPI RAM-Driver, which still would make the Editor code easier, as the whole SWAP-stuff is separated in the vMem-code. The editor would simply work on a linear huge address-space.
I was thinking that one thing that would be hard to do is select a large block of text with the mouse and then cut and paste somewhere else...
But, maybe the copy or cut operation could just create a file on SD called "clipboard.dat" that held the data...
If it were used, it would then be appended to the scratch file first...
For cut and paste, just reserve another section in the swap-file.