I’m working on a toy project, implementing a desktop client of the popular card game Dominion. I thought it would be interesting to display the UI in the terminal, using the ncurses library.
I need to display things like the player’s hand, cards they’ve played, and cards they can buy. I envisioned displaying these as ncurses menus, arranged inline on the screen.
What I can’t figure out is how to communicate focus to the user. For example,
| | | |
| Copper | | >Adventurer< |
| Copper | | Chapel |
| Copper | | Moat |
| >Copper< | | Thief |
| Copper | | |
| | | |
| | | |
Populated menus have the cursor activated (symbolized by the > < entries) when the menu is visible. I want to be able to have one menu active at once, by having one visible or otherwise special cursor that I can build the workflow around.
How can I do this? At the highest level what I want is to have lists of items on the screen, where the user can make selections based on the logic I’ve set up.
ncurses allows you to mess with the coloring of menus using functions like
set_menu_fore,set_menu_backandset_menu_grey. This is the route I took. Another idea I had (but later decided against due to too much bookkeeping) was to recolor the menu windows usingwattronandwattroff.