Files
ueforth/common/ansi.fs
2022-02-27 20:59:19 -08:00

34 lines
1.1 KiB
Forth

\ Copyright 2021 Bradley D. Nelson
\
\ Licensed under the Apache License, Version 2.0 (the "License");
\ you may not use this file except in compliance with the License.
\ You may obtain a copy of the License at
\
\ http://www.apache.org/licenses/LICENSE-2.0
\
\ Unless required by applicable law or agreed to in writing, software
\ distributed under the License is distributed on an "AS IS" BASIS,
\ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\ See the License for the specific language governing permissions and
\ limitations under the License.
( ANSI Codes )
vocabulary ansi ansi definitions
: esc 27 emit ; : bel 7 emit ;
: clear-to-eol esc ." [0K" ;
: scroll-down esc ." D" ;
: scroll-up esc ." M" ;
: hide esc ." [?25l" ;
: show esc ." [?25h" ;
: terminal-save esc ." [?1049h" ;
: terminal-restore esc ." [?1049l" ;
forth definitions ansi
: fg ( n -- ) esc ." [38;5;" n. ." m" ;
: bg ( n -- ) esc ." [48;5;" n. ." m" ;
: normal esc ." [0m" ;
: at-xy ( x y -- ) esc ." [" 1+ n. ." ;" 1+ n. ." H" ;
: page esc ." [2J" esc ." [H" ;
: set-title ( a n -- ) esc ." ]0;" type bel ;
forth