Skip to content

Instantly share code, notes, and snippets.

@greatseth
Created October 6, 2008 18:46
Show Gist options
  • Select an option

  • Save greatseth/15093 to your computer and use it in GitHub Desktop.

Select an option

Save greatseth/15093 to your computer and use it in GitHub Desktop.
diff --git a/lib/shoes/log.rb b/lib/shoes/log.rb
index 97380f3..b0ee3a6 100644
--- a/lib/shoes/log.rb
+++ b/lib/shoes/log.rb
@@ -10,37 +10,42 @@ module Shoes::LogWindow
Shoes.log.clear
end
end
- @log, @hash = stack, nil
+ @log = stack :scroll => true, :height => 1.0, :width => 1.0
update
every(0.2) do
update
end
end
end
+
def update
- if @hash != Shoes.log.hash
- @hash = Shoes.log.hash
- @log.clear do
- i = 0
- Shoes.log.each do |typ, msg, at, mid, rbf, rbl|
- stack do
- background "#f1f5e1" if i % 2 == 0
- inscription strong(typ.to_s.capitalize, :stroke => "#05C"), " in ",
- span(rbf, " line ", rbl, :stroke => "#335"), " | ",
- span(at, :stroke => "#777"),
- :stroke => "#059", :margin => 4, :margin_bottom => 0
- flow do
- stack :margin => 6, :width => 20 do
- image "#{DIR}/static/icon-#{typ}.png"
- end
- stack :margin => 4, :width => -20 do
- para " #{msg}", :margin => 4, :margin_top => 0
- end
+ return if @hash == Shoes.log.hash
+
+ @hash = Shoes.log.hash
+
+ @log.clear do
+ # How come not each_with_index?
+ i = 0
+ Shoes.log.each do |typ, msg, at, mid, rbf, rbl|
+ stack do
+ background "#f1f5e1" if i % 2 == 0
+ inscription strong(typ.to_s.capitalize, :stroke => "#05C"), " in ",
+ span(rbf, " line ", rbl, :stroke => "#335"), " | ",
+ span(at, :stroke => "#777"),
+ :stroke => "#059", :margin => 4, :margin_bottom => 0
+ flow do
+ stack :margin => 6, :width => 20 do
+ image "#{DIR}/static/icon-#{typ}.png"
+ end
+ stack :margin => 4, :width => -20 do
+ para " #{msg}", :margin => 4, :margin_top => 0
end
end
- i += 1
end
+ i += 1
end
end
+
+ @log.scroll_top = @log.scroll_max
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment