The Accidental Rubyist

invalid byte sequence in UTF-8

Archive for December 2009

Battle of the cursor over

leave a comment »

I’ve spent the last 3 days or so battling an issue with getting the cursor position correct on the screen
when the user is editing a textarea that is within a scrollpane. The insertion point in the textare was fine but the cursor display which is handled by the application at a higher level was going out of synch when the user scrolls the pane.

All it took was a couple lines of code, a couple extra variables so the textarea knows its been scrolled vertically or horizontally, but it took 3 painful days to figure that out. Still not perfect but at least the cursor and insertion point are always in synch, even if the app continues to show the cursor outside the scrollpane when the insertion point gets hidden due to scrolling (hehe). I guess that will get taken care of by the time i’ve got all the widgets upgraded.

Now I am back to the opinion that GUI’s really don’t have a cursor, although widgets know how to appear highlighted when focus falls on them. Textareas and textfields *do* however have an insertion point (perhaps caret is the correct term). Thus, the widget (rather than the app) should maintain and display a caret. This will take care of issues like making the caret invisible if the insertion point is overlapped or scrolled off, or moving it around.

# Overheard on the net

Also, Python strives for readability. I feel the existence 
and popularity of Ruby has been a net positive for Python, 
because it keeps programmers who don't greatly value 
readability away from our Python codebases.

— Python, Ruby, Power

Written by totalrecall

December 31, 2009 at 6:52 pm

Posted in rbcurse

Automated testing for a visual (ncurses) app

leave a comment »

As i work more on rbcurse, I am wondering how does one do automated testing for a software that is primarily visual. Whenever i make changes, I need to ensure that things still show correctly – the cursor position on screen, widget placement, text placement, text wrapping, highlighting and attributes of widget.

Currently, i have no way of knowing what’s broken.

One thought that comes is to take some kind of screen dump and compare screen dumps when testing.
Thoughts and pointers welcome.

# print between pattern *exclusive*

vim -e -s -c 'g/START/+1,/END/-1 p' -cq t.t.t


Written by totalrecall

December 31, 2009 at 6:02 pm

Posted in ncurses

Resuming rbcurse

leave a comment »

I am back (finally) — resuming rbcurse. I spent a month writing shell-scripts — something to track bugs.
There’s been a lot of progress with rbcurse in the last 2 days. Last month, when i dropped off, I had a non-editable component working inside a scrollpane. I had tabbedpanes, splitpanes and scrollpanes functional, but the split and scrollpanes needed to be prepared to work with real objects inside them.

Other widgets which will be placed inside panes, such as lists, textareas and tables (OMG!!! *shudder*) need to be modified so they don’t directly update the window (that’s how the original simple version does it). I am calling these “buffered” versions since they actually write to a buffer which the pane display as appropriate (after clipping, panning, hiding, showing etc, if need be). These buffered versions, of course, work outside panes as before, no change.

I’ve just got an editable textarea working inside a scrollpane, however I am working out various cursor related issues. Problem compounded by the time-off.

For example, when i pan the scrollpane, the cursor blinks at the same point it was at. Editing happens at the correct place, but the cursor needs to scroll too. Up-key and down-key can take the cursor outside the scrollpane since the textarea really doesn’t have a clue what it’s inside.

I tend to get distracted easily due to the complexity of figuring out where to make a change, esp due to the time off. I hope within a month or 2, we can see fully functional scroll and splitpanes with a sample application.

I’ll be working through the holidays since I have nothing else to do.
Happy holidays you lucky guys with a life 🙂


The rest of you: I think your Eclipse just finished launching, so you can get back to work now.
— steve yegge

Written by totalrecall

December 29, 2009 at 8:49 pm

Posted in ncurses, ruby