How can I make a simple text editing application in Shoes?
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.
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
我认为样本文件夹中有一个示例
链接地址: http://www.djcxy.com/p/79706.html