Lua lcurses 缺失教程/示例。

我已经安装了lcurses(通过luarocks和luajit),但我找不到任何教程。

我正在阅读关于C语言和ncurses的内容,试图在lua上复制代码,但lua端口不是C库的直接匹配。

这里是两个“Hello World”示例: lua版

package.path = package.path .. ';/opt/luarocks_pkg/share/lua/5.1/?.lua';
package.cpath = package.cpath.. ';/opt/luarocks_pkg/lib/lua/5.1/?.so';

local curses = require('curses');
local os = require('os');

local function main()

  --start curses mode
  curses.initscr()
  --disable line buffering
  curses.raw();
  --switch off echoing
  curses.echo(false);

  --initialize standard screen object
  local stdscr = curses.stdscr()
  --clear screen
  stdscr:clear();
  --move cursor at (10,10) and print, here only update the stdscr structure
  stdscr:mvaddstr(10,10,'Hello World');
  --force curses system to dump the contents on the screen
  stdscr:refresh();
  --wait for keyb input
  stdscr:getch();
  --frees the memory taken by curses sub-system and its data structures and puts the terminal in normal mode
  curses.endwin();

  return(0);
end
main()

c版

#include <ncurses.h>

int main()
{
    initscr();          /* Start curses mode          */
    printw("Hello World !!!");  /* Print Hello World          */
    refresh();          /* Print it on to the real screen */
    getch();            /* Wait for user input */
    endwin();           /* End curses mode        */

    return 0;
}

在lua中复制C代码需要很长时间(学习如何使用lcurses),因此我将不胜感激,如果有人可以帮助我报告我可以找到**lcurses lua教程**的地方。

点赞
用户869951
用户869951

尝试查看 lcurses 文档。该文档指出 API 相同,因此你应该能够从你系统的 curses 或 ncurses man 文档中获取详细信息。如果你不能执行 "man ncurses" 或 "man curses"(如该链接所述),则可以在以下位置找到一些在线版本:

ncurses 的介绍和教程应该提供你所需的内容。除此之外,你将必须购买相关的书籍。再往后就没有什么帮助了,所以无论如何这个答案都应该被关闭。

2014-07-10 12:19:02