The Accidental Rubyist

invalid byte sequence in UTF-8

Archive for December 2008

Video grabs of ruby curses

leave a comment »

NOTE: updated demo 1 on Dec 29 with textarea bug fixes, para wrapping, and a quick-dirty file chooser using the existing message box.

Uploaded some video captures of the test programs.

Note: Textarea had wrapping bugs in demo, subsequently fixed.
Demo 1: full screen demo of most widgets (new one uploaded 12/29/08,  7 MB)
Demo 2: message boxes (4)
Demo 3: tabbed pane
Demo 4:combo’s with different insert policies and vertical alignments.

Note that in these demos, I am showing both tabbing thru fields, and often invoking buttons by using the Alt-combination. No distracting voiceovers, but my apologies that you will see a watermark in the middle.

My registered version of SnapZ Pro 2, hangs my oldish Powerbook, so i had to look for free alternatives. ScreenFlick is the best of what I tried, but leaves a watermark.

Screen Movie Recorder (link) is a good option with no watermarks, but creates a 4 GB file taking 30 minutes to do so. Tried converting it to smaller sizes but go junk.

Screenium creates only a 30 second file, so forget it. If anyone knows how i can use ffmpeg from the command line, to do video grab of Terminal (i supposed /dev/ttys000) (NOT X11), would appreciate that.

Written by totalrecall

December 26, 2008 at 2:56 pm

Posted in ncurses, rbcurse, ruby

Merry Christmas Updates

leave a comment »

Lots of bells and whistles for Christmas. Such as:

Used ACS_ codes to make neater boxes. The earlier ascii ones were copied from Links. I hope all terminals can access the ACS codes.

Radio and checkbuttons correctly align when align_right set to true.

In Listboxes and buttons, where cursor position is not important, the cursor instead of being placed at the beginning of field, is appropriately placed in the button brackets, or row of listbox.

Checking bold or pressing Alt-B makes various labels bold

Checking bold or pressing Alt-B makes various labels bold

Checking reverse (M-R) makes labels reverse

Checking reverse (M-R) makes labels reverse

Improved the test program screenshot to look more compelling.

nc_screenshot_122508

Other updates over the last couple days: combo popups can be configured to popup above, below, centered or overlapping the entry field.

selecting value changes of check and radio buttons

selecting value changes alignment of check and radio buttons

scrolling through list changes status message at bottom

scrolling through list changes status message at bottom

Selecting Cyan (M-y) changes background or color of some widgets

Selecting Cyan (M-y) changes background or color of some widgets

Textarea updates giving meaningful events that are very close to the changes that happened (barring wrapping changes) – using InputDataEvent class.

Buttons use mnemonics for hotkeys, as well as the ampersand.

For the new year, I’ll probably work on a multi-column list, either extend the existing Listbox, or introduce a singleColumn and MultiColumn data class, as well as RowRenderers or some such simple MVC. Will try to keep it simple, yet extendable.

And before I forget, wish you all a Merry Christmas and Hannukah!

Written by totalrecall

December 25, 2008 at 10:01 pm

Posted in rbcurse

Thoughts on event firing

leave a comment »

Do UI’s fire events only when someone is listening, or always.

Firing an event often means creating an event object, doing some calculations of what changes were made and what positions they happened in.
Sometimes, one editing event can result in 2 events such as first a delete event and then an insert. Thus, it could be efficient to send events only when an object is listening. Currently, events are fired AFTER default behavior. This hopes to ensure that any exception or problem in a user-defined handler does not result in bypassing default behaviour.

However, i just came across this interesting line on ActionListener. It’s the opposite of what I am doing.

The root event class for all component-level input events. Input events are delivered to listeners before they are processed normally by the source where they originated. This allows listeners and component subclasses to “consume” the event so that the source will not process them in their default manner. For example, consuming mousePressed events on a Button component will prevent the Button from being activated.

Written by totalrecall

December 24, 2008 at 10:02 pm

Posted in rbcurse

Event model evolving

leave a comment »

