SVN / public / code / vorlesung-03 / NcursesDemoMain.cpp

Revision 1679
Date2026-05-05T16:08:54+02:00
Committerhb1003
Download
// Copyright 2026, University of Freiburg
// Chair of Algorithms and Data Structures
// Author: Hannah Bast <bast@cs.uni-freiburg.de>

#include "NcursesDemo.h"
#include <ncurses.h>
#include <unistd.h>

// Awesome Ncurses demo, useful for Ü3.
int main() {
  startNcurses();
  // mvprintw(row, col, "Hier könnte Ihre Werbung stehen");
  // refresh();

  // Terminate when ESC is pressed, or after 5 seconds.
  for (int i = 1; i <= 10'000; ++i) {
    attron(COLOR_PAIR(1) | A_REVERSE);
    mvprintw(row, col, "  ");
    attroff(COLOR_PAIR(1) | A_REVERSE);
    refresh();
    int keycode = getch();
    if (keycode != ERR) {
      mvprintw(2, 2, "Code of key pressed: %3d", keycode);
      refresh();
    }
    if (keycode == 27) {
      break;
    }
    move(keycode);
    usleep(1'000);
  }

  endNcurses();
}