Category : Forth Source Code
Archive   : SMILY46B.ZIP
Filename : VIEWEDIT.SEQ

 
Output of file : VIEWEDIT.SEQ contained in archive : SMILY46B.ZIP
\ The editor integration is pruned code from George T. Hawkins's
\ excellent browser package. I've modified to work with F-PC350,
\ remove links to the rest of the browser package, also added
\ utilities to use external editor for view, help and >b
\ DKnight
comment:
ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
º E edits open file, if no open file, enters editor º
º E (file) edits file" º
º ED does system call to external editor º
º EP re-edit last browse.prn º
º RE re-edits last edited file º
º Q does system call to qedit º
º NOTE: you'll need to configure your editor to º
º accept line # as parameter. º
º V {word) loads defining file to line # in editor º
º H (word) loads help file to line # in editor º
º H gives help screen º
º HE loads modifiable text help file into editor º
º >B works the same as with Zimmer's editor º
º Also supports EDITALL LOAD ON ERROR >BROWSER º
ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
³ **** to use with another editor, change lines 66, 111, 114 ³
³ to reflect name and path of your editor ³
³ helpscrn located at line 291 ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

comment;


!used \ get initial dictionary locations

vocabulary editor

only forth also hidden also editor also

editor definitions

headerless

80 constant |editor$| \ size of path\filespec to follow:

create editor$ |editor$| allot \ path\filespec for external editor

editor$ |editor$| blank \ blank/space fill area

\ Stores length/data address of
0 value cs-len \ length of counted string
0 value cs-addr \ data address of counted string

\ Gets the reading past the noise word and stores
\ string length/data address.
: get-setting ( | -- )
bl word drop bl word
dup 1+ !> cs-addr
c@ !> cs-len ;


\ Sets the editor specification.
: set-editor ( | -- )
get-setting
\ set editor path\filespec:
cs-len editor$ c! cs-addr
editor$ 1+ cs-len cmove ;

set-editor = edn \ change "c:\bin\q" to path\name of your editor

0 value _ed-len \ length of ed-spec + 1
0 constant _ed-file \ location of file to be edited
0 value _ed-line \ line number to edit
0 value '$ascz \ ascz string current address
0 value 'ef \ _ed-file current address
0 value |ed+fn+ln| \ size of string for:
\ editor + filename + line number

: blank-file ( -- ) \ blanks out filespec/line#
_ed-file
|editor$| _ed-len - 1-
blank ;

: _ed-file! ( a1 -- n1 ) \ fills in file to be edited and
count dup>r \ returns full ed+ed-file length
_ed-file swap cmove \ (i.e., DOS string length)
r> _ed-len + ;

: _fresh-file ( -- ) \ closes and reopens active file
seqhandle dup hclose drop hopen drop ;


forth definitions

headers

: re ( -- ) \ forces a re-edit of previous file
editor$ $sys drop
_fresh-file ;

: e ( | {} -- ) \ edits active or given file, if any
>in @ span @ < IF
bl word _ed-file!
ELSE \ use filename in input stream
seqhandle >hndle @ 0<
IF \ no active file
_ed-len
ELSE \ use active file
seqhandle _ed-file!
THEN
THEN
editor$ c! re ;

\ change c:\bin\q to path\name of your editor
: ed " e " 0 [ HIDDEN ] "SYSCOMMAND dark ;
\ Note: dark is not necessary for all editors, just the one I use.
\ 27Feb90mds

' ed alias q \ change "q" to name you use to call your editor

editor definitions

headerless

\ Invokes external editor with filename & line number.
: ed-at-line ( -- )
blank-file
_ed-len 3 + \ first part of multi part
!> |ed+fn+ln| \ string length
seqhandle count >r
r@ +!> |ed+fn+ln| \ second part of string length
_ed-file r@ cmove \ add filename
_ed-file r> + \ step past file field
bl over c! \ add space separator
1+ >r \ now at line number field
_ed-line 0 <# #s #> \ convert number to string
dup +!> |ed+fn+ln| \ third part of string length
r> swap cmove \ add line number
|ed+fn+ln| editor$ c! \ set counted string length
re ;

headers

editor$ c@ 1+ !> _ed-len \ set length of ed-spec + 1

editor$ _ed-len + 1+ !> _ed-file \ addr for edited file

\ ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ·
\ º º
\ º HOOKING IN AN EXTERNAL EDITOR º
\ º FOR INVOCATION ON LOAD ERROR º
\ º º
\ ÓÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĽ

headerless

\ Invokes external editor as default on load error.
: call-ed? ( -- )
cr ." bypasses editor - any other key calls editor: "
key 27 = IF exit then
loadline @ !> _ed-line \ set line # for editor
ed-at-line \ invoke editor for open file
cr ;

\ From SEQREAD.SEQ (modified)

: ((DOERROR)) ( a1 n1 --- )
2>r
cr ." file = " .seqhandle
." at Line " loadline @ u.
cr outbuf count type cr
>in @ 1- here c@ - 0 max
dup %!> screenchar 0
?do ascii - emit loop
." ^-- " 2r> type space
\ mods follow:
call-ed?
quit ;

