Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/samples/simple-editor.rb
blob: b6c1190df3807d6a4628d6cd8000b309342c6482 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
str, t = "", nil
Shoes.app :height => 500, :width => 450 do
  background rgb(77, 77, 77)
  stack :margin => 10 do
    para span("TEXT EDITOR", :stroke => red, :fill => white), " * USE ALT-Q TO QUIT", :stroke => white
  end
  stack :margin => 10 do
    t = para "", :font => "Monospace 12px", :stroke => white
    t.cursor = -1
  end
  keypress do |k|
    case k
    when String
      str += k
    when :backspace
      str.slice!(-1)
    when :tab
      str += "  "
    when :alt_q
      quit
    when :alt_c
      self.clipboard = str
    when :alt_v
      str += self.clipboard
    end
    t.replace str
  end
end