how to get a correctly sized window in ncurses

2019-08-24 21:55发布

I am trying out ncurses programming in C on Linux (Mint) and am having a strange problem. I keep getting windows with the wrong number of columns for the first and final lines. For example, with this code found on StackOverflow

#include <ncurses.h>
int main(){
  initscr();

  WINDOW * win = newwin(10,50,10,10);
  box(win,0,0);
  wrefresh(win);

  wgetch(win);
  endwin();
  return 0;
}

I get this output:

          ┌─┐
          │                                                │
          │                                                │
          │                                                │
          │                                                │
          │                                                │
          │                                                │
          │                                                │
          │                                                │
          └─┘

As if the first and final lines are only three columns wide. If I add text to the window, using waddch, I can only add three characters to the top line as well.

Any help would be appreciated, I can't find examples of other people running into this issue on the web, but it's not the easiest thing to come up with a good search string for.

标签: c linux ncurses
1条回答
太酷不给撩
2楼-- · 2019-08-24 22:25

Looks like you're using one of those xterm look-alikes, and running into their omission of repeat-character, noted a little over a year ago in the ncurses FAQ.

查看更多
登录 后发表回答