The Accidental Rubyist

invalid byte sequence in UTF-8

Archive for September 2010

Multiple splits (vim inspired)

leave a comment »

Tired of creating Splitpanes within Splitpanes, the Java way. Here’s a much simpler way to get what you want in ONE widget, with very little programming involved.

I’ve called it the VimSplit since its inspired by Vim.

splits in ncurses

Of course, you can expand and contract them. You can stack more. Much simpler than the earlier SplitPane which i hope to throw out the window.

Change one character, and it the same screen goes from a Vertical split to a horizontal one.

changed orientation of split

Advertisements

Written by totalrecall

September 29, 2010 at 10:11 am

Posted in ruby

progress bars in rbcurse

with 4 comments

progress bars

rbcurse has a progress bar – 2 styles, one is the colored one, and one the “classic” style.

Here’s the code for both (using the App class):

@pbar = progress :width => 20, :bgcolor => 'white', :color => 'red'
@pbar1 = progress :width => 20, :style => :old

Written by totalrecall

September 27, 2010 at 10:08 am

Posted in ruby

tabular data in listboxes and textviews

leave a comment »

I’ve done a retake on tables or tabular data. The Table class with its MVC architecture and editability is a huge class. I wanted something small and simple. A tiny code base for just printing tables, no editing. No moving, hiding etc. Just simple throwing tabular data, letting a user scroll, select a row…

First I integrated the excellent terminal-table. However, I had to make changes to that gem, and that meant installation issues and keeping it up-to-date. So i’ve hacked a simple table display in a small file, which i can use for most table data. Easy to maintain, and easy to debug or modify!

I’ve attached it to a listbox and to a textview. I might give it its own simple widget which is aware of columns without getting into models, renderers etc. The syntax from terminal-table is supported, I’ve used their examples. It does not do colspan, and center alignment. Enjoy. Ruby rocks!

Written by totalrecall

September 25, 2010 at 11:16 pm

Posted in ruby

Scrollbars and other fun

leave a comment »

I just can;t stop playing around.Creating new stuff everyday, and not even fully testing them 😦

Did a quick scrollbar class yesterday. Earlier Lists and Tables and Editboxes used to paint a scrollbar inside their code. How about a scrollbar class that can be created thusly:

Scrollbar.new @form, :parent => list

So this scrollbar takes its coordinates from the parent, and registers itself as a listener to its traversal event. So now its ready to display and move around as the user moves down his list.
http://i53.tinypic.com/33ephzb.jpg

Written by totalrecall

September 25, 2010 at 11:20 am

Posted in ruby