about summary refs log tree commit diff
path: root/Doc/Zsh/mod_curses.yo
blob: 993584ea1bf34bd20340aa889f30aa92718711fb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
COMMENT(!MOD!zsh/curses
curses windowing commands
!MOD!)
The tt(zsh/curses) module makes available one builtin command and
various parameters.

subsect(Builtin)

startitem()
findex(zcurses)
cindex(windows, curses)
xitem(tt(zcurses) tt(init))
xitem(tt(zcurses) tt(end))
xitem(tt(zcurses) tt(addwin) var(targetwin) var(nlines) var(ncols) var(begin_y) var(begin_x) [ var(parentwin) ] )
xitem(tt(zcurses) tt(delwin) var(targetwin) )
xitem(tt(zcurses) tt(refresh) [ var(targetwin) ... ] )
xitem(tt(zcurses) tt(touch) var(targetwin) ...)
xitem(tt(zcurses) tt(move) var(targetwin) var(new_y) var(new_x) )
xitem(tt(zcurses) tt(clear) var(targetwin) [ tt(redraw) | tt(eol) | tt(bot) ])
xitem(tt(zcurses) tt(location) var(targetwin) var(array))
xitem(tt(zcurses) tt(char) var(targetwin) var(character) )
xitem(tt(zcurses) tt(string) var(targetwin) var(string) )
xitem(tt(zcurses) tt(border) var(targetwin) var(border) )(
xitem(tt(zcurses) tt(attr) var(targetwin) [ var({+/-}attribute) | var(fg_col)tt(/)var(bg_col) ] [...])
xitem(tt(zcurses) tt(bg) var(targetwin) [ var({+/-}attribute) | var(fg_col)tt(/)var(bg_col) | tt(@)var(char) ] [...])
xitem(tt(zcurses) tt(scroll) [ tt(on) | tt(off) | {+/-}var(lines) ])
xitem(tt(zcurses) tt(input) var(targetwin) [ var(param) [ var(kpparm) ] ])
item(tt(zcurses) tt(timeout) var(targetwin) var(intval))(
Manipulate curses windows.  All uses of this command should be
bracketed by `tt(zcurses init)' to initialise use of curses, and
`tt(zcurses end)' to end it; omitting `tt(zcurses end)' can cause
the terminal to be in an unwanted state.

With tt(addwin), create a window with var(nlines) lines and var(ncols) columns.
Its upper left corner will be placed at row var(begin_y) and column
var(begin_x) of the screen.  var(targetwin) is a string and refers
to the name of a window that is not currently assigned.  Note
in particular the curses convention that vertical values appear
before horizontal values.

If tt(addwin) is given an existing window as the final argument, the new
window is created as a subwindow of var(parentwin).  This differs from an
ordinary new window in that the memory of the window contents is shared
with the parent's memory.  Subwindows must be deleted before their parent.
Note that the coordinates of subwindows are relative to the screen, not
the parent, as with other windows.

Use tt(delwin) to delete a window created with tt(addwin).  Note
that tt(end) does em(not) implicitly delete windows, and that
tt(delwin) does not erase the screen image of the window.

The window corresponding to the full visible screen is called
tt(stdscr); it always exists after `tt(zcurses init)' and cannot
be delete with tt(delwin).

The tt(refresh) command will refresh window var(targetwin); this is
necessary to make any pending changes (such as characters you have
prepared for output with tt(char)) visible on the screen.  tt(refresh)
without an argument causes the screen to be cleared and redrawn.
If multiple windows are given, the screen is updated once at the end.

The tt(touch) command marks the var(targetwin)s listed as changed.
This is necessary before tt(refresh)ing windows if a window that
was in front of another window (which may be tt(stdscr)) is deleted.

tt(move) moves the cursor position in var(targetwin) to new coordinates
var(new_y) and var(new_x).

tt(clear) erases the contents of var(targetwin).  One (and no more than one)
of three options may be specified.  With the option tt(redraw),
in addition the next tt(refresh) of var(targetwin) will cause the screen to be
cleared and repainted.  With the option tt(eol), var(targetwin) is only
cleared to the end of the current cursor line.  With the option
tt(bot), var(targetwin) is cleared to the end of the window, i.e
everything to the right and below the cursor is cleared.

tt(location) writes various positions associated with var(targetwin)
into the array named var(array).
These are, in order:
startsitem()
sitem()(The y and x coordinates of the cursor relative to the top left
of var(targetwin))
sitem()(The y and x coordinates of the top left of var(targetwin) on the
screen)
sitem()(The size of var(targetwin) in y and x dimensions.)
endsitem()

Outputting characters and strings are achieved by tt(char) and tt(string)
respectively.

To draw a border around window var(targetwin), use tt(border).  Note
that the border is not subsequently handled specially:  in other words,
the border is simply a set of characters output at the edge of the
window.  Hence it can be overwritten, can scroll off the window, etc.

tt(attr) will set var(targetwin)'s attributes or foreground/background
color pair for any successive character output.  Each var(attribute)
given on the line may be prepended by a tt(+) to set or a tt(-) to
unset that attribute; tt(+) is assumed if absent.  The attributes
supported are tt(blink), tt(bold), tt(dim), tt(reverse), tt(standout),
and tt(underline).

Each var(fg_col)tt(/)var(bg_col) attribute (to be read as
`var(fg_col) on var(bg_col)') sets the foreground and background color
for character output.  The color tt(default) is sometimes available
(in particular if the library is ncurses), specifying the foreground
or background color with which the terminal started.  The color pair
tt(default/default) is always available.

tt(bg) overrides the color and other attributes of all characters in the
window.  Its usual use is to set the background initially, but it will
overwrite the attributes of any characters at the time when it is called.
In addition to the arguments allowed with tt(attr), an argument tt(@)var(char)
specifies a character to be shown in otherwise blank areas of the window.
Owing to limitations of curses this cannot be a multibyte character
(use of ASCII characters only is recommended).  As the specified set
of attributes override the existing background, turning attributes
off in the arguments is not useful, though this does not cause an error.

tt(scroll) can be used with tt(on) or tt(off) to enabled or disable
scrolling of a window when the cursor would otherwise move below the
window due to typing or output.  It can also be used with a positive
or negative integer to scroll the window up or down the given number
of lines without changing the current cursor position (which therefore
appears to move in the opposite direction relative to the window).
In the second case, if scrolling is tt(off) it is temporarily turned tt(on)
to allow the window to be scrolled.

tt(input) reads a single character from the window without echoing
it back.  If var(param) is supplied the character is assigned to the
parameter var(param), else it is assigned to the parameter var(REPLY).
If both var(param) and var(kpparam) are supplied, the key is read
in `keypad' mode.  In this mode special keys such as function keys
and arrow keys return the name of the key in the parameter var(kpparam).
The key names are the macros defined in the tt(curses.h) or tt(ncurses.h)
with the prefix `tt(KEY_)' removed.  Other keys cause a value to be set in
var(param) as before.  On a succesful return only one of var(param) or
var(kpparm) contains a non-empty string; the other is set to an empty
string.

tt(timeout) specifies a timeout value for input from var(targetwin).
If var(intval) is negative, `tt(zcurses input)' waits indefinitely for
a character to be typed; this is the default.  If var(intval) is zero,
`tt(zcurses input)' returns immediately; if there is typeahead it is
returned, else no input is done and status 1 is returned.  If var(intval)
is positive, `tt(zcurses input)' waits var(intval) milliseconds for
input and if there is none at the end of that period returns status 1.
)
enditem()

subsect(Parameters)

startitem()
vindex(ZCURSES_COLORS)
item(tt(ZCURSES_COLORS))(
Readonly integer.  The maximum number of colors the terminal
supports.  This value is initialised by the curses library and is not
available until the first time tt(zcurses init) is run.
)
vindex(ZCURSES_COLOR_PAIRS)
item(tt(ZCURSES_COLOR_PAIRS))(
Readonly integer.  The maximum number of color pairs
var(fg_col)tt(/)var(bg_col) that may be defined in `tt(zcurses attr)'
commands; note this limit applies to all color pairs that have been
used whether or not they are currently active.  This value is initialised
by the curses library and is not available until the first time tt(zcurses
init) is run.
)
vindex(zcurses_attrs)
item(tt(zcurses_attrs))(
Readonly array.  The attributes supported by tt(zsh/curses); available
as soon as the module is loaded.
)
vindex(zcurses_colors)
item(tt(zcurses_colors))(
Readonly array.  The colors supported by tt(zsh/curses); available
as soon as the module is loaded.
)
vindex(zcurses_keycodes)
item(tt(zcurses_keycodes))(
Readonly array.  The values that may be returned in the second
parameter supplied to `tt(zcurses input)' in the order in which they
are defined internally by curses.  Not all function keys
are listed, only tt(F0); curses reserves space for tt(F0) up to tt(F63).
)
vindex(zcurses_windows)
item(tt(zcurses_windows))(
Readonly array.  The current list of windows, i.e. all windows that
have been created with `tt(zcurses addwin)' and not removed with
`tt(zcurses delwin)'.
)
enditem()