I’ve not posted anything in a long time, so I thought I’d dig up something from a long time ago. Once boring day, many moons ago, I stumbled upon a simple console-based Solitaire game, tty-solitaire by Murilo Pereira.




I made a few small tweaks:


I wanted to have a black bacground rather than the default green, so I swapped no-brackground-color and background-color:

static int no_background_color = 1; //originally default is not set (0)
  static const struct option options[] = {
      {"background-color", no_argument, &no_background_color, 0}, //changed from 1 to 0

I landed up also editing the greeting keys to match the changes in the keyboard section.


I changed the pointer to * to ^ and selected from @ to *:

void draw_cursor(struct cursor *cursor) {
  if (cursor->marked) {
    mvwin(cursor->window, cursor->y, cursor->x);
    waddch(cursor->window, '*'); //from @
  } else {
    mvwin(cursor->window, cursor->y, cursor->x);
    waddch(cursor->window, '^'); //from *


I also changed a few keycodes:

  • Use , and . instead of n and m to add or select or de-select more cards,
  • Enter and Backspace to select the entire stack, or reset the selection to the top card.
  • And, do this with keycode 10 and 127, since KEY_ENTER and KEY_BACKSPACE constants do not work on mac keyboards respectively.
static void handle_card_movement(struct cursor *cursor) {
      case 'm':
      case '.': //added
      case 'M':
      case '\n': //added KEY_ENTER
      case 'n':
      case ',': //added
      case 'N':
      case 127: //added KEY_BACKSPACE

Have fun!