 : (wgetch) ( window -- key )
     ffi:wgetch [ curses-error ] keep ; inline
 
+: (wattroff) ( attribute window-ptr -- )
+    swap ffi:wattroff curses-error ; inline
+
+: (wattron) ( attribute window-ptr -- )
+    swap ffi:wattron curses-error ; inline
+
 PRIVATE>
 
 : wcrefresh ( window -- ) ptr>> (wcrefresh) ;
 : crefresh ( -- ) current-window get wcrefresh ;
 
+: wcnl ( window -- ) [ "\n" ] dip ptr>> (wcwrite) ;
+: cnl ( -- ) current-window get wcnl ;
+
 : wcwrite ( string window -- ) ptr>> (wcwrite) ;
 : cwrite ( string -- ) current-window get wcwrite ;
-
-: wcnl ( window -- ) [ "\n" ] dip ptr>> (wcwrite) ;
-: cnl ( -- ) current-window get wcnl ;
 
 : wcprint ( string window -- )
     ptr>> [ (wcwrite) ] [ "\n" swap (wcwrite) ] bi ;

CONSTANT: COLOR_CYAN  6
CONSTANT: COLOR_WHITE 7

ERROR: curses-failed ;
ERROR: unsupported-curses-terminal ;


: insert-line ( string y -- )
    current-window get winsert-line ;

: wattron ( attribute window -- ) ptr>> (wattron) ;
: attron ( attribute -- ) current-window get wattron ;

: wattroff ( attribute window -- ) ptr>> (wattroff) ;
: attroff ( attribute -- ) current-window get wattroff ;

: wall-attroff ( window -- ) [ A_NORMAL ] dip wattroff ;
: all-attroff ( -- ) current-window get wall-attroff ;

: wccolor ( foreground background window -- )
    [
        2dup [ COLOR_WHITE = ] [ COLOR_BLACK = ] bi* and
        [ 2drop 0 ] [ register-color ] if ffi:COLOR_PAIR
    ] dip ptr>> (wattron) ;

: ccolor ( foreground background -- )
    current-window get wccolor ;
