Sunday, November 11, 2007

ANNOUNCE: cwidget

I've just uploaded the first release of libcwidget to Alioth and NEW. libcwidget is a high-level C++ library for developing user interfaces that run in a terminal using curses as the display and input layer. It uses widget abstractions similar (but of course not identical) to those found in GTK+ and Qt, with signals and slots provided by libsigc++.

Background



Back when I started writing aptitude, I had one general goal:

Just because it runs in a terminal doesn't mean it has to suck.


I tried to apply this in the user interface, but I also applied it internally. The curses programs I looked at before writing aptitude all had very ad-hoc UIs. In many cases the code was structured with each "view" that appeared mapped to a custom C function call; if the author was feeling ambitious, similar-looking screens might be abstracted into a single function call, but the basic structure of the interface still reflected the call graph of the program.

aptitude had a primitive interface abstraction layer from the get-go; over the years, I borrowed ideas from GTK+ and restructured this layer into a full widget set. libcwidget is this code, disentangled from the guts of aptitude and slightly cleaned up. Because of its history, it is missing widgets that aptitude doesn't need (like a multi-line text editor), but it provides an extensible base that you can build upon.

Getting cwidget



The cwidget library is available (both as source and as an i386 .deb) from the cwidget Alioth releases page. There is also API documentation automatically generated from the upstream repository, which, while it is woefully incomplete, should provide some information: I've tried to write Doxygen tags into most of the code I've added in the last 4 years or so.

The upstream code repository is in git (because what fun is a new project if you don't learn a new VCS?) and available here. To retrieve a copy of the repository for yourself, run this command:

git clone git://git.debian.org/git/cwidget/head cwidget

8 Comments:

At 12:54 AM, Anonymous Anonymous said...

Although a C++ developer by myself, I find your language choice the greatest disadvantage. That's why I'll stick to STFL, which doesn't only support C/C++, but also Perl, Python, Ruby and SPL.

 
At 7:36 PM, Blogger dburrows said...

I hadn't heard of STFL before, thanks for the link. I certainly am not claiming that cwidget will solve all the world's curses problems: aside from anything else, it's newly yanked out of the aptitude source code and needs some love before it's a truly general library.

At a quick glance, I think the libraries compare like this:

Features SFTL has that cwidget doesn't:

* Bindings in many languages.
* A simple description language for creating UIs.
* vbox and hbox containers (cwidget only has a finicky table container).
* ... probably more I'm not aware of.

Features cwidget has that SFTL doesn't:
* A proper top-level main loop; you don't have to structure your program as a sequence of input "screens".
* A defined threading model and support for injecting events from background threads to foreground threads.
* Support for defining your own custom widgets at the same level as the predefined widgets.
* Events are handled using signals and slots.
* Support for laying out structured and styled text.
* Support for overlapping widgets.
* Widgets for drop-down menus and hierarchical trees.
* The ability to dynamically hide and show widgets, and dynamically manipulate them in other ways (e.g., scrolling around a text view or replacing the text in it).
* It's a C++ library.


In general, it looks to me like cwidget and STFL are solving different problems. STFL aims to be a library for presenting forms on the terminal that are more complicated than you can do with dialog. This is a fine goal and frankly probably one that's useful to more people than what cwidget provides (as you pointed out). cwidget is a backend for applications that have a moderately complex UI: programs like mutt, links, emacs and mc. I think there are something like three people still writing new code for this sort of program, and two of them don't know C++, so the audience is rather limited. ;-)

If I had an infinite amount of time and nothing to do but develop cwidget, I think that it would be interesting to provide bindings to other languages and even more interesting to have a UI description language. But since I have a finite and limited amount of time, I think I'll worry about making the documentation not suck first and plugging the gaping holes in the set of standard widgets that it provides. :-)

 
At 4:26 PM, Blogger Łukasz said...

Hi! Now this is really something! I wanted to write sth like this a few years ago but didn't have the time and still lacked the knowledge about UIs. I think your work is more than welcome - there are people still using console apps instead of those fancy GTK/Qt ones ;) I hope to look into your code as soon as I have some spare time. Thanks again!

 
At 8:15 PM, Blogger oakleyses said...

uggs outlet, uggs on sale, ray ban sunglasses, ray ban sunglasses, louis vuitton, michael kors outlet online, oakley sunglasses wholesale, christian louboutin outlet, louis vuitton, uggs outlet, louis vuitton outlet, polo outlet, prada handbags, nike free, chanel handbags, longchamp outlet, michael kors outlet, replica watches, louis vuitton outlet, oakley sunglasses, michael kors outlet online, prada outlet, michael kors outlet online, longchamp outlet, burberry handbags, michael kors outlet, kate spade outlet, ray ban sunglasses, longchamp outlet, louis vuitton outlet, oakley sunglasses, nike air max, oakley sunglasses, replica watches, ugg boots, polo ralph lauren outlet online, ugg boots, gucci handbags, jordan shoes, cheap oakley sunglasses, michael kors outlet online, christian louboutin uk, burberry outlet, tory burch outlet, tiffany and co, christian louboutin shoes

 
At 8:17 PM, Blogger oakleyses said...

uggs outlet, uggs on sale, ray ban sunglasses, ray ban sunglasses, louis vuitton, michael kors outlet online, oakley sunglasses wholesale, christian louboutin outlet, louis vuitton, uggs outlet, louis vuitton outlet, polo outlet, prada handbags, nike free, chanel handbags, longchamp outlet, michael kors outlet, replica watches, louis vuitton outlet, oakley sunglasses, michael kors outlet online, prada outlet, michael kors outlet online, longchamp outlet, burberry handbags, michael kors outlet, kate spade outlet, ray ban sunglasses, longchamp outlet, louis vuitton outlet, oakley sunglasses, nike air max, oakley sunglasses, replica watches, ugg boots, polo ralph lauren outlet online, ugg boots, gucci handbags, jordan shoes, cheap oakley sunglasses, michael kors outlet online, christian louboutin uk, burberry outlet, tory burch outlet, tiffany and co, christian louboutin shoes

 
At 12:57 AM, Blogger jeje said...

Le jeu Air soldes basket asics femme Max Quarter et Air Max Pure sont également asics gel noosa tri 9 w femme des baskets de basket-ball Nike qui asics gel nimbus 18 Chaussures offrent les fonctionnalités de grande qualité nike air max 90 jacquard femme pour lesquelles Nike est célèbre. Une nike air jordan 1 retro high og carmine personne que je n'étais jamais prêt asics gel lyte iii kakishibu tan tan à faire était de prendre des suppléments avis sur chaussures asics illégaux ou tout type d'hormone de croissance. nike roshe run noir cdiscount

 
At 12:27 AM, Blogger yanmaneee said...

yeezy shoes
yeezy
supreme clothing
chrome hearts online store
yeezy 500
goyard handbags
longchamp
bape outlet
kyrie 6
hermes bags

 
At 1:22 AM, Anonymous mokktar sultan said...

Keep up the good work :)

1. (شركة تنظيف خزانات بالرياض )
2. (شركة تنظيف خزانات بجدة)
3. (شركة تنظيف خزانات بمكة)
4. (شركة تنظيف خزانات بالطائف)
5. (شركة تنظيف خزانات بالمدينة )
6. (شركة تنظيف خزانات بالدمام )

 

Post a Comment

<< Home