Pages: 1
|
 |
|
Author
|
Topic: A more useful editor (Read 2885 times)
|
Giant
Member
 
Karma: +0/-0
Offline
Posts: 10
|
Hello. I am new to retro, and I am all for minimalism... but I do think that a more usable editor would completely change my life. I can't see why I would use anything else to develop software, quite frankly, as I've had it with everything else.
Now this is a little tricky. A minimal environment with a clunky user interface is completely useless (see ColorForth). On the other hand, retro's 'edit' is a bit too silly for real-life programming.
I envision a simple cursor-oriented block editor. Is there anything like it, or do I have to write one? I don't mind, just don't want to waste time...
Thanks, and apologies for my possible ignorance.
|
|
|
|
|
Logged
|
|
|
|
Charles Childers
Administrator
Sr. Member
    
Karma: +2/-0
Offline
Posts: 745
|
I don't consider red (the editor in RetroForth) to be clunky, but then again I've been using it (in various forms) for over four years. So I could be a bit biased. It's the default editor in RetroForth since it proved to be very small, and still provided enough useability for real work. (Indeed, I seldom use other editors to edit my forth code)
I am in favor of a more interactive editor, especially since more people would be able to use it effectively. Line oriented editors aren't for everyone. I just haven't been able to find the time to work on one that's easily adaptable for all ports. Since I use a wide variety of operating systems on a daily basis, this is a must for me.
If you're willing to take on the challenge, you might want to look at http://forthworks.com/vibe.rf for a possible starting point. It's a partial port of Sam Falvo's VIBE editor to RetroForth. It's not really complete enough to use yet, but it could probably be brought to a working state without too much hassle.
|
|
|
|
|
Logged
|
|
|
|
Charles Childers
Administrator
Sr. Member
    
