         ] [
             window-params ffi:newwin
         ] if* [ curses-error ] keep >>ptr &dispose
-    ] [ apply-options ] bi ;
+    ] [ apply-window-options ] bi ;
 
 : with-window ( window quot -- )
     [ current-window ] dip with-variable ; inline

        [ ffi:cbreak ] [ ffi:nocbreak ] if
    ] if curses-error ;

: apply-options ( window -- )
    {
        [ [ cbreak>> ] [ raw>> ] bi set-cbreak/raw ]
        [ echo>> [ ffi:echo ] [ ffi:noecho ] if curses-error ]
        [ [ ptr>> ] [ scrollok>> >BOOLEAN ] bi ffi:scrollok curses-error ]
        [ [ ptr>> ] [ leaveok>> >BOOLEAN ] bi ffi:leaveok curses-error ]
        [ [ ptr>> ] [ keypad>> >BOOLEAN ] bi ffi:keypad curses-error ]
    } cleave ;

SYMBOL: n-registered-colors


        init-terminal
        ffi:initscr curses-pointer-error drop
        dup ptr>> ffi:set_term curses-pointer-error drop
    ] dip [ apply-global-options ] [ apply-window-options ] bi ;
    
<PRIVATE