Rubycurses’ event model is undergoing a lot of change currently: in terms of parameters passed. Last night, modified it so multiple actions can be bound to an event of an object.

However, the parameters passed to an event when fired is what is also undergoing change, as i test and play around with the same. At present way, we reference to the current object (that underwent the event). That gives the user flexibility to call whatever methods s/he wants. However, the user then has to go through documentation to figure out what he wants.

Thus, I am thinking of moving all events to an Event object (as is already the case with ListData events). The Event object will contain a ref to the source object, as well as a relevant method such as selected_item, selected_index, value, event_type, etc as appropriate to that class of events.

In addition, I might change some event names, (current ones were taken from Tk, but I’ve left Tk behind long back). I also need to change some method names before this library starts getting used.

Written by totalrecall

December 23, 2008 at 2:54 pm

Posted in rbcurse

vt100 and vt200

leave a comment »

I was pleasantly surprised to find that vt100 and 200 do send keycodes that work correctly with rbcurse. However, in the menubar, highlighting of focussed menuitems and hotkeys was not happening. Made some changes so that highlighting works in both vt100/200 and also screen/xterm.

I am mostly testing under screen and xterm. Are there any other major TERM’s I should check out.

Written by totalrecall

December 22, 2008 at 1:14 pm

Posted in rbcurse

xterm-color key issues fixed

leave a comment »

xterm-color blows as a TERM. Even vt100/200, xterm (and xterm-256color) send proper values for F1..F4 and backtab. xterm-color sends a 27,79,80 for F1 (i.e., three keys). So I spent the wee hours of last night hacking some ugly lines into window.getchar() to trap these combinations.

Then i found that backtab is 27,79,81. Added more ugly code for that. But that’s about it.

What is problematic is that xterm-color sends 27,79 for M-O (Meta or Alt O). I checked manver’s VER::keyboard.rb and for xterm-color it (incorrectly) sends “M-O” followed by the character “P”, although the code appears to check for this combination (See SPECIAL_KEYS in his code).

So now my getchar() will send a M-O or F1 correctly for xterm-color, although the M-O takes a little longer to be passed to your program since it waits for getch to return -1.

I suggest avoiding xterm-color since other keys could also bomb at some time. Please tell me if there are fixes for it. I like “screen” the best, although it doesn’t show underlines.

Written by totalrecall

December 22, 2008 at 1:11 pm

Posted in ncurses, rbcurse

Hotkeys with Labels (and other buttons)

leave a comment »

We may associate a label with any field/widget with the label_for method. If a mnemonic has been defined for the label, it will register the ALT-key, to transfer keyboard focus to that field.

label hotkeys will transfer focus to buddy fields

label hotkeys will transfer focus to buddy fields

If that field is a button (responds to fire), its fire will be called.

e.g. we had created some fields in a loop. Now we add mnemonics to them.


      mnemonics = %w[ n l r p]
      %w[ name line regex password].each_with_index do |w,i|
        field = Field.new @form do
          name   w
          row  r
          col  c
          display_length  30
          set_buffer "abcd "
          set_label Label.new @form, {'text' => w, 'mnemonic'=> mnemonics[i]}
        end
        r += 1
      end
 

We had created a label for 2 radio buttons. Now we can associate the label with one radio button.


      colorlabel = Label.new @form, {'text' => "Select a color:", "row" => 21, "col" => 22, "color"=>"cyan", "mnemonic" => 'S'}
      # after declaring radio1
      colorlabel.label_for radio1
 

We had used the underline property to create hotkeys for buttons. Now we use the same property to create hotkeys for radiobuttons, checkboxes and togglebuttons as can be seen in the screenshot below.

Button hotkeys execute the fire method

Button hotkeys execute the fire method

The underline property was taken from Tk, however, i think its a dirty hack. A mnemonic is a better idea. I am considering phasing out underline in favor of mnemonic.

In other news, combo selection behaviour has been improved. Check the tweets on the sidebar for small changes/enhancements.

Written by totalrecall

December 21, 2008 at 1:13 am

Posted in ncurses, rbcurse, ruby