minicurses.lua


NAME

minicurses.lua - a stripped-down, easy-to-use access to the ncurses library


SYNOPSIS

  local MC = require 'minicurses'
  local LINES, COLS = MC.initscr()
  MC.move(0,15); MC.addstr('Welcome to minicurses :-)')
  MC.mvaddstr(2, 10, 'All those moments will be lost in time,')
  MC.mvaddstr(3, 16, 'like tears in the rain.  ')  
  MC.refresh()
  MC.echo(); c = MC.getch(); MC.noecho()
  MC.endwin()


DESCRIPTION

This module is a highly minimalised, stripped-down replacement for the abandoned lcurses module.
It works under Lua 5.4

Be aware that, following curses tradition, the arguments of move, mvaddstr and mvgetnstr are row, column
where row zero is at the top, and column zero is on the left.
This is not the same as x,y   it's the other way round.

stdscr is hidden, because it is the only window offered.

Since version 0.5, the wrapper-function getkey is provided, which returns the strings 'UP' 'DOWN' 'RIGHT' 'LEFT' 'END' 'HOME' 'PAGEUP' or 'PAGEDOWN' when those corresponding keys are pressed.


FUNCTIONS

addstr(str)
attrset(attribute)     (attribute is BOLD, REVERSE, or NORMAL)
cbreak()
clear()
clrtobot()
clrtoeol()
echo()
endwin()
getch()
getnstr(len)
hline(n)
LINES, COLS = initscr()
move(row, col)
mvaddstr(row, col, str)
mvgetnstr(row, col, len)
noecho()
nonl()
refresh()
vline(n)

getkey()
This function, which is not part of curses, is a thin wrapper round getch() which interprets the byte-sequences
^[[A ^[[B ^[[C^ [[D ^[[F ^[[H ^[[2~ ^[[3~ ^[[5~ or ^[[6~ and returns
'UP' 'DOWN' 'RIGHT' 'LEFT' 'END' 'INSERT' 'DELETE' 'HOME' 'PAGEUP' or 'PAGEDOWN' accordingly.
These escape-sequences are very portable. Other keys, such as the Function Keys, are not provided.


CONSTANTS

BOLD     REVERSE     NORMAL     LINES     COLS


INSTALLATION

This module is a LuaRock in luarocks.org/modules/peterbillam so you should install it with the command:
  $ su
  Password:
  # luarocks install minicurses


CHANGES

20220105 0.8 getkey() handles INS and DEL keys
20220101 0.7 remove keypad(); and initscr() returns LINES, COLS
20211230 0.6 add nonl()
20211213 0.5 add getkey(), hline(n), vline(n)
20211210 0.4 add mvgetnstr(row,col,len)
20211209 0.3 add getnstr(len)
20211206 0.2 add addstr, attrset, clrtobot, clrtoeol, keypad
20211204 0.1 first released version


AUTHOR

Peter J Billam,   http://peterbillam.fastmail.com.user.fm/comp/contact.html


SEE ALSO

  luarocks.org/modules/jjandresson/lcurses
  github.com/lcurses/lcurses/issues/13
  apt install ncurses-doc
  man ncurses
  /usr/include/ncurses.h
  gitlab.com/peterbillam/pjb_lua/-/tree/master/minicurses-0.0
  pjb.com.au/midi/midithru.html
  en.wikipedia.org/wiki/Box-drawing_character#Box_Drawing