The Accidental Rubyist

invalid byte sequence in UTF-8

TabbedPanes in ruby-curses

with one comment

Tabbedpanes (multiple overlapping forms as you see in preference panes) may now
be made quite simply as follows:


      @tp = RubyCurses::TabbedPane.new @window do
        height 12
        width  50
        row 5
        col 10
      end

      ## add a tab with label Language

      @tab1 = @tp.add_tab "Language"

      ## get the form associated with the tab, so we can create widgets/fields on it

      f1 = @tab1.form


      ## a quick example of some checkboxes is as follows

      @tab3 = @tp.add_tab "Editors"
      f3 = @tab3.form
      butts = %w[ Vim Emacs Jed Other ]
      row = 3                           # starting row
      butts.each do |name|
        RubyCurses::CheckBox.new f3 do
          text name
          row row
          col 4
        end
        row +=1
      end

      ## ask the tabbed pane to display itself and to handle keys
      @tp.show
      @tp.handle_keys

tabbed pane first pane/form

tabbed pane first pane/form

nc_tabbedpane_set

Key movement:

Buttons have been used for the tab labels on top. Currently, pressing a button reveals the tab form. After tabbing through buttons, focus goes to the open tab. After the last field on the tab, focus comes back to the buttons.

I have looked at various implementations on my system. In the Terminal preferences, pressing the button reveals the tab form. In others, when the button gets focus the tab is revealed. I am not sure what standard behaviour is. Looking for feedback.

nc_tabbedpane_edit

Issues

I have just coded this. Not much testing. Currently, buttons have 2 states: focussed and unfocussed. However, here we need 3 states: selected (this button’s tab is open), focussed (cycling through buttons) and unfocussed.

Other widget

Please do let me know any other widgets that would be useful. If you can give me a link to details (methods, properties) as well as a description of behaviour that would help.

I got stalled on combo-boxes, since I am not sure of standard behaviour. The examples I see on my system ( in iTunes, Firefox location bar, etc) all have differences in behaviour.

Location: http://github.com/rkumar/rbcurse/tree/master

Advertisements

Written by totalrecall

December 14, 2008 at 11:44 pm

Posted in ncurses, rbcurse, ruby

One Response

Subscribe to comments with RSS.

  1. You are making amazing progress on your curses library! Thank you for this great contribution to the Ruby world!

    John

    December 15, 2008 at 10:42 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: