RetroForum Welcome, Guest. Please login or register.
September 07, 2010, 05:53:33 AM
Home Help Search Calendar Login Register

RetroForth Discussion  |  Older Boards  |  Development  |  Topic: A more useful editor « previous next »
Pages: 1 Go Down Print
Author Topic: A more useful editor  (Read 2885 times)
Giant
Member
**

Karma: +0/-0
Offline Offline

Posts: 10


View Profile
A more useful editor
« on: April 23, 2005, 10:06:35 PM »

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 Offline

Posts: 745


View Profile WWW
Re: A more useful editor
« Reply #1 on: April 23, 2005, 11:22:58 PM »

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 Offline

Posts: 745


View Profile WWW
Re: A more useful editor
« Reply #2 on: April 23, 2005, 11:32:25 PM »

Here's the most recent version of that code. While it's still incomplete, bits and pieces of it are operational in this copy:

Code:
| 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 Offline

Posts: 10


View Profile
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 Offline

Posts: 745


View Profile WWW
Re: A more useful editor
« Reply #4 on: April 24, 2005, 02:25:59 AM »

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 Offline

Posts: 745


View Profile WWW
Re: A more useful editor
« Reply #5 on: August 13, 2005, 02:29:27 AM »

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
Charles Childers
Administrator
Sr. Member
*****

Karma: +2/-0
Offline Offline

Posts: 745


View Profile WWW
Re: A more useful editor
« Reply #6 on: August 13, 2005, 05:11:54 PM »

REM, the RetroEditor for Mortals is now availible for RetroForth/Linux. A Windows version should be ready within a few days, then a Generic+FFI version as I have time.

To load it: download rem.f, and put somewhere easy to find. Then do:

Code:
load path/to/rem.f \f new

Enter rem to start the editor, and q to quit it. I strongly recommend reading the comments at the beginning so you can learn the basics of how to use it.

See http://retro.tunes.org/rem.f for the code.
Logged
Charles Childers
Administrator
Sr. Member
*****

Karma: +2/-0
Offline Offline

Posts: 745


View Profile WWW
Re: A more useful editor
« Reply #7 on: August 14, 2005, 03:47:49 AM »

http://retro.tunes.org/rem_win.f

Now a Windows version is complete and working.
Logged
docl
Contributor
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 2


View Profile
Re: A more useful editor
« Reply #8 on: August 14, 2005, 06:34:02 PM »

REM, the RetroEditor for Mortals is now availible for RetroForth/Linux.

This is awesome!  I almost missed how it worked, it was so simple.  I prefer a more keypad like interface, so I changed mine as follows:

Code:
' $$cu alias $$ci ' $$cl alias $$cj
' $$cd alias $$ck ' $$cr alias $$cl

: $$cI 0 line ! ;
: $$cK 7 line ! ;
: $$cJ 8 column -! ;
: $$cL 8 column +! ;
« Last Edit: August 23, 2005, 03:56:30 AM by docl » Logged
Pages: 1 Go Up Print 
RetroForth Discussion  |  Older Boards  |  Development  |  Topic: A more useful editor « previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1 RC2 | SMF © 2001-2005, Lewis Media Valid XHTML 1.0! Valid CSS!