 : 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>> swap ffi:wattron curses-error ;
+    ] dip ptr>> (wattron) ;
 
 : ccolor ( foreground background -- )
     current-window get wccolor ;

: with-curses ( window quot -- )
    curses-ok? [ unsupported-curses-terminal ] unless
    [
        [
            ffi:initscr curses-pointer-error
            >>ptr dup apply-options
        ] dip
        ffi:erase curses-error
        init-colors
        [
            [ ffi:endwin curses-error ] [ ] cleanup
        ] curry with-window
    ] with-destructors ; inline

TUPLE: curses-terminal < disposable

: (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 ;

: wcprint ( string window -- )
    ptr>> [ (wcwrite) ] [ "\n" swap (wcwrite) ] bi ;
