Skip to content

Instantly share code, notes, and snippets.

@mrange
Created May 9, 2021 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrange/4804b2262bb7e04eb5432b13e0e5df3c to your computer and use it in GitHub Desktop.
Save mrange/4804b2262bb7e04eb5432b13e0e5df3c to your computer and use it in GitHub Desktop.
gui.cs
open System
open NStack
open Terminal.Gui
let ustr (x: string) = ustring.Make(x)
let doNothing () = ()
[<EntryPoint>]
let main argv =
Application.Init ()
let top = Application.Top
let onQuit () =
let r = MessageBox.Query (50, 7, ustr "Quit?", ustr "Are you sure you want to quit?", ustr "Yes", ustr "No") = 0
top.Running <- not r
use menuBar =
let mb mbis = new MenuBar ((mbis : MenuBarItem array))
let mbi n mis = MenuBarItem (ustr n, (mis : MenuItem array))
let mi n a = MenuItem (ustr n, ustring.Empty, Action a)
mb <| [|
mbi "_File" <| [|
mi "_Load" doNothing
mi "_Save" doNothing
mi "_Quit" onQuit
|]
mbi "_About" <| [|
mi "_Help" doNothing
|]
|]
use statusBar =
let sb sis = new StatusBar (sis)
let si k n a = StatusItem (k, ustr n, Action a)
sb [|
si Key.F1 "~F1~ Help" doNothing
si Key.F2 "~F2~ Load" doNothing
si Key.F3 "~F3~ Save" doNothing
si Key.Q "~^Q~ Quit" onQuit
|]
use win = new Window (ustr "Hello")
top.Add win
top.Add (menuBar, statusBar)
Application.Run(top)
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment