aUCBLogo Demos and Tests / textcontroltest
			
				
			
			to textcontroltest
   ; a complete console written in Logo
   textcontroltest_f=Frame [][MyConsole]
      wxCaption+wxSystem_Menu+wxClose_Box+wxResize_Border
      +wxStay_on_Top
      [0 100][400 400]
   FrameSetClientSize textcontroltest_f 600 400
   FrameSetBackgroundColor textcontroltest_f [.9 .9 .8]
   
   history=[[;]]
   historyi=0
   t=(TextControl textcontroltest_f " " 
      [][]
      wxTE_multiline+wxTE_readOnly+wxTE_Rich2+wxTE_NoHideSel
      );[0 0][-1 -1])
   setWriter t   
   
   t2=(TextControl textcontroltest_f [Commandline] "
      []   ;OnChange
      [   OnEnter
      ])
   b=Button textcontroltest_f [Enter]
      [   OnEnterButton
      ]
   TextControlOnChar t2
   [   c=KeyboardValue
      case c 
      [[wxk_escape destroyAll]
      [wxk_up 
         if historyi < count history
         [   historyi=historyi+1
            TextControlSetValue t2 history.historyi
         ]
      ]
      [wxk_down 
         ifelse historyi > 1
         [   historyi=historyi-1
            TextControlSetValue t2 history.historyi
         ][   historyi=0
            TextControlSetValue t2 " 
         ]
      ]
      [else historyi=0]]
   ]
   setWriter t
;comment   
;[
   bs=BoxSizer wxVertical
   BoxSizerAdd bs t 1 wxExpand 0
   bsh=BoxSizer wxHorizontal
   BoxSizerAdd bsh t2 1 wxExpand+wxAlign_left 0
   BoxSizerAdd bsh b 0 wxExpand+wxAlign_left 0
   BoxSizerAdd bs bsh 0 wxExpand+wxAlign_bottom 0
   FrameSetSizer textcontroltest_f bs
;]
end
to myRun v
   catch "error [run v]
   local [err]
   err=error
   if not empty? err
   [   (pr err.2 [in] err.3 [of] err.4 [line] err.5)
   ]
   updateGraph
end
to OnEnter
   local [v]
   v=(TextControlValue t2)
   push "history v
   historyi=0
   TextControlAppend t (word v char 10)
   TextControlSetValue t2 "
   myRun v
end
to OnEnterButton
   local [v]
   v=(TextControlValue t2)
   push "history v
   historyi=0
   TextControlAppend t (word v char 10)
   myRun v
end
to destroyAll
   er [[][textcontroltest_f history historyi t t2]]
   (GC true)
   setWriter []
end