Created
November 1, 2008 22:07
-
-
Save devyn/21586 to your computer and use it in GitHub Desktop.
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
# This is an example of a shoes terminal | |
# Created by Devyn Cairns | |
Shoes.app do | |
background "#FFF" | |
@win = flow do | |
@header = para('shoes console', :family => 'monospace', :fill => "#000", :stroke => "#FFF", :align => 'center', :margin => 8) | |
para "\n" | |
@console = para('$ ', :family => 'monospace', :stroke => "#000") | |
@cursor = para(' ', :fill => "#FFF", :family => 'monospace') | |
@nodelete = 2 | |
animate(2) { @cursor.fill = ((@cursor.fill == "#000") ? "#FFF" : "#000") } | |
keypress do |key| | |
case key | |
when :delete, :backspace, :shift_delete, :shift_backspace | |
@console.text = @console.text[0..-2] unless @console.text.size == @nodelete | |
when "\n", :enter, :return | |
@console.text += "\n" | |
@console.text += `#{@console.text[@nodelete..-2]}` | |
@console.text += "\n$ " | |
@nodelete=@console.text.size | |
@win.scroll_top = @win.scroll_max | |
else | |
@console.text += key if key.class == String | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment