Awesome, thanks Krzysztof! I've incorporated your changes. Another question to folks: Now that I've got a Shoes development environment working, I've fixed a couple of minor bugs in Shoes that were bothering me. Is there a standard procedure for feeding patches up to _why? Should I email patches to this list/to him? Or send him a github pull request?
Thanks! -Kevin On Tue, Jan 13, 2009 at 8:46 AM, Krzysztof B. Wicher <[email protected]>wrote: > Hi, > I like your idea. Great work: > I added an error_logger edit box at the bottom so that you do not need to > open the console to see the error. > It is just a draft and can be enhanced: > > > class DemoApp > attr_reader :msg > def initialize(code) > @app = if code.grep(/Shoes.app/).empty? > eval "Shoes.app { #{code} }" > else > eval @code > end > end > def id > @app.id > end > def close > @app.close > end > end > > # This positioning doesn't appear to work... I wonder how to do it right? > a = Shoes.app :left => 10, :top => 10 do > > # kwicher: ADDED clear the console log > Shoes.log.clear > @apps = [] > para "Enter shoes code and submit to see a demo of what it would look > like" > @e = edit_box :height => 200, :width => '100%' > @e.focus > > # Would like to have hotkeys for each button, but its unclear how to > catch > # things like ctrl-s from inside the edit_box > @submit = button "Submit" > # kwicher: ADDED clear the console log and error_listener edit_box > > @submit.click {Shoes.log.clear;@err.text=''; @apps.push > DemoApp.new(@e.text);} > @clear = button "Clear" > # kwicher: ADDED clear the console log and error_listener edit_box > @clear.click {[email protected] = '';@err.text=''; Shoes.log.clear;} > > @delete = button "Remove Demo Apps" > @delete.click do > open_app_ids = Shoes.APPS.map {|a| a.id} > @apps.each do |a| > a.close if open_app_ids.include? a.id > end > @apps = [] > end > > @load = button "Load from file" > @load.click do > filename = ask_open_file > @e.text = File.read(filename) > @err.text=''; > end > # kwicher: ADDED error_listener > every(1) do > Shoes.log.each do |typ, msg, at, mid, rbf, rbl| > @err.text="#{msg}" > end > end > @e.focus > # kwicher: ADDED error_listener edit_box > para "=============== Error Messages=============", :align => 'center' > @err = edit_box :height => 200, :width => '100%' > end > > Krzys > > > On Tue, Jan 13, 2009 at 4:45 AM, Kevin Ball <[email protected]> wrote: > >> >> I guess you ask this for removing the DemoApp from the list when it's >>> closed, but maybe you could just not use that class and eval the code >>> straight from the main app? And if the code contains Shoes.app, then >>> run it, else eval it in a new window ( window { eval @e.text } ) >> >> >> Interesting... so this doesn't quite work, because within the window @e is >> not defined. This is definitely not what I expected... I guess this is an >> example of the type of funkiness with blocks that _why warned about. >> >> This is pretty weird though, because as I understood it the funkiness had >> to do with the definition of self within the block, but regardless of self >> I'd expect there to be a closure so @e would be available. I can work >> around the problem by defining a local variable reference to @e, so while >> >> window {eval @e.text} >> >> doesn't work >> >> e = @e; window {eval e.text} >> >> does. I guess instance variables are looked up on self, so closures don't >> work in quite the way I'd expect when it creates a new window, but I can >> work around it. >> >> That said... this doesn't end up solving my problem. I still haven't >> found a way to get or register a callback for when that window closes, and >> if I try to close an already closed window Shoes crashes, just the same as >> when I tried to close an already closed App. >> >> However, I did discover that Shoes has a method for seeing what apps are >> currently open... Shoes.APPS. By using this to compare against my list, I >> can avoid trying to close apps twice. I haven't figured a similar way to do >> bookkeeping for windows. >> >> -Kevin >> > >
