license
See send
 
	| CREATE (_send_) 0 t,
	| : send (_send_) @execute ;

 
See TYPE
 
	| CREATE (_type_) 0 t,
	| : TYPE ( addr num --)
		(_type_) @execute 
	;
	
	\ Non standard
	\
    : $type   ( addr --) COUNT TYPE ;
	

 
See EXPECT
 
	| CREATE (_expect_) 0 t,
	| : EXPECT ( addr num --)
		(_expect_) @execute ;
	 
ANS 6.1.1320 EMIT

( x -- )

If x is a graphic character in the implementation-defined character set, display x. The effect of EMIT for all other values of x is implementation-defined.

When passed a character whose character-defining bits have a value between hex 20 and 7E inclusive, the corresponding standard character, specified by 3.1.2.1 Graphic characters, is displayed. Because different output devices can respond differently to control characters, programs that use control characters to perform specific functions have an environmental dependency. Each EMIT deals with only one character.

 
	\ can't use the stack as we are not allowed to take the
	\ stack address. Using a buffer is a bit over the top so
	\ we will allocate a user variable for the job.
	\
	uvariable _emit_buffer
	: EMIT ( char --)
			_emit_buffer C!
			_emit_buffer one 
			TYPE 
	;
	 
 
	CREATE (_cr_) 0 t,
	| : CR (_cr_) @execute ; 


 
visible ( from num to --)

Move the characters from the buffer described by from and num to the buffer pointed to by to. Make sure the characters are in a visible range. Useful for printing ascii text out to terminals that will interpret some characters as control characters.

  


	: visible ( from num to --)
		-rot               \ to from num (--
		OVER               \ to from num from (--
		+                  \ to start end (--
		SWAP               \ to end start (--
		DO                 \ to (--
			I char@ 
			DUP BL < IF    
				DROP [CHAR] ~
			THEN
			DUP [CHAR] ~ > IF
				DROP [CHAR] ~
			THEN
			OVER char!
			CHAR+
		[ 1 CHARS ]T LITERAL +LOOP
		DROP
	;

	 

Convert invisible caracters to ~

 
	: ~TYPE ( addr num --)
		DUP IF   
			$buffer
				TUCK			\ num addr num (--
				buffer visible		
			    buffer SWAP     \ addr num (--
				TYPE
			kill_buffer
		ELSE 
			2DROP 
			xpause 
		THEN 
	;

	: ^C ( --)
		user_base activation_^c_set W@ IF
			FALSE user_base activation_^c_set W! 
			TRUE ABORT" ^C detected." 
		THEN 
	;