Program.fs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Learn more about F# at http://fsharp.org
  2. open System
  3. open Terminal.Gui
  4. open NStack
  5. let ustr (x:string) = ustring.Make(x)
  6. let stop = Action Application.RequestStop
  7. let newFile() =
  8. let ok = Button (ustr "Ok", true, Clicked=stop)
  9. let cancel = Button (ustr "Cancel", Clicked=stop)
  10. let d = Dialog (ustr ("New File"), 50, 20, ok, cancel)
  11. Application.Run (d)
  12. let quit() =
  13. if MessageBox.Query (50, 7, "Quit demo", "Are you sure you want to quit the demo?", "Yes", "No") = 0 then
  14. Application.Top.Running <- false
  15. let buildMenu() =
  16. MenuBar ([|
  17. MenuBarItem (ustr ("File"),
  18. [| MenuItem(ustr("_New"), "Creates a new file", System.Action newFile);
  19. MenuItem(ustr("_Quit"), null, System.Action quit)
  20. |])|])
  21. [<EntryPoint>]
  22. let main argv =
  23. Application.Init ()
  24. let top = Application.Top
  25. let win = Window (ustr "Hello", X=Pos.op_Implicit(0), Y=Pos.op_Implicit(1), Width=Dim.Fill(), Height=Dim.Fill())
  26. top.Add (buildMenu())
  27. top.Add (win)
  28. Application.Run ()
  29. 0 // return an integer exit code