goncurses

package module
v0.0.0-...-a5f4cdc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2023 License: BSD-3-Clause Imports: 6 Imported by: 1

README

Overview

Goncurses is an ncurses library for the Go programming language. It requires both pkg-config and ncurses C development files be installed.

Installation

The go tool is the recommended method of installing goncurses. Issue the following command on the command line:

$ go get github.com/rthornton128/goncurses

Prerequisites

The ncurses C development library must be installed on your system in order to build and install Goncurses. For example, on Debian based systems you can run:

$ sudo apt install libncurses-dev
``

OSX and Windows users should visit the 
[Wiki](https://github.com/rthornton128/goncurses/wiki) for installation
instructions.

## Pkg-config Flags Error
**Cgo** will fail to build with an invalid or unknown flag error with recent
versions of **ncurses**. Unfortunately, the **cgo** tool only provides one
mechanism for overcoming this. You need to set \*\_ALLOW environment variables
to overcome the issue. There are no **cgo** directives or any other clever
ways (that I know of) to fix this.

This package provides a [Makefile](../master/Makefile) as one solution.
Another would be to set the variables in your shell in whatever way makes
you feel comfortable.

See Issues: [#55](https://github.com/rthornton128/goncurses/issues/55) and
[#56](https://github.com/rthornton128/goncurses/issues/56)

# Notes

No functions which operate only on stdscr have been implemented because 
it makes little sense to do so in a Go implementation. Stdscr is treated the
same as any other window.

Whenever possible, versions of ncurses functions which could potentially
have a buffer overflow, like the getstr() family of functions, have not been
implemented. Instead, only mvwgetnstr() and wgetnstr() are used.

Documentation

Overview

Package goncurses is a new curses (ncurses) library for the Go programming language. It implements all the ncurses extension libraries: form, menu and panel.

Minimal operation would consist of initializing the display:

src, err := goncurses.Init()
if err != nil {
	log.Fatal("init:", err)
}
defer goncurses.End()

It is important to always call End() before your program exits. If you fail to do so, the terminal will not perform properly and will either need to be reset or restarted completely.

CAUTION: Calls to ncurses functions are normally not atomic nor reentrant and therefore extreme care should be taken to ensure ncurses functions are not called concurrently. Specifically, never write data to the same window concurrently nor accept input and send output to the same window as both alter the underlying C data structures in a non safe manner.

Ideally, you should structure your program to ensure all ncurses related calls happen in a single goroutine. This is probably most easily achieved via channels and Go's built-in select. Alternatively, or additionally, you can use a mutex to protect any calls in multiple goroutines from happening concurrently. Failure to do so will result in unpredictable and undefined behaviour in your program.

The examples directory contains demonstrations of many of the capabilities goncurses can provide.

Index

Constants

View Source
const (
	SYNC_NONE   = iota
	SYNC_CURSOR // Sync cursor in all sub/derived windows
	SYNC_DOWN   // Sync changes in all parent windows
	SYNC_UP     // Sync change in all child windows
)

Synconize options for Sync() function

View Source
const (
	A_NORMAL     Char = C.A_NORMAL
	A_STANDOUT        = C.A_STANDOUT
	A_UNDERLINE       = C.A_UNDERLINE
	A_REVERSE         = C.A_REVERSE
	A_BLINK           = C.A_BLINK
	A_DIM             = C.A_DIM
	A_BOLD            = C.A_BOLD
	A_PROTECT         = C.A_PROTECT
	A_INVIS           = C.A_INVIS
	A_ALTCHARSET      = C.A_ALTCHARSET
	A_CHARTEXT        = C.A_CHARTEXT
)

Text attributes

View Source
const (
	/* VT100 symbols */
	ACS_ULCORNER Char = C.A_ALTCHARSET + 'l'
	ACS_LLCORNER      = C.A_ALTCHARSET + 'm'
	ACS_URCORNER      = C.A_ALTCHARSET + 'k'
	ACS_LRCORNER      = C.A_ALTCHARSET + 'j'
	ACS_LTEE          = C.A_ALTCHARSET + 't'
	ACS_RTEE          = C.A_ALTCHARSET + 'u'
	ACS_BTEE          = C.A_ALTCHARSET + 'v'
	ACS_TTEE          = C.A_ALTCHARSET + 'w'
	ACS_HLINE         = C.A_ALTCHARSET + 'q'
	ACS_VLINE         = C.A_ALTCHARSET + 'x'
	ACS_PLUS          = C.A_ALTCHARSET + 'n'
	ACS_S1            = C.A_ALTCHARSET + 'o'
	ACS_S9            = C.A_ALTCHARSET + 's'
	ACS_DIAMOND       = C.A_ALTCHARSET + '`'
	ACS_CKBOARD       = C.A_ALTCHARSET + 'a'
	ACS_DEGREE        = C.A_ALTCHARSET + 'f'
	ACS_PLMINUS       = C.A_ALTCHARSET + 'g'
	ACS_BULLET        = C.A_ALTCHARSET + '~'

	/* Teletype 5410v1 symbols */
	ACS_LARROW  = C.A_ALTCHARSET + ','
	ACS_RARROW  = C.A_ALTCHARSET + '+'
	ACS_DARROW  = C.A_ALTCHARSET + '.'
	ACS_UARROW  = C.A_ALTCHARSET + '-'
	ACS_BOARD   = C.A_ALTCHARSET + 'h'
	ACS_LANTERN = C.A_ALTCHARSET + 'i'
	ACS_BLOCK   = C.A_ALTCHARSET + '0'

	/* Undocumented, not well supported */
	ACS_S3       = C.A_ALTCHARSET + 'p'
	ACS_S7       = C.A_ALTCHARSET + 'r'
	ACS_LEQUAL   = C.A_ALTCHARSET + 'y'
	ACS_GEQUAL   = C.A_ALTCHARSET + 'z'
	ACS_PI       = C.A_ALTCHARSET + '{'
	ACS_NEQUAL   = C.A_ALTCHARSET + '|'
	ACS_STERLING = C.A_ALTCHARSET + '}'
)

Definitions for printed characters not found on most keyboards.

View Source
const (
	C_BLACK   int16 = C.COLOR_BLACK
	C_BLUE          = C.COLOR_BLUE
	C_CYAN          = C.COLOR_CYAN
	C_GREEN         = C.COLOR_GREEN
	C_MAGENTA       = C.COLOR_MAGENTA
	C_RED           = C.COLOR_RED
	C_WHITE         = C.COLOR_WHITE
	C_YELLOW        = C.COLOR_YELLOW
)

Colors available to ncurses. Combine these with the dim/bold attributes for bright/dark versions of each color. These colors can be used for both background and foreground colors.

View Source
const (
	KEY_TAB       Key = 9               // tab
	KEY_RETURN        = 10              // enter key vs. KEY_ENTER
	KEY_ESC           = 27              // esc key
	KEY_DOWN          = C.KEY_DOWN      // down arrow key
	KEY_UP            = C.KEY_UP        // up arrow key
	KEY_LEFT          = C.KEY_LEFT      // left arrow key
	KEY_RIGHT         = C.KEY_RIGHT     // right arrow key
	KEY_HOME          = C.KEY_HOME      // home key
	KEY_BACKSPACE     = C.KEY_BACKSPACE // backpace
	KEY_F1            = C.KEY_F0 + 1    // F1 key
	KEY_F2            = C.KEY_F0 + 2    // F2 key
	KEY_F3            = C.KEY_F0 + 3    // F3 key
	KEY_F4            = C.KEY_F0 + 4    // F4 key
	KEY_F5            = C.KEY_F0 + 5    // F5 key
	KEY_F6            = C.KEY_F0 + 6    // F6 key
	KEY_F7            = C.KEY_F0 + 7    // F7 key
	KEY_F8            = C.KEY_F0 + 8    // F8 key
	KEY_F9            = C.KEY_F0 + 9    // F9 key
	KEY_F10           = C.KEY_F0 + 10   // F10 key
	KEY_F11           = C.KEY_F0 + 11   // F11 key
	KEY_F12           = C.KEY_F0 + 12   // F12 key
	KEY_DL            = C.KEY_DL        // delete-line key
	KEY_IL            = C.KEY_IL        // insert-line key
	KEY_DC            = C.KEY_DC        // delete-character key
	KEY_IC            = C.KEY_IC        // insert-character key
	KEY_EIC           = C.KEY_EIC       // sent by rmir or smir in insert mode
	KEY_CLEAR         = C.KEY_CLEAR     // clear-screen or erase key
	KEY_EOS           = C.KEY_EOS       // clear-to-end-of-screen key
	KEY_EOL           = C.KEY_EOL       // clear-to-end-of-line key
	KEY_SF            = C.KEY_SF        // scroll-forward key
	KEY_SR            = C.KEY_SR        // scroll-backward key
	KEY_PAGEDOWN      = C.KEY_NPAGE     // page-down key (next-page)
	KEY_PAGEUP        = C.KEY_PPAGE     // page-up key (prev-page)
	KEY_STAB          = C.KEY_STAB      // set-tab key
	KEY_CTAB          = C.KEY_CTAB      // clear-tab key
	KEY_CATAB         = C.KEY_CATAB     // clear-all-tabs key
	KEY_ENTER         = C.KEY_ENTER     // enter/send key
	KEY_PRINT         = C.KEY_PRINT     // print key
	KEY_LL            = C.KEY_LL        // lower-left key (home down)
	KEY_A1            = C.KEY_A1        // upper left of keypad
	KEY_A3            = C.KEY_A3        // upper right of keypad
	KEY_B2            = C.KEY_B2        // center of keypad
	KEY_C1            = C.KEY_C1        // lower left of keypad
	KEY_C3            = C.KEY_C3        // lower right of keypad
	KEY_BTAB          = C.KEY_BTAB      // back-tab key
	KEY_BEG           = C.KEY_BEG       // begin key
	KEY_CANCEL        = C.KEY_CANCEL    // cancel key
	KEY_CLOSE         = C.KEY_CLOSE     // close key
	KEY_COMMAND       = C.KEY_COMMAND   // command key
	KEY_COPY          = C.KEY_COPY      // copy key
	KEY_CREATE        = C.KEY_CREATE    // create key
	KEY_END           = C.KEY_END       // end key
	KEY_EXIT          = C.KEY_EXIT      // exit key
	KEY_FIND          = C.KEY_FIND      // find key
	KEY_HELP          = C.KEY_HELP      // help key
	KEY_MARK          = C.KEY_MARK      // mark key
	KEY_MESSAGE       = C.KEY_MESSAGE   // message key
	KEY_MOVE          = C.KEY_MOVE      // move key
	KEY_NEXT          = C.KEY_NEXT      // next key
	KEY_OPEN          = C.KEY_OPEN      // open key
	KEY_OPTIONS       = C.KEY_OPTIONS   // options key
	KEY_PREVIOUS      = C.KEY_PREVIOUS  // previous key
	KEY_REDO          = C.KEY_REDO      // redo key
	KEY_REFERENCE     = C.KEY_REFERENCE // reference key
	KEY_REFRESH       = C.KEY_REFRESH   // refresh key
	KEY_REPLACE       = C.KEY_REPLACE   // replace key
	KEY_RESTART       = C.KEY_RESTART   // restart key
	KEY_RESUME        = C.KEY_RESUME    // resume key
	KEY_SAVE          = C.KEY_SAVE      // save key
	KEY_SBEG          = C.KEY_SBEG      // shifted begin key
	KEY_SCANCEL       = C.KEY_SCANCEL   // shifted cancel key
	KEY_SCOMMAND      = C.KEY_SCOMMAND  // shifted command key
	KEY_SCOPY         = C.KEY_SCOPY     // shifted copy key
	KEY_SCREATE       = C.KEY_SCREATE   // shifted create key
	KEY_SDC           = C.KEY_SDC       // shifted delete-character key
	KEY_SDL           = C.KEY_SDL       // shifted delete-line key
	KEY_SELECT        = C.KEY_SELECT    // select key
	KEY_SEND          = C.KEY_SEND      // shifted end key
	KEY_SEOL          = C.KEY_SEOL      // shifted clear-to-end-of-line key
	KEY_SEXIT         = C.KEY_SEXIT     // shifted exit key
	KEY_SFIND         = C.KEY_SFIND     // shifted find key
	KEY_SHELP         = C.KEY_SHELP     // shifted help key
	KEY_SHOME         = C.KEY_SHOME     // shifted home key
	KEY_SIC           = C.KEY_SIC       // shifted insert-character key
	KEY_SLEFT         = C.KEY_SLEFT     // shifted left-arrow key
	KEY_SMESSAGE      = C.KEY_SMESSAGE  // shifted message key
	KEY_SMOVE         = C.KEY_SMOVE     // shifted move key
	KEY_SNEXT         = C.KEY_SNEXT     // shifted next key
	KEY_SOPTIONS      = C.KEY_SOPTIONS  // shifted options key
	KEY_SPREVIOUS     = C.KEY_SPREVIOUS // shifted previous key
	KEY_SPRINT        = C.KEY_SPRINT    // shifted print key
	KEY_SREDO         = C.KEY_SREDO     // shifted redo key
	KEY_SREPLACE      = C.KEY_SREPLACE  // shifted replace key
	KEY_SRIGHT        = C.KEY_SRIGHT    // shifted right-arrow key
	KEY_SRSUME        = C.KEY_SRSUME    // shifted resume key
	KEY_SSAVE         = C.KEY_SSAVE     // shifted save key
	KEY_SSUSPEND      = C.KEY_SSUSPEND  // shifted suspend key
	KEY_SUNDO         = C.KEY_SUNDO     // shifted undo key
	KEY_SUSPEND       = C.KEY_SUSPEND   // suspend key
	KEY_UNDO          = C.KEY_UNDO      // undo key
	KEY_MOUSE         = C.KEY_MOUSE     // any mouse event
	KEY_RESIZE        = C.KEY_RESIZE    // Terminal resize event
	//KEY_EVENT         = C.KEY_EVENT     // We were interrupted by an event
	KEY_MAX = C.KEY_MAX // Maximum key value is KEY_EVENT (0633)
)
View Source
const (
	M_ALL            MouseButton = C.ALL_MOUSE_EVENTS
	M_ALT                        = C.BUTTON_ALT      // alt-click
	M_B1_PRESSED                 = C.BUTTON1_PRESSED // button 1
	M_B1_RELEASED                = C.BUTTON1_RELEASED
	M_B1_CLICKED                 = C.BUTTON1_CLICKED
	M_B1_DBL_CLICKED             = C.BUTTON1_DOUBLE_CLICKED
	M_B1_TPL_CLICKED             = C.BUTTON1_TRIPLE_CLICKED
	M_B2_PRESSED                 = C.BUTTON2_PRESSED // button 2
	M_B2_RELEASED                = C.BUTTON2_RELEASED
	M_B2_CLICKED                 = C.BUTTON2_CLICKED
	M_B2_DBL_CLICKED             = C.BUTTON2_DOUBLE_CLICKED
	M_B2_TPL_CLICKED             = C.BUTTON2_TRIPLE_CLICKED
	M_B3_PRESSED                 = C.BUTTON3_PRESSED // button 3
	M_B3_RELEASED                = C.BUTTON3_RELEASED
	M_B3_CLICKED                 = C.BUTTON3_CLICKED
	M_B3_DBL_CLICKED             = C.BUTTON3_DOUBLE_CLICKED
	M_B3_TPL_CLICKED             = C.BUTTON3_TRIPLE_CLICKED
	M_B4_PRESSED                 = C.BUTTON4_PRESSED // button 4
	M_B4_RELEASED                = C.BUTTON4_RELEASED
	M_B4_CLICKED                 = C.BUTTON4_CLICKED
	M_B4_DBL_CLICKED             = C.BUTTON4_DOUBLE_CLICKED
	M_B4_TPL_CLICKED             = C.BUTTON4_TRIPLE_CLICKED
	M_CTRL                       = C.BUTTON_CTRL           // ctrl-click
	M_SHIFT                      = C.BUTTON_SHIFT          // shift-click
	M_POSITION                   = C.REPORT_MOUSE_POSITION // mouse moved
)

Mouse button events

View Source
const (
	REQ_NEXT_PAGE    FormDriverReq = C.REQ_NEXT_PAGE    // next page
	REQ_PREV_PAGE                  = C.REQ_PREV_PAGE    // previous page
	REQ_FIRST_PAGE                 = C.REQ_FIRST_PAGE   // first page
	REQ_LAST_PAGE                  = C.REQ_LAST_PAGE    // last page
	REQ_NEXT_FIELD                 = C.REQ_NEXT_FIELD   // next field
	REQ_PREV_FIELD                 = C.REQ_PREV_FIELD   // previous field
	REQ_FIRST_FIELD                = C.REQ_FIRST_FIELD  // first field
	REQ_LAST_FIELD                 = C.REQ_LAST_FIELD   // last field
	REQ_SNEXT_FIELD                = C.REQ_SNEXT_FIELD  // sorted next field
	REQ_SPREV_FIELD                = C.REQ_SPREV_FIELD  // sorted previous field
	REQ_SFIRST_FIELD               = C.REQ_SFIRST_FIELD // sorted first field
	REQ_SLAST_FIELD                = C.REQ_SLAST_FIELD  // sorted last field
	REQ_LEFT_FIELD                 = C.REQ_LEFT_FIELD   // left field
	REQ_RIGHT_FIELD                = C.REQ_RIGHT_FIELD  // right field
	REQ_UP_FIELD                   = C.REQ_UP_FIELD     // up to a field
	REQ_DOWN_FIELD                 = C.REQ_DOWN_FIELD   // down to a field
	REQ_NEXT_CHAR                  = C.REQ_NEXT_CHAR    // next character in field
	REQ_PREV_CHAR                  = C.REQ_PREV_CHAR    // previous character in field
	REQ_NEXT_LINE                  = C.REQ_NEXT_LINE    // next line
	REQ_PREV_LINE                  = C.REQ_PREV_LINE    // previous line
	REQ_NEXT_WORD                  = C.REQ_NEXT_WORD    // next word
	REQ_PREV_WORD                  = C.REQ_PREV_WORD    // previous word
	REQ_BEG_FIELD                  = C.REQ_BEG_FIELD    // beginning of field
	REQ_END_FIELD                  = C.REQ_END_FIELD    // end of field
	REQ_BEG_LINE                   = C.REQ_BEG_LINE     // beginning of line
	REQ_END_LINE                   = C.REQ_END_LINE     // end of line
	REQ_LEFT_CHAR                  = C.REQ_LEFT_CHAR    // character to the left
	REQ_RIGHT_CHAR                 = C.REQ_RIGHT_CHAR   // character to the right
	REQ_UP_CHAR                    = C.REQ_UP_CHAR      // up a character
	REQ_DOWN_CHAR                  = C.REQ_DOWN_CHAR    // down a character
	REQ_NEW_LINE                   = C.REQ_NEW_LINE     // insert of overlay a new line
	REQ_INS_CHAR                   = C.REQ_INS_CHAR     // insert a blank character at cursor
	REQ_INS_LINE                   = C.REQ_INS_LINE     // insert a blank line at cursor
	REQ_DEL_CHAR                   = C.REQ_DEL_CHAR     // delete character at cursor
	REQ_DEL_PREV                   = C.REQ_DEL_PREV     // delete character before cursor
	REQ_DEL_LINE                   = C.REQ_DEL_LINE     // delete line
	REQ_DEL_WORD                   = C.REQ_DEL_WORD     // delete word
	REQ_CLR_EOL                    = C.REQ_CLR_EOL      // clear from cursor to end of line
	REQ_CLR_EOF                    = C.REQ_CLR_EOF      // clear from cursor to end of field
	REQ_CLR_FIELD                  = C.REQ_CLR_FIELD    // clear field
	REQ_OVL_MODE                   = C.REQ_OVL_MODE     // overlay mode
	REQ_INS_MODE                   = C.REQ_INS_MODE     // insert mode
	REQ_SCR_FLINE                  = C.REQ_SCR_FLINE    // scroll field forward a line
	REQ_SCR_BLINE                  = C.REQ_SCR_BLINE    // scroll field back a line
	REQ_SCR_FPAGE                  = C.REQ_SCR_FPAGE    // scroll field forward a page
	REQ_SCR_BPAGE                  = C.REQ_SCR_BPAGE    // scroll field back a page
	REQ_SCR_FHPAGE                 = C.REQ_SCR_FHPAGE   // scroll field forward half a page
	REQ_SCR_BHPAGE                 = C.REQ_SCR_BHPAGE   // scroll field back half a page
	REQ_SCR_FCHAR                  = C.REQ_SCR_FCHAR    // scroll field forward a character
	REQ_SCR_BCHAR                  = C.REQ_SCR_BCHAR    // scroll field back a character
	REQ_SCR_HFLINE                 = C.REQ_SCR_HFLINE   // horisontal scroll field forward a line
	REQ_SCR_HBLINE                 = C.REQ_SCR_HBLINE   // horisontal scroll field back a line
	REQ_SCR_HFHALF                 = C.REQ_SCR_HFHALF   // horisontal scroll field forward half a line
	REQ_SCR_HBHALF                 = C.REQ_SCR_HBHALF   // horisontal scroll field back half a line
	REQ_VALIDATION                 = C.REQ_VALIDATION   // validate field
	REQ_NEXT_CHOICE                = C.REQ_NEXT_CHOICE  // display next field choice
	REQ_PREV_CHOICE                = C.REQ_PREV_CHOICE  // display previous field choice
)
View Source
const (
	FO_VISIBLE  = C.O_VISIBLE  // Field visibility
	FO_ACTIVE   = C.O_ACTIVE   // Field is sensitive/accessable
	FO_PUBLIC   = C.O_PUBLIC   // Typed characters are echoed
	FO_EDIT     = C.O_EDIT     // Editable
	FO_WRAP     = C.O_WRAP     // Line wrapping
	FO_BLANK    = C.O_BLANK    // Clear on entry
	FO_AUTOSKIP = C.O_AUTOSKIP // Skip to next field when current filled
	FO_NULLOK   = C.O_NULLOK   // Blank ok
	FO_STATIC   = C.O_STATIC   // Fixed size
	FO_PASSOK   = C.O_PASSOK   // Field validation
)
View Source
const (
	O_ONEVALUE   = C.O_ONEVALUE   // Only one item can be selected
	O_SHOWDESC   = C.O_SHOWDESC   // Display item descriptions
	O_ROWMAJOR   = C.O_ROWMAJOR   // Display in row-major order
	O_IGNORECASE = C.O_IGNORECASE // Ignore case when pattern-matching
	O_SHOWMATCH  = C.O_SHOWMATCH  // Move cursor to item when pattern-matching
	O_NONCYCLIC  = C.O_NONCYCLIC  // Don't wrap next/prev item
)

Menu Options

View Source
const O_SELECTABLE = C.O_SELECTABLE

Menu Item Options

Variables

View Source
var DriverActions = map[Key]MenuDriverReq{
	KEY_DOWN:     C.REQ_DOWN_ITEM,
	KEY_HOME:     C.REQ_FIRST_ITEM,
	KEY_END:      C.REQ_LAST_ITEM,
	KEY_LEFT:     C.REQ_LEFT_ITEM,
	KEY_PAGEDOWN: C.REQ_SCR_DPAGE,
	KEY_PAGEUP:   C.REQ_SCR_UPAGE,
	KEY_RIGHT:    C.REQ_RIGHT_ITEM,
	KEY_UP:       C.REQ_UP_ITEM,
}

DriverActions is a convenience mapping for common responses to keyboard input

Functions

func BaudRate

func BaudRate() int

BaudRate returns the speed of the terminal in bits per second

func Beep

func Beep()

Beep requests the terminal make an audible bell or, if not available, flashes the screen. Note that screen flashing doesn't work on all terminals

func CBreak

func CBreak(on bool)

Turn on/off buffering; raw user signals are passed to the program for handling. Overrides raw mode

func CanChangeColor

func CanChangeColor() bool

Test whether colour values can be changed

func ColorContent

func ColorContent(col int16) (int16, int16, int16)

Get RGB values for specified colour

func ColorPairs

func ColorPairs() int

ColorPairs returns the maximum number of color pairs that the terminal supports

func Colors

func Colors() int

Colors returns the number of colors that the terminal supports

func CursesVersion

func CursesVersion() string

CursesVersion returns the version of the ncurses library currently linked to

func Cursor

func Cursor(vis byte) error

Set the cursor visibility. Options are: 0 (invisible/hidden), 1 (normal) and 2 (extra-visible)

func Echo

func Echo(on bool)

Echo turns on/off the printing of typed characters

func End

func End()

Must be called prior to exiting the program in order to make sure the terminal returns to normal operation

func Flash

func Flash()

Flash requests the terminal flashes the screen or, if not available, make an audible bell. Note that screen flashing doesn't work on all terminals

func FlushInput

func FlushInput() error

FlushInput flushes all input

func HalfDelay

func HalfDelay(delay int) error

Behaves like cbreak() but also adds a timeout for input. If timeout is exceeded after a call to Getch() has been made then GetChar will return with an error.

func HasColors

func HasColors() bool

HasColors returns true if terminal can display colors

func HasInsertChar

func HasInsertChar() bool

HasInsertChar return true if the terminal has insert and delete character capabilities

func HasInsertLine

func HasInsertLine() bool

HasInsertLine returns true if the terminal has insert and delete line capabilities. See ncurses documentation for more details

func HasKey

func HasKey(ch Key) bool

HasKey returns true if terminal recognized the given character

func InitColor

func InitColor(col, r, g, b int16) error

InitColor is used to set 'color' to the specified RGB values. Values may be between 0 and 1000.

func InitPair

func InitPair(pair, fg, bg int16) error

InitPair sets a colour pair designated by 'pair' to fg and bg colors

func IsEnd

func IsEnd() bool

IsEnd returns true if End() has been called, otherwise false

func IsTermResized

func IsTermResized(nlines, ncols int) bool

IsTermResized returns true if ResizeTerm would modify any current Windows if called with the given parameters

func KeyString

func KeyString(k Key) string

Returns a string representing the value of input returned by GetChar

func MouseInterval

func MouseInterval(ms int) int

MouseInterval sets the maximum time in milliseconds that can elapse between press and release mouse events and returns the previous setting. Use a value of 0 (zero) to disable click resolution. Use a value of -1 to get the previous value without changing the current value. Default value is 1/6 of a second.

func MouseOk

func MouseOk() bool

MouseOk returns true if ncurses has built-in mouse support. On ncurses 5.7 and earlier, this function is not present and so will always return false

func Nap

func Nap(ms int)

Nap (sleep; halt execution) for 'ms' milliseconds

func NewLines

func NewLines(on bool)

NewLines turns newline translation on/off.

func PairContent

func PairContent(pair int16) (fg int16, bg int16, err error)

PairContent returns the current foreground and background colours associated with the given pair

func Raw

func Raw(on bool)

Raw turns on input buffering; user signals are disabled and the key strokes are passed directly to input. Set to false if you wish to turn this mode off

func RequestByName

func RequestByName(request string) (res int, err error)

RequestByName returns the request ID of the provide request

func RequestName

func RequestName(request int) (string, error)

RequestName of menu request code

func ResizeTerm

func ResizeTerm(nlines, ncols int) error

ResizeTerm will attempt to resize the terminal. This only has an effect if the terminal is in an XWindows (GUI) environment.

func SetEscDelay

func SetEscDelay(size int)

Sets the delay from when the escape key is pressed until recognition.

func SetTabSize

func SetTabSize(tabSize int)

SetTabSize allows for modification of the tab width. This setting is global and affects all windows.

func SlkAttributeOff

func SlkAttributeOff(attr Char) error

SlkAttributeOff turns off the given OR'd attributes without turning any on

func SlkAttributeOn

func SlkAttributeOn(attr Char) error

SlkAttributeOn turns on the given OR'd attributes without turning any off

func SlkClear

func SlkClear() error

SlkClear removes the soft-key labels from the screen

func SlkColor

func SlkColor(cp int16) error

SlkColor sets the color pair for the soft-keys

func SlkInit

func SlkInit(f SlkFormat)

Initializes the soft-key labels with the given format; keys like the F1-F12 keys on most keyboards. After a call to SlkRefresh a bar at the bottom of the standard screen returned by Init will be displayed. This function MUST be called prior to Init()

func SlkLabel

func SlkLabel(labnum int) string

SlkLabel returns the label for the given key

func SlkNoutRefresh

func SlkNoutRefresh() error

SlkNoutFresh behaves like Window.NoutRefresh

func SlkRefresh

func SlkRefresh() error

SlkRefresh behaves the same as Window.Refresh. Most applications would use SlkNoutRefresh because a Window.Refresh is likely to follow

func SlkRestore

func SlkRestore() error

SlkRestore restores the soft-key labels to the screen after an SlkClear()

func SlkSet

func SlkSet(labnum int, label string, just SlkJustify) error

SlkSet sets the 'labnum' text to the supplied 'label'. Labels must not be greater than 8 characters

func SlkSetAttribute

func SlkSetAttribute(attr Char) error

SlkSetAttribute sets the OR'd attributes to use

func SlkTouch

func SlkTouch() error

SlkTouch behaves just like Window.Touch

func StartColor

func StartColor() error

Enables colors to be displayed. Will return an error if terminal is not capable of displaying colors

func TabSize

func TabSize() int

TabSize returns the configured tab width.

func TypeAhead

func TypeAhead(fd int) int

func UnGetChar

func UnGetChar(ch Char)

UnGetChar places the character back into the input queue

func Update

func Update() error

Update the screen, refreshing all windows

func UpdatePanels

func UpdatePanels()

UpdatePanels refreshes the panel stack. It must be called prior to using ncurses's DoUpdate()

func UseDefaultColors

func UseDefaultColors() error

UseDefaultColors tells the curses library to assign the terminal's default foreground and background colors to color number -1. This will allow you to call InitPair(x, -1, -1) to set both the foreground and background colours of pair x to the terminal's default. This function can fail if the terminal does not support certain ncurses features like orig_pair or initialize_pair.

func UseEnvironment

func UseEnvironment(use bool)

UseEnvironment specifies whether the LINES and COLUMNS environmental variables should be used or not

Types

type Char

type Char C.chtype

func ColorPair

func ColorPair(pair int16) Char

Return the value of a color pair which can be passed to functions which accept attributes like AddChar, AttrOn/Off and Background.

type Field

type Field C.FIELD

func NewField

func NewField(h, w, tr, lc, oscr, nbuf int32) (*Field, error)

func (*Field) Background

func (f *Field) Background() Char

Background returns the field's background character attributes

func (*Field) Buffer

func (f *Field) Buffer() string

Buffer returns a string containing the contents of the buffer. The returned string will contain whitespace up to the buffer size as set by SetMax or the value by the call to NewField

func (*Field) Duplicate

func (f *Field) Duplicate(y, x int32) (*Field, error)

Duplicate the field at the specified coordinates, returning a pointer to the newly allocated object.

func (*Field) Foreground

func (f *Field) Foreground() Char

Foreground returns the field's foreground character attributes

func (*Field) Free

func (f *Field) Free() error

Free field's allocated memory. This must be called to prevent memory leaks

func (*Field) Info

func (f *Field) Info(h, w, y, x, off, nbuf *int) error

Info retrieves the height, width, y, x, offset and buffer size of the given field. Pass the memory address of the variable to store the data in or nil.

func (*Field) Justification

func (f *Field) Justification() int

Just returns the justification type of the field

func (*Field) Move

func (f *Field) Move(y, x int32) error

Move the field to the location of the specified coordinates

func (*Field) Options

func (f *Field) Options(opts int, on bool)

Options turns features on and off

func (*Field) Pad

func (f *Field) Pad() int

Pad returns the padding character of the field

func (*Field) SetBackground

func (f *Field) SetBackground(ch Char) error

SetBackground character and attributes (colours, etc)

func (*Field) SetBuffer

func (f *Field) SetBuffer(s string) error

SetBuffer sets the visible characters in the field. A buffer is empty by default.

func (*Field) SetForeground

func (f *Field) SetForeground(ch Char) error

SetForeground character and attributes (colours, etc)

func (*Field) SetJustification

func (f *Field) SetJustification(just int) error

SetJustification of the field

func (*Field) SetMax

func (f *Field) SetMax(max int) error

SetMax sets the maximum size of a field

func (*Field) SetOptionsOff

func (f *Field) SetOptionsOff(opts Char) error

OptionsOff turns feature(s) off

func (*Field) SetOptionsOn

func (f *Field) SetOptionsOn(opts Char) error

OptionsOn turns feature(s) on

func (*Field) SetPad

func (f *Field) SetPad(padch int) error

SetPad sets the padding character of the field

type Form

type Form struct {
	// contains filtered or unexported fields
}

func NewForm

func NewForm(fields []*Field) (Form, error)

NewForm returns a new form object using the fields array supplied as an argument

func (*Form) Driver

func (f *Form) Driver(drvract Key) error

Driver issues the actions requested to the form itself. See the corresponding REQ_* constants

func (*Form) FieldCount

func (f *Form) FieldCount() int

FieldCount returns the number of fields attached to the Form

func (*Form) Free

func (f *Form) Free() error

Free the memory allocated to the form. Forms are not automatically free'd by Go's garbage collection system so the memory allocated to it must be explicitly free'd

func (*Form) Post

func (f *Form) Post() error

Post the form, making it visible and interactive

func (*Form) SetFields

func (f *Form) SetFields(fields []*Field) error

SetFields overwrites the current fields for the Form with new ones. It is important to make sure all prior fields have been freed otherwise this action will result in a memory leak

func (*Form) SetOptions

func (f *Form) SetOptions(opts int) error

SetOptions for the form

func (*Form) SetSub

func (f *Form) SetSub(w *Window) error

SetSub sets the subwindow associated with the form

func (*Form) SetWindow

func (f *Form) SetWindow(w *Window) error

SetWindow sets the window associated with the form

func (*Form) Sub

func (f *Form) Sub() Window

Sub returns the subwindow associated with the form

func (*Form) UnPost

func (f *Form) UnPost() error

UnPost the form, removing it from the interface

type FormDriverReq

type FormDriverReq C.int

Form Driver Requests

type Key

type Key int
type Menu struct {
	// contains filtered or unexported fields
}

func NewMenu

func NewMenu(items []*MenuItem) (*Menu, error)

NewMenu returns a pointer to a new menu.

func (m *Menu) Background() int

Background returns the menu's background character setting

func (m *Menu) Count() int

Count returns the number of MenuItems in the Menu

func (m *Menu) Current(mi *MenuItem) *MenuItem

Current returns the selected item in the menu

func (m *Menu) Driver(daction MenuDriverReq) error

Driver controls how the menu is activated. Action usually corresponds to the string returned by the Key() function in goncurses.

func (m *Menu) Foreground() int

Foreground gets the attributes of highlighted items in the menu

func (m *Menu) Format(r, c int) error

Format sets the menu format. See the O_* menu options.

func (m *Menu) Free() error

Free deallocates memory set aside for the menu. This must be called before exiting.

func (m *Menu) Grey(ch Char)

Grey sets the attributes of non-selectable items in the menu

func (m *Menu) Items() []*MenuItem

Items will return the items in the menu.

func (m *Menu) Mark(mark string) error

Mark sets the indicator for the currently selected menu item

func (m *Menu) Option(opts int, on bool) error

Option sets the options for the menu. See the O_* definitions for a list of values which can be OR'd together

func (m *Menu) Pad() int

Pad sets the padding character for menu items.

func (m *Menu) Pattern() string

Pattern returns the menu's pattern buffer

func (m *Menu) PositionCursor()

PositionCursor sets the cursor over the currently selected menu item.

func (m *Menu) Post() error

Post the menu, making it visible

func (m *Menu) Scale() (int, int, error)

Scale

func (m *Menu) SetBackground(ch Char) error

SetBackground set the attributes of the un-highlighted items in the menu

func (m *Menu) SetForeground(ch Char) error

SetForeground sets the attributes of the highlighted items in the menu

func (m *Menu) SetItems(items []*MenuItem) error

SetItems will either set the items in the menu. When setting items you must make sure the prior menu items will be freed.

func (m *Menu) SetPad(ch Char) error

SetPad sets the padding character for menu items.

func (m *Menu) SetPattern(pattern string) error

SetPattern sets the padding character for menu items.

func (m *Menu) SetSpacing(desc, row, col int) error

SetSpacing of the menu's items. 'desc' is the space between the item and it's description and may not be larger than TAB_SIZE. 'row' is the number of rows separating each item and may not be larger than three. 'col' is the spacing between each column of items in multi-column mode. Use values of 0 or 1 to reset spacing to default, which is one

func (m *Menu) SetWindow(w *Window) error

SetWindow container for the menu

func (m *Menu) Spacing() (int, int, int)

Spacing returns the menu item spacing. See SetSpacing for a description

func (m *Menu) SubWindow(sub *Window) error

SubWindow for the menu

func (m *Menu) UnPost() error

UnPost the menu, effectively hiding it.

func (m *Menu) Window() *Window

Window container for the menu. Returns nil on failure

type MenuDriverReq C.int

Menu Driver Requests

type MenuItem struct {
	// contains filtered or unexported fields
}

func NewItem

func NewItem(name, desc string) (*MenuItem, error)

NewItem creates a new menu item with name and description.

func (mi *MenuItem) Description() string

Description returns the second value passed to NewItem

func (mi *MenuItem) Free()

Free must be called on all menu items to avoid memory leaks

func (mi *MenuItem) Index() int

Index of the menu item in it's parent menu

func (mi *MenuItem) Name() string

Name of the menu item

func (mi *MenuItem) Selectable(on bool)

Selectable turns on/off whether a menu option is "greyed out"

func (mi *MenuItem) SetValue(val bool) error

SetValue sets whether an item is active or not

func (mi *MenuItem) Value() bool

Value returns true if menu item is toggled/active, otherwise false

func (mi *MenuItem) Visible() bool

Visible returns true if the item is visible, false if not

type MouseButton

type MouseButton int

func MouseMask

func MouseMask(mask MouseButton, old *MouseButton) MouseButton

MouseMask accepts a single int of OR'd mouse events. If a mouse event is triggered, GetChar() will return KEY_MOUSE. To retrieve the actual event use GetMouse() to pop it off the queue. Pass a pointer as the second argument to store the prior events being monitored or nil.

type MouseEvent

type MouseEvent struct {
	Id      int16       /* device ID */
	X, Y, Z int         /* event coordinates */
	State   MouseButton /* button state */
}

func GetMouse

func GetMouse() *MouseEvent

GetMouse returns the MouseEvent associated with a KEY_MOUSE event returned by a call to GetChar(). Returns a new MouseEvent or nil on error or if no event is currently in the mouse event queue

type Pad

type Pad struct {
	*Window
}

func NewPad

func NewPad(h, w int) (*Pad, error)

NewPad creates a window which is not restricted by the terminal's dimensions (unlike a Window). Pads accept all functions which can be called on a window. It returns a pointer to a new Pad of h(eight) by w(idth).

func (*Pad) Echo

func (p *Pad) Echo(ch int)

Echo prints a single character to the pad immediately. This has the same effect of calling AddChar() + Refresh() but has a significant speed advantage

func (*Pad) NoutRefresh

func (p *Pad) NoutRefresh(py, px, sy, sx, h, w int) error

NoutRefresh indicates that a section of the screen should be redrawn but does not update the physical screen until Update() is called. See Pad.Refresh() for details on the arguments and Window.NoutRefresh for more details on the workings of this function

func (*Pad) Refresh

func (p *Pad) Refresh(py, px, sy1, sx1, sy2, sx2 int) error

Refresh will calculate how to update the physical screen in the most efficient manor and update it. See Window.Refresh for more details. The coordinates py, px specify the location on the pad from which the characters we want to display are located. sy1 and sx1 specify the location on the screen where this data should be displayed, hence the upper left corner of the display area on the screen. sy2 and sx2 specify the location of the lower right corner of the display area on the screen:

(y1,x1) +-------------+
        |             |
        |             |
        |             |
        |             |
        |             |
        |             |
        +-------------+ (y2, x2)

The coordinates of the rectangle must be contained within both the Pad's and Window's respective areas.

func (*Pad) Sub

func (p *Pad) Sub(y, x, h, w int) *Pad

Sub creates a sub-pad h(eight) by w(idth) in size starting at the location y, x in the parent pad. Changes to a sub-pad will also change it's parent

type Panel

type Panel struct {
	// contains filtered or unexported fields
}

func Below

func Below(p *Panel) *Panel

Returns a pointer to the panel below in the stack or nil. Passing nil will return the bottom panel in the stack

func NewPanel

func NewPanel(w *Window) *Panel

Panel creates a new panel derived from the window, adding it to the panel stack. The pointer to the original window can still be used to execute most window functions with the exception of Refresh(). Always use panel's Refresh() function.

func (*Panel) Above

func (p *Panel) Above() *Panel

Returns a pointer to the panel above in the stack or nil. Passing nil will return the top panel in the stack

func (*Panel) Bottom

func (p *Panel) Bottom() error

Move the panel to the bottom of the stack.

func (*Panel) Delete

func (p *Panel) Delete() error

Delete panel, removing from the stack.

func (*Panel) Hidden

func (p *Panel) Hidden() bool

Hidden returns true if panel is visible, false if not

func (*Panel) Hide

func (p *Panel) Hide() error

Hide the panel

func (*Panel) Move

func (p *Panel) Move(y, x int) error

Move the panel to the specified location. It is important to never use ncurses movement functions on the window governed by panel. Always use this function

func (*Panel) Replace

func (p *Panel) Replace(w *Window) error

Replace panel's associated window with a new one.

func (*Panel) Show

func (p *Panel) Show() error

Show the panel, if hidden, and place it on the top of the stack.

func (*Panel) Top

func (p *Panel) Top() error

Move panel to the top of the stack

func (*Panel) Window

func (p *Panel) Window() *Window

Window returns the window governed by panel

type Screen

type Screen struct {
	// contains filtered or unexported fields
}

func NewTerm

func NewTerm(termType string, out, in *os.File) (*Screen, error)

NewTerm returns a new Screen, representing a physical terminal. If using this function to generate a new Screen you should not call Init(). Unlike Init(), NewTerm does not call Refresh() to clear the screen so this will need to be done manually. When finished with a terminal, you must call End() in reverse order that each terminal was created in. After you are finished with the screen you must call Delete to free the memory allocated to it. This function is usually only useful for programs using multiple terminals or test for terminal capabilities. The argument termType is the type of terminal to be used ($TERM is used if value is "" which also has the same effect of using os.Getenv("TERM"))

func (*Screen) Delete

func (s *Screen) Delete()

Delete frees memory allocated to the screen. This function

func (*Screen) End

func (s *Screen) End()

End is just a wrapper for the global End function. This helper function has been provided to help ensure that new terminals are closed in the proper, reverse order they were created. It makes the terminal active via set then called End so it is closed properly. You must make sure that Delete is called once done with the screen/terminal.

func (*Screen) Set

func (s *Screen) Set() (*Screen, error)

Set the screen to be the current, active screen

type SlkFormat

type SlkFormat byte
const (
	SLK_323        SlkFormat = iota // 8 labels; 3-2-3 arrangement
	SLK_44                          // 8 labels; 4-4 arrangement
	SLK_PC444                       // 12 labels; 4-4-4 arrangement
	SLK_PC444INDEX                  // 12 labels; 4-4-4 with index line
)

type SlkJustify

type SlkJustify byte
const (
	SLK_LEFT SlkJustify = iota
	SLK_CENTER
	SLK_RIGHT
)

type Window

type Window struct {
	// contains filtered or unexported fields
}

func Init

func Init(locale string) (stdscr *Window, err error)

Initialize the ncurses library. You must run this function prior to any other goncurses function in order for the library to work

func NewWindow

func NewWindow(h, w, y, x int) (window *Window, err error)

NewWindow creates a window of size h(eight) and w(idth) at y, x

func StdScr

func StdScr() *Window

StdScr returns a Window for the underlying stdscr object which represents the physical screen. This is the same Window returned by Init and therefore not useful unless using NewTerm and other multi-screen related functions.

func (*Window) AddChar

func (w *Window) AddChar(ach Char)

AddChar prints a single character to the window. The character can be OR'd together with attributes and colors.

func (*Window) AttrOff

func (w *Window) AttrOff(attr Char) (err error)

Turn off character attribute.

func (*Window) AttrOn

func (w *Window) AttrOn(attr Char) (err error)

Turn on character attribute

func (*Window) AttrSet

func (w *Window) AttrSet(attr Char) error

AttrSet sets the attributes to the given value

func (*Window) Background

func (w *Window) Background() Char

Background returns the current background attributes

func (*Window) Border

func (w *Window) Border(ls, rs, ts, bs, tl, tr, bl, br Char) error

Border uses the characters supplied to draw a border around the window. t, b, r, l, s correspond to top, bottom, right, left and side respectively.

func (*Window) Box

func (w *Window) Box(vch, hch Char) error

Box draws a border around the given window. For complete control over the characters used to draw the border use Border()

func (*Window) Clear

func (w *Window) Clear() error

Clears the screen and the underlying virtual screen. This forces the entire screen to be rewritten from scratch. This will cause likely cause a noticeable flicker because the screen is completely cleared before redrawing it. This is probably not what you want. Instead, you should probably use the Erase() function. It is the same as called Erase() followed by a call to ClearOk().

func (*Window) ClearOk

func (w *Window) ClearOk(ok bool)

ClearOk clears the window completely prior to redrawing it. If called on stdscr then the whole screen is redrawn no matter which window has Refresh() called on it. Defaults to False.

func (*Window) ClearToBottom

func (w *Window) ClearToBottom() error

Clear starting at the current cursor position, moving to the right, to the bottom of window

func (*Window) ClearToEOL

func (w *Window) ClearToEOL() error

Clear from the current cursor position, moving to the right, to the end of the line

func (*Window) Color

func (w *Window) Color(pair int16)

Color sets the foreground/background color pair for the entire window

func (*Window) ColorOff

func (w *Window) ColorOff(pair int16) error

ColorOff turns the specified color pair off

func (*Window) ColorOn

func (w *Window) ColorOn(pair int16) error

Normally color pairs are turned on via attron() in ncurses but this implementation chose to make it separate

func (*Window) Copy

func (w *Window) Copy(src *Window, sy, sx, dtr, dtc, dbr, dbc int,
	overlay bool) error

Copy is similar to Overlay and Overwrite but provides a finer grain of control.

func (*Window) CursorYX

func (w *Window) CursorYX() (int, int)

CursorYX returns the current cursor location in the Window. Note that it uses ncurses idiom of returning y then x.

func (*Window) DelChar

func (w *Window) DelChar() error

DelChar deletes the character at the current cursor position, moving all characters to the right of that position one space to the left and appends a blank character at the end.

func (*Window) Delete

func (w *Window) Delete() error

Delete the window. This function must be called to ensure memory is freed to prevent memory leaks once you are done with the window.

func (*Window) Derived

func (w *Window) Derived(height, width, y, x int) *Window

Derived creates a new window of height and width at the coordinates y, x. These coordinates are relative to the original window thereby confining the derived window to the area of original window. See the SubWindow function for additional notes.

func (*Window) Duplicate

func (w *Window) Duplicate() *Window

Duplicate the window, creating an exact copy.

func (*Window) Enclose

func (w *Window) Enclose(y, x int) bool

Test whether the given coordinates are within the window or not

func (*Window) Erase

func (w *Window) Erase()

Erase the contents of the window, clearing it. This function allows the underlying structures to be updated efficiently and thereby provide smooth updates to the terminal when frequently clearing and re-writing the window or screen.

func (*Window) GetChar

func (w *Window) GetChar() Key

GetChar retrieves a character from standard input stream and returns it. In the event of an error or if the input timeout has expired (i.e. if Timeout() has been set to zero or a positive value and no characters have been received) the value returned will be zero (0)

func (*Window) GetString

func (w *Window) GetString(n int) (string, error)

GetString reads at most 'n' characters entered by the user from the Window. Attempts to enter greater than 'n' characters will elicit a 'beep'

func (*Window) HLine

func (w *Window) HLine(y, x int, ch Char, wid int)

HLine draws a horizontal line starting at y, x and ending at width using the specified character

func (*Window) InChar

func (w *Window) InChar() Char

InChar returns the character at the current position in the curses window

func (*Window) IsCleared

func (w *Window) IsCleared() bool

IsCleared returns the value set in ClearOk

func (*Window) IsKeypad

func (w *Window) IsKeypad() bool

IsKeypad returns the value set in Keypad

func (*Window) Keypad

func (w *Window) Keypad(keypad bool) error

Keypad turns on/off the keypad characters, including those like the F1-F12 keys and the arrow keys

func (*Window) LineTouched

func (w *Window) LineTouched(line int) bool

LineTouched returns true if the line has been touched; returns false otherwise

func (*Window) MaxYX

func (w *Window) MaxYX() (int, int)

Returns the maximum size of the Window. Note that it uses ncurses idiom of returning y then x.

func (*Window) Move

func (w *Window) Move(y, x int)

Move the cursor to the specified coordinates within the window

func (*Window) MoveAddChar

func (w *Window) MoveAddChar(y, x int, ach Char)

MoveAddChar prints a single character to the window at the specified y x coordinates. See AddChar for more info.

func (*Window) MoveDelChar

func (w *Window) MoveDelChar(y, x int) error

MoveDelChar deletes the character at the given cursor coordinates, moving all characters to the right of that position one space to the left and appends a blank character at the end.

func (*Window) MoveGetChar

func (w *Window) MoveGetChar(y, x int) Key

MoveGetChar moves the cursor to the given position and gets a character from the input stream

func (*Window) MoveInChar

func (w *Window) MoveInChar(y, x int) Char

MoveInChar returns the character at the designated coordates in the curses window

func (*Window) MovePrint

func (w *Window) MovePrint(y, x int, args ...interface{})

MovePrint moves the cursor to the specified coordinates and prints the supplied message. See Print for more details.The first two arguments are the coordinates to print to.

func (*Window) MovePrintf

func (w *Window) MovePrintf(y, x int, format string, args ...interface{})

MovePrintf moves the cursor to coordinates and prints the message using the specified format. See Printf and MovePrint for more information.

func (*Window) MovePrintln

func (w *Window) MovePrintln(y, x int, args ...interface{})

MovePrintln moves the cursor to coordinates and prints the message. See Println and MovePrint for more details.

func (*Window) MoveWindow

func (w *Window) MoveWindow(y, x int)

MoveWindow moves the location of the window to the specified coordinates

func (*Window) NoutRefresh

func (w *Window) NoutRefresh()

NoutRefresh, or No Output Refresh, flags the window for redrawing but does not output the changes to the terminal (screen). Essentially, the output is buffered and a call to Update() flushes the buffer to the terminal. This function provides a speed increase over calling Refresh() when multiple windows are involved because only the final output is transmitted to the terminal.

func (*Window) Overlay

func (w *Window) Overlay(src *Window) error

Overlay copies overlapping sections of src window onto the destination window. Non-blank elements are not overwritten.

func (*Window) Overwrite

func (w *Window) Overwrite(src *Window) error

Overwrite copies overlapping sections of src window onto the destination window. This function is considered "destructive" by copying all elements of src onto the destination window.

func (*Window) Parent

func (w *Window) Parent() *Window

Parent returns a pointer to a Sub-window's parent, or nil if the window has no parent

func (*Window) Print

func (w *Window) Print(args ...interface{})

Print a string to the given window. See the fmt package in the standard library for more information. In order to simulate the 'n' version of functions (like addnstr) just slice your string to the maximum length before passing it as an argument. window.Print("My line which should be clamped to 20 characters"[:20])

func (*Window) Printf

func (w *Window) Printf(format string, args ...interface{})

Printf functions the same as the standard library's fmt package. See Print for more details.

func (*Window) Println

func (w *Window) Println(args ...interface{})

Println behaves the same as the standard library's fmt package. See Print for more information.

func (*Window) Refresh

func (w *Window) Refresh()

Refresh the window so it's contents will be displayed

func (*Window) Resize

func (w *Window) Resize(height, width int)

Resize the window to new height, width

func (*Window) Scroll

func (w *Window) Scroll(n int)

Scroll the contents of the window. Use a negative number to scroll up, a positive number to scroll down. ScrollOk Must have been called prior.

func (*Window) ScrollOk

func (w *Window) ScrollOk(ok bool)

ScrollOk sets whether scrolling will work

func (*Window) SetBackground

func (w *Window) SetBackground(attr Char)

SetBackground fills the background with the supplied attributes and/or characters.

func (*Window) Standend

func (w *Window) Standend() error

Standend turns off Standout mode, which is equivalent AttrSet(A_NORMAL)

func (*Window) Standout

func (w *Window) Standout() error

Standout is equivalent to AttrSet(A_STANDOUT)

func (*Window) Sub

func (w *Window) Sub(height, width, y, x int) *Window

SubWindow creates a new window of height and width at the coordinates y, x. This window shares memory with the original window so changes made to one window are reflected in the other. It is necessary to call Touch() on this window prior to calling Refresh in order for it to be displayed.

func (*Window) Sync

func (w *Window) Sync(sync int)

Sync updates all parent or child windows which were created via SubWindow() or DerivedWindow(). Argument can be one of: SYNC_DOWN, which syncronizes all parent windows (done by Refresh() by default so should rarely, if ever, need to be called); SYNC_UP, which updates all child windows to match any updates made to the parent; and, SYNC_CURSOR, which updates the cursor position only for all windows to match the parent window

func (*Window) Timeout

func (w *Window) Timeout(delay int)

Timeout sets the window to blocking or non-blocking read mode. Calls to GetCh will behave in the following manor depending on the value of delay: <= -1 - blocking mode is set (blocks indefinitely) == 0 - non-blocking; returns zero (0) >= 1 - blocks for delay in milliseconds; returns zero (0)

func (*Window) Touch

func (w *Window) Touch() error

Touch indicates that the window contains changes which should be updated on the next call to Refresh

func (*Window) TouchLine

func (w *Window) TouchLine(start, count int) error

Touchline behaves like Touch but only effects count number of lines, beginning at start

func (*Window) Touched

func (w *Window) Touched() bool

Touched returns true if window will be updated on the next Refresh

func (*Window) UnTouch

func (w *Window) UnTouch()

UnTouch indicates the window should not be updated on the next call to Refresh

func (*Window) VLine

func (w *Window) VLine(y, x int, ch Char, wid int)

VLine draws a vertical line starting at y, x and ending at height using the specified character

func (*Window) YX

func (w *Window) YX() (int, int)

YX returns the current coordinates of the Window. Note that it uses ncurses idiom of returning y then x.

Directories

Path Synopsis
examples
acs
An example of using AddChar to show a non-standard character.
An example of using AddChar to show a non-standard character.
color
Demonstrates some of the color facilities of ncurses
Demonstrates some of the color facilities of ncurses
concurrency
This example demonstrates using goncurses with Go's built-in concurrency primitives.
This example demonstrates using goncurses with Go's built-in concurrency primitives.
curs_menu
This example show a basic menu similar to that found in the ncurses * examples from TLDP
This example show a basic menu similar to that found in the ncurses * examples from TLDP
form
This simple example demonstrates how to implement a form
This simple example demonstrates how to implement a form
getstr
This example demonstrates reading a string from input, rather than a * single character
This example demonstrates reading a string from input, rather than a * single character
hello
The classic "Hello, World!" program in Goncurses!
The classic "Hello, World!" program in Goncurses!
init
Demonstrates some of the initilization options for ncurses;
Demonstrates some of the initilization options for ncurses;
menu
This example demonstrates the use of the menu library
This example demonstrates the use of the menu library
menu_mcol
This example shows a basic multi-column menu similar to that found in the * ncurses examples from TLDP
This example shows a basic multi-column menu similar to that found in the * ncurses examples from TLDP
menu_scroll
This example shows a scrolling menu similar to that found in the ncurses * examples from TLDP
This example shows a scrolling menu similar to that found in the ncurses * examples from TLDP
menu_subwin
This example show a basic menu similar to that found in the ncurses * examples from TLDP
This example show a basic menu similar to that found in the ncurses * examples from TLDP
menugrey
This example show a basic menu similar to that found in the ncurses * examples from TLDP
This example show a basic menu similar to that found in the ncurses * examples from TLDP
menutoggle
This example show a basic menu similar to that found in the ncurses * examples from TLDP
This example show a basic menu similar to that found in the ncurses * examples from TLDP
mouse
Expanding on the basic menu example, the example demonstrates how you * could possibly utilize the mouse to navigate a menu and select options
Expanding on the basic menu example, the example demonstrates how you * could possibly utilize the mouse to navigate a menu and select options
newterm
This example demonstrates how one might write to multiple terminals from a single program or redirect output.
This example demonstrates how one might write to multiple terminals from a single program or redirect output.
pad
A basic example of how to create and display a pad.
A basic example of how to create and display a pad.
panel
A simmple example of how to use panels
A simmple example of how to use panels
panel2
A slightly more advanced example of how to use the panel routines
A slightly more advanced example of how to use the panel routines
print
This example demonstrates the use of the print function.
This example demonstrates the use of the print function.
resize
This example demonstrates the ability to resize.
This example demonstrates the ability to resize.
slk
Demonstarates the use of the SLK Soft-Keys facilities
Demonstarates the use of the SLK Soft-Keys facilities
starfield
Starfield is a simple Goncurses game demo.
Starfield is a simple Goncurses game demo.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL