How can I make a simple text editing application in Shoes?

I am trying to write a simple tool using Shoes. This will be the indented code for the obscure scripting language that we use. It has one large text box and one button. I have a command line program, but I was not lucky to wrap it in Shoes. If someone could give a working example of an application that performs the following tasks to start me up and running, that would be very helpful.

When the button is pressed, I want: Get the text, split into an array of lines (there are indents), append the lines again and update the text field with new data.

+3
source share
2 answers
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
+6

, samples

0

Source: https://habr.com/ru/post/1707931/


All Articles