3

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.

GEOCHET
  • 21,119
  • 15
  • 74
  • 98
nearly_lunchtime
  • 12,203
  • 15
  • 37
  • 42

2 Answers2

6
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
  • 23,810
  • 2
  • 71
  • 76
0

I think there's an example in the samples folder

rogerdpack
  • 62,887
  • 36
  • 269
  • 388