Plan 9 from Bell Labs’s /usr/web/sources/contrib/fgb/root/sys/src/cmd/4th/lib/print.4th

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


\ 4tH library - PRINT - Copyright 2003,2009 J.L. Bezemer
\ You can redistribute this file and/or modify it under
\ the terms of the GNU General Public License

\ Has RMARGIN been defined? If not, abort!
[UNDEFINED] RMARGIN [IF]
[ABORT] [THEN]

\ Load definitions when needed
[UNDEFINED] SCAN [IF]
[NEEDS lib/scanskip.4th]
[THEN]

[UNDEFINED] PRINT [IF]
VARIABLE #emits 

: (PRINT) DUP #emits +! TYPE ;         \ public
: SHOW emit 1 #emits +! ;              \ public
: NL CR 0 #emits ! ;                   \ public
: ?SPACE #emits @ IF BL SHOW THEN ;    \ public

: NEXT-WORD                            \ private
  BL DUP >R SKIP OVER OVER R> SCAN TUCK
  >R >R - R> R> ROT >R ROT R>
  DUP 1+ #emits @ + RMARGIN >
  IF NL ELSE ?SPACE THEN (PRINT)
;

: PRINT ( addr count --)               \ public
  BEGIN DUP WHILE NEXT-WORD REPEAT
  DROP DROP
;

[DEFINED] 4TH# [IF]
hide #emits
hide NEXT-WORD
[THEN]
[THEN]


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].