home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / sedpage.seq < prev    next >
Text File  |  1989-07-03  |  4KB  |  97 lines

  1. \ SEDPAGE.SEQ   Allow going to a particular page in SED         by Tom Zimmer
  2.  
  3. editor definitions
  4.  
  5. headerless
  6.  
  7. : gopage        ( --- )         \ set right margin to current column
  8.                 20  6 50 12 box&fill
  9.                 bcr ."  Current page is " curline prtlines / 1+ .
  10.                 bcr
  11.                 bcr ."  Goto Page "
  12.                 on> filtering
  13.                 32 10 at tib 6 expect  span @ #tib ! >in off
  14.                 off> filtering
  15.                 bl word  dup c@ 0> >r number? r> and
  16.                 if      drop 1 max 132 min 1- prtlines * curline over >
  17.                         if      1 max
  18.                                 first.textline =: screenline
  19.                                 backto.line
  20.                         else    to.line
  21.                         then
  22.                 else    2drop
  23.                 then    edeeol >norm scrshow ;
  24.  
  25. \ ' gopage is topage
  26.  
  27. : goline        ( --- )         \ set right margin to current column
  28.                 20  6 50 12 box&fill
  29.                 bcr ."  Current line is " curline 1+ .
  30.                 bcr
  31.                 bcr ."  Goto Line \r\s06"
  32.                 on> filtering
  33.                 33 10 at tib 5 expect  span @ #tib ! >in off
  34.                 off> filtering
  35.                 bl word  dup c@ 0> >r number? r> and
  36.                 if      drop 0MAX maxlines min 1- curline over >
  37.                         over 9 min first.textline +
  38.                         last.textline min =: screenline
  39.                         if      backto.line
  40.                         else    to.line
  41.                         then
  42.                 else    2drop
  43.                 then    edeeol >norm scrshow ;
  44.  
  45. \ ' goline is toaline
  46.  
  47. : nextpar       ( --- )
  48.                 begin   linelen  0> ?lastline 0= and while <sdln> repeat
  49.                 begin   linelen  0= ?lastline 0= and while <sdln> repeat
  50.                 curline screenline 8 max min =: screenline
  51.                 scrshow ;
  52.  
  53. : prevpar       ( --- )
  54.                 <suln>
  55.                 begin   linelen  0= ?firstline 0= and while <suln> repeat
  56.                 begin   linelen  0> ?firstline 0= and while <suln> repeat
  57.                 ?firstline
  58.                 if      first.textline =: screenline
  59.                         scrshow
  60.                 else    last.textline first.textline - 2/ screenline min
  61.                         =: screenline
  62.                         nextpar
  63.                 then ;
  64.  
  65. : ALT-GO        ( --- )         \ Alt-G options
  66.                 ['] noop save!> dobutton
  67.                 savescr
  68.                 ?doingmac 0=    \ If we are doing a macro, don't display
  69.                                 \ command menu box.
  70.                 if      screenline 1+ dup 12 >
  71.                         if      13 -
  72.                         then    20 swap 60 over 9 + box&fill
  73.                         ."  Goto commands.. Select an operation" bcr bcr
  74.                         ."     P - Goto a specified Page"     bcr
  75.                         ."     L - Goto a specified Line"     bcr
  76.                         ."     N - Goto the Next paragraph"   bcr
  77.                         ."     B - Goto the paragraph Before" bcr bcr
  78.                         ." \s10\r ESC \0 = cancel"
  79.                         showcur
  80.                 then
  81.                 key bl or >r
  82.                 restscr
  83.                 'p' r@ = if gopage          then
  84.                 'l' r@ = if goline          then
  85.                 'n' r@ = if nextpar         then
  86.                 'b' r> = if prevpar         then
  87.                 restore> dobutton
  88.                 sdisplay showstat cursor-on ;
  89.  
  90. ' ALT-GO IS ALT-G
  91.  
  92. headers
  93.  
  94. forth definitions
  95.  
  96.  
  97.