Are there tree libraries / widgets for (n) curses

I wondered if there were any tree libraries for (n) curses.

I am trying to write a component that shows a folder tree, and I was curious if there is a ready-made curse component that could do this.

I checked the 'core' curses as well as libraries like CDK and I can not find anything.

If no one exists, I am not averse to creating my own, but I cannot find suitable textbooks on this subject, so any help in this regard will also be highly appreciated.

Thanks Ace

+6
ncurses curses
source share
4 answers

Depending on which programming language you use / want to use. I recently introduced a tree widget for Urwid, which is the curses widget library for Python: http://bitbucket.org/robla/urwid-treetools/src/

UPDATE 2015-09-06 - My patch was adopted a long time ago as part of Urwid , which now supports the widget tree in its core. The link in my original 2010 answer is still related to my old code, but is deprecated.

+1
source share

"I'm trying to write a component that shows a folder tree"

The CDK has a CDKFSELECT widget.

Displays a list of directories and files that may work for you, or the source code of CDKFSELECT can be used for your own solution.

 CDKFSELECT *fSelect = 0; /* Height of zero means to extent of xterm Width of zero means to extent of xterm */ int HEIGHT = 0; int WIDTH = 0; char *title = new char[strlen("Pick a file to open") + 1]; strcpy(title, "Pick a file to open"); char *prompt = new char[strlen("==> ") + 1]; strcpy(prompt, "==> "); char *directoryAttribute = new char[strlen("</B>") + 1]; /* bold */ strcpy(directoryAttribute, "</B>"); char *fileAttribute = new char[strlen("</N>") + 1]; /* normal */ strcpy(fileAttribute, "</N>"); char *linkAttribute = new char[strlen("</D>") + 1]; /* dim */ strcpy(linkAttribute, "</D>"); char *sockAttribute = new char[strlen("</D>") + 1]; /* dim */ strcpy(sockAttribute, "</D>"); boolean displayBox = TRUE; boolean displayShadow = FALSE; fSelect = newCDKFselect(pCdkScreen, TOP, LEFT, HEIGHT, WIDTH, title, prompt, A_NORMAL, '_', A_REVERSE, directoryAttribute, fileAttribute, linkAttribute, sockAttribute, displayBox, displayShadow); char *filename = activateCDKFselect(fSelect, 0); /* 2014-06-13, using DDD, filename being correctly populated by CDK */ /* do other stuff... */ /* free the memory of any dynamically created objects that were created with new or malloc, or such */ destroyCDKFselect(fSelect); delete [] title; delete [] prompt; delete [] directoryAttribute; delete [] fileAttribute; delete [] linkAttribute; delete [] sockAttribute; 
+1
source share

Look at the source code for the Midnight Commander ( http://www.midnight-commander.org/ ). It has a widget with storage.

0
source share

The dialog program (with a documented library interface) has a "tree" . The program works with (n) curses, and unlike CDK , it is suitable for use with UTF-8.

dialog - tree view

It also has a file (/ directory) widget of choice.

dialogue - file selection

There is also wcd (although like mc , reusing the library is vague). However, this is a good example of what the OP probably wants:

screenshot converted from wcd page

Regarding urwid , which is controversial. Under the hood, you may not have curses. What is the treeview script screenshot for?

urwid treeview

and on my Debian / testing system, the script does not use ncurses. It is hardcoded (i.e. uses raw_display ).

0
source share

All Articles