Search code examples
rubyshoes

Ruby shoes, para.cursor method


My question is concerning the "para" object. Where can I look up all the methods para has? I tried the shoesrb.com manual but all it says is that para is used to render text. I also tried #shoes at Freenode, but no one answered. Seems that no one is online.

I ask because I don't understand what the pounded (###) line does.

str, t = "", nil 
Shoes.app :height => 500, :width => 450 do 
  background rgb(77, 77, 77) 
  stack :margin => 10 do 
    para span("TEXT EDITOR", :stroke => red, :fill => white), " * USE ALT-Q TO QUIT", :stroke => white 
  end 
  stack :margin => 10 do 
    t = para "", :font => "Monospace 12px", :stroke => white 
    t.cursor = -1  ####### I don't understand this line
  end 
  keypress do |k| 
    case k 
    when String 
      str += k 
    when :backspace 
      str.slice!(-1) 
    when :tab 
      str += "  " 
    when :left  ### This is the part I'm interested in
      #### Can you suggest a method to put in here. It moves the cursor to the left.
    when :alt_q 
      quit 
    when :alt_c 
      self.clipboard = str 
    when :alt_v 
      str += self.clipboard 
    end 
    t.replace str 
  end 
end 

Does the para class have a cursor method? The official documentation has no answer. I am trying to extend this into a simple text editor but I can't understand how to move the cursor. I am a novice programer and new to Ruby as well.

Furthermore, where do the Shoes programmers hang out? I tried the mailing list, apparently it's out of service. Is there are specific forum or a different mailing list?


Solution

  • thanks for trying out Shoes.

    Yes, Red Shoes a.k.a. Shoes 3 apparently has a cursor method that lets you set the position of the cursor. It's undocumented though, I had to look up in the sources. Your milage may vary using it.

    The Shoes mailing list is definitely alive and active. Just send a message to [email protected] and you should automatically be signed up. That would be the best channel for help on Shoes, for the rest communication happens mostly through Github issues.