On 06/28/2012 05:31 PM, David Seikel wrote:

Coming late to this party, but..

More importantly, the infrastructure is taking shape well.  So right
now making a really cut down microemacs, wordstar, nano, or whatever is
as simple as providing a different key to command mapping array, then
calling the editLine() function.  New commands for a more feature full
editor should be easy to add.

I wonder if it's really that simple? Most of the discussion I've seen here seems to focus on how you display the text on screen, but that's only part of the issue. Pagers like less simply read files from disk and put the results on screen, letting you scroll forward and backward. Less was popular when it first came out because it simply started to read from disk and put up what it had, which could be a lot faster than using an editor like vi in read-only mode and needing to wait for the whole file to load.

But when you want to *edit* files, you start running into questions of how you will store the text to be edited in memory. Storing it as one big blob may not be feasible when you are dealing with large files, and you have issues of how you handle things like copying, moving or deleting blocks.

Some editors have used linked lists or doubly linked lists, where the list is an array of lines. What happens if the file you want to edit is one *very* long line? Current practice seems to be using the "buffer gap" technique. An outfit called Blue Mug software did a research paper on writing a word processor for handheld devices that might be a useful reference. See http://goo.gl/bJtPt

Additional documentation that might be useful is here:
http://texteditors.org/cgi-bin/wiki.pl?DesigningTextEditors

Something else to look at might be Albrecht Kliene's e3 editor. e3 is open source and cross platform, with X86 versions available for Linux, FreeBSD, NetBSD, OpenBSD, Win9x, QNX, Atheos, BeOS(TM), DOS and ELKS, and a version for ARM as well. Significantly, they're written in NASM Assembler. There is also a generic C version for other platforms.

e3 emulates a subset of the emacs, nedit, pico, vi, and WordStar command sets. Which emulation it uses is determined by the name it is called by, and the usual installation practice is to hard link or symlink it to the desired names. The 64 bit Linux executable is a whopping 17K in size here.

(Under DOS/Windows, there is a 4K stub and a 20K overlay. On a 16 bit system it's possible to use just the 4K stub, which has WS keybindings and a 64K file size limit.)

e3 is at https://sites.google.com/site/e3editor/

Key bindings in vi mode:

<ESC>                   enter cmd mode
h,j,k,l,+,-,<Ret>,<SPC> move by chars&lines
^B,^F,^D,^U             move by [half]page
$,0,^,w,b,e,H,L,M,z.    move in line/screen
/,?,G                   srch fwd/bwd, go EOF
ma,'a                   set/go marker a
x,X,<Del>,dw,D          dele chr,word,EOL
S,C,dd,d'a,yy,y'a       subst,change,dele,yank
p,P                     paste
A,a,I,i,<Ins>,O,o       enter ins.mode
R,r                     enter ovw.mode,ovw.chr
J                       join lines
ZZ,^Z, u                save&quit,suspend, undo!
;,#                     E3 SPECIAL: set edit mode,calculate
:w,:wq,:x,:q,:q!,:e     ex mode:save,quit,save_as,edit other
:0,:$,:<line#>          ex mode:go BOF,EOF,line
:h                      ex mode:help
:<other cmd>            pipe buffer thru 'sed'


Key bindings in WS mode:

Files:  ^KR Insert      ^KS Save        ^KX Save&Exit   ^KQ Abort&Exit
        ^KD Save&Load   ^KP Pipe buffer thru 'sed'

Blocks: ^KB Start       ^KK End         ^KC Copy        ^KY Del
        ^KV Move        ^KW Write

Search: ^QF Find        ^L  Repeat      ^QA Srch&Repl

Move:   ^E  Up          ^X  Down        ^S  Left        ^D  Right
        ^R  Page Up     ^C  Page Dn     ^W  Scroll Up   ^Z  Scroll Dn

Quick-  ^QE Wnd Top     ^QX Wnd Bott    ^QS Home        ^QD End
-Move:  ^QR BOF         ^QC EOF         ^QB Blk Begin   ^QK Blk End
        ^F  Next Word   ^A  Prev Word   ^QI Line#       ^QV Last Find

Delete: ^T  Word        ^Y  Line        ^H  Left        ^G  Chr
        ^QY Line End    ^QDel,^QH Line Beg

Other: ^KM Set mode ^KN Numerics ^KZ Suspend ^U Undo


Key bindings in EMACS mode:

Files:  ^X^C Exit       ^XI  Insert     ^X^S Save       ^X^F Load New
        ^X^W Write new  ^X^H Help       ^X^P Pipe buffer thru 'sed'

Move:   ^P   Up         ^N  Down        ^B   Left       ^F   Right
        altV Pg up      ^V  Pg down     altB Left word  altF Right word
        ^A   Home       ^E  End         alt< BOF        alt> EOF
        altG Go line#   ^L  Center Pos

Search: ^S Find fwd     ^R Find bwd     alt% Search&Replace like WS

Buffer: altW Copy       ^Y Yank         ^<SPC> Mark     ^X^X Xchg Mark/Pt

Delete: ^K Line         ^W Region       ^H Left Chr     ^D This Chr

Other:  ^O Open line                    ^I Ins Tab      ^Q Quoted Ins
        ^M NL           ^J NL+indent    altX Set edit mode
        ^X^N Calculate                  ^Z Suspend      ^_  Undo


Key bindings in PICO mode:

Files:  ^XN ExitNoSave  ^XY Exit+Save   ^XL Save+Load New File
        ^O  Save        ^S  Save as     ^R  Read

Move:   ^P  Up          ^N  Down        ^B  Left        ^F  Right
        ^Y  Page up     ^V  Page down   ^QN Next word   ^QP Previous word
        ^A  Home        ^E  End         ^QS Start       ^QE EOF
        ^QT Top screen  ^QB Bottom scr  ^QL Line #      ^QF last Find

Search: ^W  Where is    ^T  Search&Repl ^JT Repeat Search & Replace

Delete: ^H  Left char   ^D  This char   ^K  Kill line/region
        ^JW Word        ^JL Line end    ^JH Line begin

Other:  ^U  Unkill      ^G  Help        ^^,^L,^<SPC> Mark region
        ^QM Set Edit Mode               ^JP Pipe buffer thru 'sed'
        ^QC Calculate                   ^Z Suspend      ^QU Undo


Key bindings in NEDIT mode:

Files:  ^QN Exit_NoSave ^QY Exit&Save   ^QL Save&Load new
        ^S  Save        ^W  WriteTo=SaveAs
Move:   ^L  Line#
        ^F  Find        ^R Search&Replace (like WS)
        ^G  Go repeat last ^F,^R

Select: ^<SPACE> begin&extend by cursor keys (like Emacs)
        ^A  All buffer
        ^X  Cut         ^C Copy         ^V Paste

Other:  ^E  Set edit mode
        ^K  Calculate
        altH Help       ^Z Suspend      ^U Undo


_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to