【问题标题】:Ncurses, updating screen and breaking a loopNcurses,更新屏幕并打破循环
【发布时间】:2014-01-25 23:30:19
【问题描述】:

我正在尝试像ncurses 一样创建htop

我正在做一个无限循环来更新信息和让它停止的条件。 但它不会自我更新,因为它想在之前检查输入。

我该怎么办?

【问题讨论】:

    标签: process ncurses htop


    【解决方案1】:

    htop author here -- htop 本身是用 ncurses 编写的。需要使用 halfdelay() 函数使输入函数超时。

    http://linux.die.net/man/3/halfdelay

    【讨论】:

      【解决方案2】:

      在初始化curses参数时,可以使用next函数

      timeout(TIME_IN_MILLIS);
      

      代码示例:

      initscr();
      cbreak(); 
      noecho();
      nonl();
      
      timeout(1000);
      mvprintw( 1, 1, "%s", "Hello World!" );
      refresh();
      getch();
      endwin();
      

      【讨论】:

        猜你喜欢
        • 2015-08-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-12-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-12-05
        相关资源
        最近更新 更多