Refresh behavior (nCurses)

2

I've been studying the ncurses library recently and I ended up with a question: What exactly does the refresh function do?

Searching a little I understood that it should update the screen, showing the output formatted. Basically I would make all the changes on the "screen" buffered and only after the refresh that the output would actually appear.

But doing some tests, I realized that output appears with or without the refresh. In the program below it is quite simple testing the inputs and position manipulation in mvprintw:

#include <ncurses.h>
#include <string.h>

int main() {
  char mesg[] = "Just a String";
  int row, col;

  initscr();
  getmaxyx(stdscr, row, col);

  while(true) {
    //refresh();
    mvprintw(row/2, (col - strlen(mesg))/2, "%s", mesg);

    mvprintw(row-2, 0, "This screen has %d rows and %d columns\n", row, col);

    char c = getch();
    if (c == 'e') { row++; }
    else if (c == 'q') { row--; }
    else if (c == 'a') { col--; }
    else if (c == 'd') { col++; }
  }

  getch();
  endwin();

  return 0;
}

Removing the refresh or putting it in any part of the code, being inside the loop or out, apparently does not change anything at the output of the program.

What exactly is the functionality of refresh () ??

    
asked by anonymous 10.11.2018 / 15:41

0 answers