| Proto 4th.CoSy Interface 
|
| Author: Bob Armstrong building upon resources created by 
| Extracted & Built upon Tui.f built upon
| Danny Reinhold / Reinhold Software Services / vocabulary on the IUP GUI toolkit: | 
| Copyright © 1994-2005 Tecgraf / PUC-Rio and PETROBRAS S/A.
|
| Reva's license terms also apply to this file

cr ." | Job.f  begin | "  

~ needs ui/gui exit~ 

with~ ~iup with~ ~ui

| .~ cr cr


_n dup value dlgH  value txtH 

: newwdo ( -- dialogHandle_MultiLineHandle )
 z" multilineAction" IupMultiLine 
 dup z" EXPAND" z" YES" IupSetAttribute drop
 dup IupDialog swap 2_i cL ;

: JobHndl s" Tui" v@ s" hndl" v@ ;
: JobHndld_ JobHndl 0 i@ ;   : JobHndlt_ JobHndl 1 i@ ;

: dhndl_ ( tui -- dialogHndl_ ) s" hndl" v@ 0 i@ ;
: thndl_ ( tui -- textHndl_ ) s" hndl" v@ 1 i@ ;


: getX ( dlgH -- int ) z" X" IupGetAttribute zcount >single drop ;
: getY ( dlgH -- int ) z" Y" IupGetAttribute zcount >single drop ;
: _getPos ( dlgH -- X Y ) dup getX swap getY 2 s>iv ; | get UL corner pos of window .


: getAttrStr IupGetAttribute zcount _str ;
: setAttrStr ( str Hndl lbl  -- ) --bca >r> van zt IupStoreAttribute drop r> ref0del ;  


: _getSize ( dlgH -- s" XxY" ) z" SIZE" getAttrStr ;
: setsize ( s" XxY" dlgH -- ) swap z" SIZE" swap van zt IupSetAttribute drop ;

: _getfont ( thndl -- s" " ) z" FONT" getAttrStr ;
: setfont ( font thndl -- ) z" FONT" setAttrStr  ;  

: gettxt ( txtH -- str ) z" VALUE" getAttrStr ; 
: settxt ( str txtH -- ) z" VALUE" setAttrStr ; 

: gettit ( dlgH -- str ) z" TITLE" getAttrStr ; 
: settit ( str dlgH -- ) setAttrStr ; 

: gettab ( dlgH -- str ) z" TABSIZE" getAttrStr ; 
: settab ( str dlgH -- ) z" TABSIZE" setAttrStr ; 

: getcaret ( txtH -- str ) z" CARET" getAttrStr  ;
: setcaret ( ` X,Y txtH ) z" CARET" setAttrStr ;  


: savetxt ( -- ) | uses globals dlgH and txtH  
 dup 1 c+ @ gettxt R rot @ gettit v! ;
| saves text of text dialog based on title .

: svtxt ." svtxt | " $.> txtH gettxt R dlgH gettit v! ." | " $.> cr ;

: setWdo ( Job -- ) 1p  newwdo >a> R@ s" Tui" v@ >a> s" hndl" v! 
  a@ s" SIZE" v@ auxx@ 0 i@ setsize
  a> s" FONT" v@ a@ 1 i@ setfont
  ( R@ s" text" v@ ) ec a> 1 i@ settxt 
 1P ;


: showXY ( dlgH X Y -- ) IupShowXY drop ;  

: showWdo dup JobHndld_ swap s" Tui" v@ s" posXY" v@ lst>stk_  IupShowXY _i ;

|  auxx@ 1 i@ a@ s" posXY" v@ lst>stk_ IupShowXY _i 1P> ; 

: rShow s" .r" Dv@ dup setWdo  showWdo ;

: rUpdate  "lf MV s" .r" Dv@ JobHndlt_ settxt ;

: rGet  ` .r Dv@  JobHndlt_ gettxt >a> ` .r ` text ,L Dv! a> ; 	| retrieve changed text from window
| 20210711 | added saving of text to .r as well as returning .

: closeWdo ( Job -- ) s" Tui hndl" blVM v@ >_ IupDestroy drop ; 


: closedlg dlgH IupDestroy drop  _n dup addr dlgH 2! ;


| \/ | really nothing below here  | \/ | =========== |

." | Job.f end | " cr 