' ((DOERROR)) IS DOERROR


\ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
\ ³ string search of files words ³
\ ³ From FWORDS.SEQ ³
\ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

create slook.buf 36 allot

code searchsetup ( --- a1 n1 a2 n2 )
mov bx, # slook.buf 1+ \ slook.buf count
push bx
mov al, slook.buf byte
sub ah, ah
push ax
mov bx, # outbuf 1+ \ outbuf count
push bx
mov al, outbuf byte
1push
end-code

\ From FWORDS.SEQ (modified)
: searchedit ( --- )
[ forth ]
IBRESET
0.0 seek
." ." ?cr
10000 1
do ?keypause
lineread c@ 0= ?leave
searchsetup search nip
if i !> _ed-line
savescr @> #out @> #line 2>r
ed-at-line
restscr 2r> at
leave
then
loop ;

forth definitions

headers

\ From FWORDS.SEQ
: editall ( search_string file_specs --- ) \ edit all files containing
SAVESTATE
?in-empty \ if nothing following command
if cr ." String to LOOK for and EDIT ->" query 0 word
else bl word
then slook.buf over c@ 1+ 32 min cmove
get-filespecs ['] searchedit fallof
RESTORESTATE ;


\ ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
\ º VIEW & HELP UTILITY for outside editor º
\ ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

\ view & help words 10:20:37 Tue 02-13-1990
\ a lot of these words were cobbed from tz's topedit, seqread, and
\ fpc225 view as well as hawkins ed-int and as usual i was to lazy
\ to document dk

only forth also hidden also editor also

forth definitions

headerless

: get-ed ( -- )
loadline @ !> _ed-line \ set line # for editor
ed-at-line \ invoke editor for open file
cr ;

: file-line_view ( n1 a1 --- )
$file 0=
if loadline !
get-ed
else drop
savecursor
savescr
cursor-off
15 8 65 12 box&fill
bcr ." \4 Couldn't locate " >attrib4 .seqhandle
62 #out @ - spaces >norm
beep 15 tenths
cursor-on
restscr
restcursor
then ;

: cfa_view ( a1 --- )
>viewfile \ get file name
file-line_view ; \ get linr #

: cfa_help ( a1 --- )
>viewfile
" HLP" ">$ over $>ext \ glue extension hlp to file
file-line_view ;

\ $>HANDLE ( filename1 handle1 --- )
: helpfile " HELPFILE.TXT" ">$ dup>r
$file abort" Failed to open HELPFILE.TXT"
r> $file abort" Couldn't re-open HELPFILE.TXT"
e ;

: lastbrowse " browse.prn" ">$ dup>r
$file abort" Failed to open browse.prn"
r> $file abort" Couldn't re-open browse.prn"
e ;

headers

: helpscrn ( ---)
cls
4 5 74 21 box&fill
bcr ." >B use like this: >B REF HOPEN "
bcr ." B exit (alias for bye) "
bcr ." E (file) edits file"
bcr ." E edits open file, if no open file, enters editor"
bcr ." ED does system call to external editor"
bcr ." EDITALL (word) edits all occurrences of word "
bcr ." EP loads last browse.prn ( >bl ) into editor"
bcr ." H (word) loads help file to line # in editor "
bcr ." H gives this help screen"
bcr ." HE loads modifiable text help file into editor"
bcr ." Q does system call to qedit"
bcr ." RE re-edits last edited file"
bcr ." V {word} view word's source code "
cr ;

: view ( | --- )
>in @ bl word swap >in ! c@
if bl word hfind 0= ?missing
cfa_view
else savecursor
savescr
cursor-off
15 8 65 12 box&fill
bcr ." \4 USAGE = V Word " >attrib4
62 #out @ - spaces >norm
beep 15 tenths
cursor-on
restscr
restcursor
then ;

: help ( | --- )
>in @ bl word swap >in ! c@
if bl word hfind 0= ?missing
cfa_help
else helpscrn
then ;

' help alias h
' view alias v
' helpfile alias he
' lastbrowse alias ep

editor definitions

\ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
\ ³ The following allows use of browsepr.seq ³
\ ³ browsepr.seq needs be loaded after this file ³
\ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ


\ this is neccessary to get around >browser calling editor with
' ed-at-line alias


\ the following are dummy words to allow the use of browsepr.seq without
\ modifications

: newbrowse ;
: ?browse ;
: seding ;
: newfl ;
: edready ;

' NOOP IS newbrowse
' NOOP IS ?browse
' NOOP IS seding
' NOOP IS newfl
' NOOP IS edready

behead

only forth also definitions

\ display dictionary space used:

cr
.( VIEWEDIT.SEQ uses:)
cr
.used



  3 Responses to “Category : Forth Source Code
Archive   : SMILY46B.ZIP
Filename : VIEWEDIT.SEQ

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/