Martin DeMello wrote:
On Fri, Oct 10, 2008 at 12:05 PM, Nit K. [email protected]
wrote:
some smallish projects that solve this kind of problem?
Could you paste in some of your switch/case code? It would suggest
what bits of it want to be object oriented. Some nice high level
projects atop C-ish bindings are WxSugar and RubyGame. Also look at
STFL for an existing high level layer atop ncurses, complete with ruby
bindings
http://www.clifford.at/stfl/
Another neat but sadly abandoned TUI project is jttuii:
Best Open Source Mac Software Development Software 2023
martin
Have been checking a lot of ncurses wrappers. Sadly, many ruby projects
that have not released any files, or seem abandoned. I am currently
installing a newt-ruby binding released in 2002. No activity since. No
writeup, screenshots etc.
e.g Yesterday I wrote a file pager with an OK Cancel button. This is a
tiny example compared to FIELD or FORM. Now I would like to be able to
just add a button in a few lines of code, and not have to cut-paste into
3 places and change names of form or window variables etc.
So when i am creating all the fields, prior to the form being created I
have these lines:
# create the Ok field
label = "OK"
width = label.length+2
field = FIELD.new(1, width, @footer_row, @cols-20, 0, 0)
field.field_opts_off(O_EDIT);
field.set_field_buffer(0, "[#{label}]")
field.set_field_just(JUSTIFY_CENTER);
field.user_object = label
@fields.push(field)
Later, in my getch() loop I have this:
when KEY_ENTER
name=@curr_field_name;
if name == "OK"
return multiline_format(@content, @fieldwidth)
elsif name == "Cancel"
return ""
end
In my field_init_hook, I check for field. When the button gets the
focus, I make it reverse video:
if ix != 0
@fields[ix].set_field_back(A_REVERSE)
When you tab out, (in the field_term_hook):
@fields[ix].set_field_back(A_NORMAL)
I have vague/distant memories of Swing programming, so I was having
thoughts that each field should have a handler installed in some array
for each event. The field_init and term hook just call that handler with
field and value, and the handler invokes the handler of that field, if
exists.
When i create a FIELD, it (should) installs its handlers. This includes
on_enter, on_exit, on_selection and should also wrap the label (in
ncurses printing a fields label is totally unrelated to the field, and
happens after the form and window is created). Now I don’t want to get
overly complex and slow, for then one purpose of using text UI is
defeated.
So i really want to study a well-designed wrapper and see how the pros
do it.
I did look at wxSugar last night. Thanks for sharing your thoughts.