NCurses, scrolling of multiline items, "current item" pointer and "selected items"

Posted by mjf on Programmers See other posts from Programmers or by mjf
Published on 2014-05-27T00:11:51Z Indexed on 2014/05/27 3:40 UTC
Read the original article Hit count: 420

I am looking for hints/ideas for the best (most effective) way on how to scroll multi-line items as well as emphasizing of the "current item" and "selected items" such as:

1 FOO ITEM
  1 Foo sub-item
  2 Foo sub-item
  3 Foo sub-item

2 BAR ITEM
  1 Bar sub-item

3 BAZ ITEM
  1 Baz sub-item
  2 Baz sub-item

4 RAB ITEM

5 ZZZ ITEM
  1 Zzz sub-item
  2 Zzz sub-item
  3 Zzz sub-item
  4 Zzz sub-item

using NCurses (some combination of windows, sub-windows, pads, copywin? Uff! In fact, the lines could exceed the stdscr's width so that possibility to scroll left/right would be also nice - pads?)...

The whole items (including the sub-items) are supposed to be emphasized as full-width window/pad areas.

The "current item" (including it's set of lines) should be emphasized (i.e. using A_BOLD), selected set of items of choice (including the set of lines for each the selected item) should be emphasized in another way (i.e. using A_REVERSE).

What would you choose to cope with it the most effective NCurses way? (The less redrawals/refreshes the better and terminal is supposed to have the ability to change it's size - such as XTerm running under "floating window" management.)

Thank you for your ideas (or perhaps some piece of code where something similar is already solved - I was not able to find anything helpful on the Internet. I mean I am not going to copy/paste foreign code but programming NCurses properly is still somehow difficult to me).

P.S.: Would you suggest to "smooth-scroll" +1/-1 screen line or rather "jump-scroll" +lines/-lines of the items? (I personally prefer the latter one.)

Sincerely,

-- mjf

© Programmers or respective owner

Related posts about design-patterns

Related posts about user-interface