Karma: +2/-0
Offline
Posts: 745
|
Here's the most recent version of that code. While it's still incomplete, bits and pieces of it are operational in this copy:
| We need: | : 2* : min : max : update ; : at-xy : >= : = : spaces : <= : +! ;
| Quick fillin, flesh out further! : page home ;
( Editor State )
1 variable: scr 0 variable: x 0 variable: y 'c variable: mode
create wordname 5 1, '$ 1, '$ 1, 0 1, 0 1, 0 1,
( Editor Display )
: mode. 63 0 at-xy mode @ emit ; : scr. 0 0 at-xy ." Block: " scr @ . ." " ; : header scr. mode. cr ; : 8-s ." --------" ; : 64-s 8-s 8-s 8-s 8-s 8-s 8-s 8-s 8-s ; : border space 64-s cr ; : row dup 64 type 64 + ; : line ." |" row ." |" cr ; : 4lines line line line line ; : 16lines scr @ block 4lines 4lines 4lines 4lines drop ; : card 0 1 at-xy border 16lines border ; : cursor x @ 1+ y @ 2 + at-xy ; : screen header card cursor ;
( Editor State Control )
: insert 'i mode ! ; : replace 'r mode ! ; : cmd 'c mode ! ;
: bounds scr @ 0 max 65535 min scr ! ; : prevblock -2 scr +! bounds ; : nextblock 2 scr +! bounds ; : toggleshadow 1 scr @ xor scr ! ;
( Editor Cursor Control )
: flushLeft 0 x ! ; : boundX x @ 0 max 63 min x ! ; : boundY y @ 0 max 15 min y ! ; : bounds boundX boundY ; : left -1 x +! bounds ; : right 1 x +! bounds ; : up -1 y +! bounds ; : down 1 y +! bounds ; : beep 7 emit ; : nextline y @ 15 <if flushLeft down then ; : next x @ 63 =if nextline ;; then right ;
( Editor Insert/Replace Text )
: 64* 2* 2* 2* 2* 2* 2* ; : where scr @ block swap 64* + swap + ; : wh x @ y @ where ; : eol 63 y @ where ; : place wh c! update next ; : -eol? x @ 63 ; : openr wh dup 1+ 63 x @ - move ; : openRight -eol? 0 <>if openr then ; : inserting? mode @ 'i ; : chr inserting? =if openRight then place ;
( Editor Commands: Quit, cursor, block, et. al. )
: $$c51 drop 0 20 at-xy r> r> drop >r ; | Q -- quits main loop : $$c30 drop flushLeft ; | 0 : $$c69 drop insert ; | i : $$c49 drop flushLeft insert ; | I : $$c52 drop replace ; | R : $$i1B drop cmd ; | (escape) : $$c68 drop left ; | h : $$c6A drop down ; | j : $$c6B drop up ; | k : $$c6C drop right ; | l : $$c5B drop prevblock ; | [ : $$c5C drop toggleshadow ; | | : $$c5D drop nextblock ; | ]
( Editor Backspace/Delete )
: padding 32 eol c! update ; : del wh dup 1+ swap 63 x @ - move ; : delete -eol? <if del then padding ; : bs left delete ; : backspace x @ 0 >if bs then ;
( Editor Carriage Return )
: nextln eol 1+ ; : #chrs scr @ block 1024 + nextln - 64 - ; : copydown y @ 14 <if nextln dup 64 + #chrs move then ; : blankdown nextln 64 32 fill update ; : splitdown wh nextln 2dup swap - move ; : blankrest wh nextln over - 32 fill ; : opendown copydown blankdown ; : splitline opendown splitdown blankrest ; : retrn inserting? =if splitline then flushLeft nextline ; : return y @ 15 <if retrn then ;
( Editor Wipe Block )
: msg 0 20 at-xy ." Are you sure? (Y/N) " ; : valid? dup 'n = over 'y = or ; : uppercase? dup 'A >= swap 'Z <= and ; : lowercase dup uppercase? 0 <>if $20 xor then ; : validkey repeat key lowercase valid? until ; : clrmsg 0 20 at-xy 64 spaces ; : no? msg validkey clrmsg 'n ; : ?confirm no? =if r> drop then ; : wipe ?confirm scr @ block 1024 32 fill update 0 x ! 0 y ! ;
( Editor Commands: backspace, delete, et. al. )
: $$i04 drop delete ; | CTRL-D : $$i08 drop backspace ; | (bs) : $$i7F drop backspace ; | DEL -- for Unix : $$i0D drop return ; | (cr) : $$c5A drop wipe ; | Z : $$c6F drop opendown down $$c49 ; | o : $$c4F drop opendown ; | O
( Editor Keyboard Handler )
| Word name key: $ $ _ _ _ | | | | | c = command mode --+ | | | i = ins/repl mode | | | | | | Key code (hex#) -----+-+ | | Called with ( k -- ) where k is the ASCII key code.
: keyboard key ; : cmd? mode @ 'c = ; : ins? mode @ 'i = mode @ 'r = or ; : mode! ins? 'i and cmd? 'c and or wordname 3 + c! ; : >hex dup 9 >if 7 + then '0 + ; : h! dup $F0 and 2/ 2/ 2/ 2/ >hex wordname 4 + c! ; : l! $0F and >hex wordname 5 + c! ; : name! mode! h! l! ; : nomapping drop ['] beep cmd? and ['] chr ins? and or ; : handlerword name! wordname find ?if ;; then nomapping ; : handler dup handlerword execute ; : editor repeat keyboard handler screen again ; : ed page screen editor ; : vibe scr ! ed ;
|
|
|
|
|
Logged
|
|
|
|
Giant
Member
 
Karma: +0/-0
Offline
Posts: 10
|
 |
Thanks...
« Reply #3 on: April 24, 2005, 01:29:34 AM » |
|
Charles, I did not mean any disrespect. I find line editors to be somewhat burdensome, but then again I am used to a somewhat different environment which has a source repository, and the editor is the main way to manipulate the system. Here we are somewhat stripped down. It is probably good.
I am very curious.. Do you work interactively or do you write code in a text editor and suck it in?
|
|
|
|
|
Logged
|
|
|
|
Charles Childers
Administrator
Sr. Member
    
Karma: +2/-0
Offline
Posts: 745
|
I normally work interactively. I write code in red or at the interpreter, and test it, saving often. I have tools to convert text files to blockfiles and vice versa, but I don't use them often. (Normally just when importing code from other people to the library)
|
|
|
|
|
Logged
|
|
|
|
Charles Childers
Administrator
Sr. Member
    
Karma: +2/-0
Offline
Posts: 745
|
I'm happy to announce that I expect to have an easier to use editor very soon. It's built over the existing one, but provides an editing environment that's similar to VIBE. A Linux version should be done in a day or two, with Windows and Generic+FFI versions following sometime later.
|
|
|
|
|
Logged
|
|
|
|
|
|
|
|
|
|
Pages: 1
|
|
|
|
|