Created
July 16, 2014 14:15
-
-
Save anonymous/0adde0fa5a92698fc6f6 to your computer and use it in GitHub Desktop.
Praises API usability
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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