home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
forth
/
compiler
/
fpc
/
source
/
sedsort.seq
< prev
next >
Wrap
Text File
|
1989-03-29
|
2KB
|
59 lines
\ SEDSORT.SEQ Sort the lines of a paragraph by Tom Zimmer
editor definitions
0 value colsave
variable sortto
variable sortfrm
create sort1.buf 142 allot
create sort2.buf 142 allot
headerless
: sortline ( --- )
linebuf 1+ sort1.buf 1+ 132 cmove
linelen sort1.buf c! ldel
@> sortfrm dup @> sortto
do sort2.buf colsave + 15 blank
i #lineseginfo 2- ?cs: sort2.buf rot
colsave 15 + min
cmovel sort2.buf colsave +
sort1.buf 1+ colsave + 8 compare 0>
if drop i leave then
loop backto.line <nln>
sort1.buf dup linebuf 132 cmove
c@ =: linelen @> rmargin linebuf c!
modified putline getline
sortfrm incr @> sortfrm to.line ;
: ssort ( --- ) \ sort lines of a paragraph
?browse ?exit
linelen 0= ?lastline or if sdln exit then
screenchar =: colsave
?shiftkey save!> caps
true save!> imode
save> screenline
0 save!> screenchar
curline =: sortto
sdln
curline =: sortfrm
begin modified
putline getline
linelen 0> ?lastline 0= and
while sortline
repeat sortto @ backto.line
restore> screenchar
restore> screenline
restore> imode
restore> caps
scrshow ;
' ssort is sortlin
headers
forth definitions