Skip to content

Instantly share code, notes, and snippets.

Created July 16, 2014 14:15
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 anonymous/0adde0fa5a92698fc6f6 to your computer and use it in GitHub Desktop.
Save anonymous/0adde0fa5a92698fc6f6 to your computer and use it in GitHub Desktop.
Praises API usability
#
# Using Praises to show 2 windows, and output text to one of them,
# and halt with a “press any key to continue” prompt
#
w1 = Praises::Window.new(width: '100%', height: '50%', show: true)
w2 = Praises::Window.new(width: '100%', height: '50%', bottom: 0, show: true)
w1.puts "This is the top window"
Praises.blocking_getch
#
# Using Praises with a menu bar (of commands defined by you),
# kind of like Midnight Commander style
#
menu = Praises::MenuBar.new(bottom: 0)
menu.option('f1', "File") do
# Handle
end
menu.option('f2', "Edit") do
# Handle
end
menu.option('ctrl+f1', "Archive") do
# Handle
end
menu.show
# Options that need modifiers (eg ctrl+f1) won't appear until
# modifier key is pressed
#
# Using Praises to handle a modal alert
#
modal = Praises::Modal.new(text: "Are you sure?", buttons: [:ok, [:maybe, "Perhaps"]])
modal.option('OK') do
# Handle
end
modal.option('Maybe') do
# Handle
end
modal.show
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment