tags:

views:

158

answers:

2

I am trying to write a simple tool using Shoes. This will indent code for an obscure scripting language we use. It has one large text box and one button. I have the program working on the command line, but am having no luck wrapping this up in Shoes. If anyone could give a working example of an app that does the following tasks to get me up and running that would be very useful.

When the button is clicked I want to: Get the text, split into an array of lines, (indenting happens here), join the lines again and refresh the text box with the new data.

+3  A: 
Shoes.app :width => 300, :height => 450 do
  @text = edit_box :width => 1.0, :height => 400
  btn = button 'Indent!'
  btn.click do
    ugly_txt = @text.text
    lines = ugly_txt.split $/ #the record separator
    lines.collect! { |line| '  ' + line } #your indentation would replace this
    @text.text = lines.join $/
  end
end
Pesto
A: 

I think there's an example in the samples folder

rogerdpack