Updated 6/5/17 to add term size change and some tweaks to search

I decided to see if I could make a rough emulation of the original rand text editor. I'd used the editor for years and always found the "feel" of the editor to be better than emacs and certainly better than vi. It turns out it only took a couple of weekends to make something that more or less did everything I remembered. Some of the original features like WP mode were to fuzzy in my mind to try to replicate. The basics are there though including multiple windows, alternate files in windows & rectangular get and cut buffers. If your interested, its free for the taking as a GPL program. You can grab the source and a precompiled 64 bit version here. Also available is a version that compiles and runs on MAC. Thanks to Mike O'Brien for the files.
I decided to name it sre, for Stabie's Rand Editor. It is a pity it fell out of existence. It was the grand-daddy of all full screen editors. The editor has a very small memory footprint of about 1.5M on a 32 bit machine (ARM or i86) and 4.5M on a 64 bit one. This compares to vim's 4.5M 32 bit machine footprint and 22M 64 bit footprint.

Note I have compiled and run this on the raspberry pi as well, so it works on ARM as well as x86 architectures.

Update 3/6/2011:
Added split and join commands along with a simple way to define your own keys. I figured anyone who really uses this editor will want their own keys, and I had to have split & join after a bit of use.

Update 3/13/2011:
Added a command to "tag" to a function if a tags file is available. Use the env var TAGPATH to search multiple directories. Also added a command to "unload" a file from a window's edit queue. With tagging it can be especially useful to limit the windows alternate files. Fixed a bug in rectangular cut as well.

Update 3/26/11:
Fixed a bug in delete char if the line was not in memory. Added ability to open up to 4 files when starting the editor by specifying additional files as arguments. Fixed a bug where the file modified flag was not set if lines were cut using the mark command.

Update 4/19/11:
Check if file is RO and do not allow modification if it is. Copy the file access mode when saving file to preserve exec mode etc. Preserve insertmode and search key in init file Add a variable bell, to control if a beep is made on errors. (set bell 0, set bell 1 on command line) Add new command "match" assigned to keypad key "5", which matches [], {}, and (). Just put cursor over the [], {}, or () and press the 5 keypad key. The matching bracket, brace or paren will be the new cursor location. A matched failed message is returned if no match is available.

Update 6/2/11:
Add "range" command to limit editing to a range of lines within a file. Easiest way to use is to first set a mark over the beginning brace of a function, hit ^G, then keypad 5 to jump to the matching end brace of the function, then ^space to get command prompt, then enter range, and the marked area is now the range of the cursor. All commands obey the range with the exception of a goto. So a goto 1 will always goto line 1. Turn off the range with the -range command. You can have multiple windows open. The range applies to only the specified window and only the file active when range is enabled.

Update 6/17/11:
Fix bug that could cause a crash when opening/cutting/pasting lines. The bug occured from the current line optimization.

Update 4/20/12:
Fix bug in cut command. Add new repl /xxx/yyy/ command. Also fix ix minor nuisance of hitting escape by accident requiring entering some keys to simulate a multi-byte function key.

Update 5/10/13:
Fix bug in repl when replacement string was of the form /string/string1/ and fix problem in search when window was shifted left and search string was under the cursor. Add new command "run unixProgram opts" where program unixProgram is run with opts and stdin to the program is the current line (or marked region) and the current line (or marked region) us replaced by the stdout of unixProgram. The line(s) replaced are stored in the new "unrun" buffer. To retrieve the old text use the command unrun. Note unrun does not delete the output from the unixProgram. A simple example is run ls where the current line will be replaced by a listing of the files in the current directory.

Update 6/14/13:
Search command can now search either in case insensitive mode or a glob-like mode. You toggle the searchmode with ^Q or the searchMode command in the command field.

Update 11/29/15 Tweaked the setup terminal code to initially use ioctl call to get window width/height, then fallback to the old method. Some terminals (UXTERM) were not working with the old method

Update 9/1/16:
A new MAC compliant version of the code is available. Just pick the sre_mac.tar.gz version.

Update 6/5/17:
Updated search to include a "word" mode. Word mode in a search requires the search key to be delimited by word delimiters. This allows a search for a variable say "i". In literal search mode a search of "i" would get many hits. In word mode the "i" must be delimited by characters such as BOL, EOL, []. etc. To make this more useful, a word mode has been established so that the set of delimiters is easily switched between "english" and "C". You could easily modify the delimiters in srch.c This change also effects how a "word" is determined under the cursor. So in "C" mode, with the cursor over the i in the string array[i], the key sequence control+space control-R would forward search for the string i, but in english mode it would search for the string array[i] since in english mode, the [] characters are not considered delimiters. Also in in this rev is limited support for changing the terminal size. Just don't make the window so small subwindows disappear.

Update 3/16/19:
This release adds just one new feature, but is a major change. The latest experimetal version threads the read of large files which by default are files with over 10K lines. You can look at the file (up to the 1st 10K lines) but the file is locked to read mode while the rest of the file is loaded. For large files you just need to review, it can be handy.

Update 6/3/20:
This release makes one change. For some reason on the latest pi release, using getc to pick up input does not work. I switched to a read_getc which uses read to grab the next character from the terminal. This also required the addition of some flushes to stdout. This version also works on x86 platforms, so patch is universal. I guess getc had some side effects I was not counting on, so switching to plain read works better. current version