Skip to content

Instantly share code, notes, and snippets.

@devyn
Created November 1, 2008 22:07
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 devyn/21586 to your computer and use it in GitHub Desktop.
Save devyn/21586 to your computer and use it in GitHub Desktop.
# 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