Outcurses: Difference between revisions

Line 189: Line 189:
push A off-screen. B would then have eight lines of text, the maximum on a
push A off-screen. B would then have eight lines of text, the maximum on a
12-line screen with both types of borders.
12-line screen with both types of borders.
===Panelreel usage===
<tt>create_panelreel()</tt> is called with a <tt>panelreel_options</tt> struct, returning NULL on error. This struct includes:
* <tt>WINDOW* w</tt> -- the ncurses WINDOW on which this panelreel lives
* <tt>int footerlines, headerlines</tt> -- how many lines to leave on the top and bottom of the WINDOW
* <tt>int leftcolumns, rightcolumns</tt> -- how many columns to leave on the left and right of the WINDOW
* <tt>bool infinitescroll</tt> -- whether the line segment ought be looped into a torus
* <tt>bool circular</tt> -- set true for reel rotation, false for focus rotation, when panelreel doesn't occupy entire screen
* <tt>LineCountCB linecb</tt> and <tt>DrawLinesCB drawcb</tt> -- callbacks, see below
** It is invalid to set circular but not set infinitescroll. NULL will be returned
Two callbacks must be provided: a <tt>LineCountCB</tt> and a <tt>DrawLinesCB</tt>. Most actions on a panelreel can result in these callbacks being called one or more times, possibly in an interleaved fashion. Note that a change in one tablet can result in a change of the <i>position</i> of another tablet, and thus the <i>number</i> and <i>identity</i> of lines displayed in that tablet, so more than one tablet can be the subject of callbacks. Furthermore, note that the screen is a composition of tablets <i>as they stand at some time</i>, so a tablet must not change between the callbacks triggered by a given call.
The natural implication is that, prior to calling a panelreel function, the caller ought take a lock, and this lock ought cover *all material relevant to display, for all tablets*. Only upon return from outcurses can this lock be unlocked. Yes, this is a very coarse locking scheme, with some latency in the critical section. If you need to continue processing events at a high rate while updating the panelreel, collapse them into an intermediate structure, and have your calling thread pull in those data. Or something. The most common effect of failure to do this is empty lines in a tablet.


==Panel animations==
==Panel animations==