6 * MuCurses core functions
24 * Write a single character rendition to a window
26 * @v *win window in which to write
27 * @v ch character rendition to write
28 * @v wrap wrap "switch"
30 void _wputch ( WINDOW *win, chtype ch, int wrap ) {
31 /* make sure we set the screen cursor to the right position
33 win->scr->movetoyx( win->scr, win->ori_y + win->curs_y,
34 win->ori_x + win->curs_x );
35 win->scr->putc(win->scr, ch);
36 if ( ++(win->curs_x) - win->width == 0 ) {
39 /* specification says we should really scroll,
40 but we have no buffer to scroll with, so we
41 can only overwrite back at the beginning of
43 if ( ++(win->curs_y) - win->height == 0 )
52 * Retreat the cursor back one position (useful for a whole host of
55 * @v *win window in which to retreat
57 void _wcursback ( WINDOW *win ) {
58 if ( win->curs_x == 0 ) {
59 if ( win->curs_y == 0 )
60 win->curs_y = win->height - 1;
61 win->curs_x = win->width = 1;
66 win->scr->movetoyx( win->scr, win->ori_y + win->curs_y,
67 win->ori_x + win->curs_x );
71 * Write a chtype string to a window
73 * @v *win window in which to write
74 * @v *chstr chtype string
75 * @v wrap wrap "switch"
76 * @v n write at most n chtypes
78 void _wputchstr ( WINDOW *win, const chtype *chstr, int wrap, int n ) {
79 for ( ; *chstr && n-- ; chstr++ ) {
80 _wputch(win,*chstr,wrap);
85 * Write a standard c-style string to a window
87 * @v *win window in which to write
89 * @v wrap wrap "switch"
90 * @v n write at most n chars from *str
92 void _wputstr ( WINDOW *win, const char *str, int wrap, int n ) {
93 for ( ; *str && n-- ; str++ ) {
94 _wputch( win, *str | win->attrs, wrap );
99 * Move a window's cursor to the specified position
101 * @v *win window to be operated on
104 * @ret rc return status code
106 int wmove ( WINDOW *win, int y, int x ) {
107 /* chech for out-of-bounds errors */
108 if ( ( (unsigned)y >= win->height ) ||
109 ( (unsigned)x >= win->width ) ) {
115 win->scr->movetoyx( win->scr, win->ori_y + win->curs_y,
116 win->ori_x + win->curs_x );