Class posix.curses.chstr

Curses attributed string buffers.

An array of characters, plus associated curses attributes and colors at each position.

Although marginally useful alone, the constants used to set colors and attributes in chstr buffers are not defined until after curses.initscr () has been called.

Methods

posix.curses.chstr:dup () Duplicate chstr.
posix.curses.chstr:get (o) Get information from the chstr.
posix.curses.chstr:len (cs) Retrieve chstr length.
posix.curses.chstr:set_ch (o, int[, attr=A_NORMAL[, rep=1]]) Set a character in the buffer.
posix.curses.chstr:set_str (o, s[, attr=A_NORMAL[, rep=1]]) Change the contents of the chstr.

Metamethods

posix.curses.chstr:__call (len) Initialise a new chstr.


Methods

posix.curses.chstr:dup ()
Duplicate chstr.

Returns:

    chstr duplicate of cs

Usage:

    dup = cs:dup ()
posix.curses.chstr:get (o)
Get information from the chstr.

Parameters:

  • o int offset from start of cs

Returns:

  1. int character at offset o in cs
  2. int bitwise-OR of attributes at offset o in cs
  3. int colorpair at offset o in cs

Usage:

      cs = curses.chstr (10)
      cs:set_ch(0, 'A', curses.A_BOLD, 10)
      --> 65 2097152 0
      print (cs:get (9))
posix.curses.chstr:len (cs)
Retrieve chstr length.

Parameters:

  • cs chstr buffer to act on

Returns:

    int length of cs

Usage:

      cs = curses.chstr (123)
      --> 123
      print (cs:len ())
posix.curses.chstr:set_ch (o, int[, attr=A_NORMAL[, rep=1]])
Set a character in the buffer. ch* can be a one-character string, or an integer from string.byte

Parameters:

  • o int offset to start of change
  • int |string ch character to insert
  • attr int attributes for changed elements (default A_NORMAL)
  • rep int repeat count (default 1)

Usage:

      -- Write a bold 'A' followed by normal 'a' chars to a new buffer
      size = 10
      cs = curses.chstr (size)
      cs:set_ch(0, 'A', curses.A_BOLD)
      cs:set_ch(1, 'a', curses.A_NORMAL, size - 1)
posix.curses.chstr:set_str (o, s[, attr=A_NORMAL[, rep=1]])
Change the contents of the chstr.

Parameters:

  • o int offset to start of change
  • s string characters to insert into cs at o
  • attr int attributes for changed elements (default A_NORMAL)
  • rep int repeat count (default 1)

Usage:

      cs = curses.chstr (10)
      cs:set_str(0, "0123456789", curses.A_BOLD)

Metamethods

posix.curses.chstr:__call (len)
Initialise a new chstr.

Parameters:

  • len int buffer length

Returns:

    chstr a new chstr filled with spaces

Usage:

    cs = curses.chstr (10)
generated by LDoc 1.4.3 Last updated 2015-03-01 09:06:02