#include <curses.h>
#include <stddef.h>
#include <stdlib.h>
#include "mucurses.h"
Go to the source code of this file.
Functions | |
| int | delwin (WINDOW *win) |
| Delete a window. | |
| WINDOW * | derwin (WINDOW *parent, int nlines, int ncols, int begin_y, int begin_x) |
| Create a new derived window. | |
| WINDOW * | dupwin (WINDOW *orig) |
| Create a duplicate of the specified window. | |
| int | mvwin (WINDOW *win, int y, int x) |
| Move window origin to specified coordinates. | |
| WINDOW * | newwin (int nlines, int ncols, int begin_y, int begin_x) |
| Create new WINDOW. | |
| WINDOW * | subwin (WINDOW *parent, int nlines, int ncols, int begin_y, int begin_x) |
| Create a new sub-window. | |
Definition in file windows.c.
| int delwin | ( | WINDOW * | win | ) |
Delete a window.
| *win | pointer to window being deleted |
| rc | return status code |
Definition at line 18 of file windows.c.
References _wputch(), _curses_window::curs_x, _curses_window::curs_y, ERR, free(), NULL, OK, stdscr, wmove(), and WRAP.
00018 { 00019 if ( win == NULL ) 00020 return ERR; 00021 00022 /* I think we should blank the region covered by the window - 00023 ncurses doesn't do this, but they have a buffer, so they 00024 may just be deleting from an offscreen context whereas we 00025 are guaranteed to be deleting something onscreen */ 00026 wmove( win, 0, 0 ); 00027 chtype killch = (chtype)' '; 00028 do { 00029 _wputch( win, killch, WRAP ); 00030 } while ( win->curs_x + win->curs_y ); 00031 00032 free( win ); 00033 00034 wmove ( stdscr, 0, 0 ); 00035 00036 return OK; 00037 }
Create a new derived window.
| parent | parent window | |
| nlines | window height | |
| ncols | window width | |
| begin_y | window y origin (relative to parent) | |
| begin_x | window x origin (relative to parent) |
| ptr | return pointer to child window |
Definition at line 49 of file windows.c.
References _curses_window::height, malloc(), NULL, _curses_window::ori_x, _curses_window::ori_y, _curses_window::parent, _curses_window::scr, and _curses_window::width.
00050 { 00051 WINDOW *child; 00052 if ( parent == NULL ) 00053 return NULL; 00054 if ( ( child = malloc( sizeof( WINDOW ) ) ) == NULL ) 00055 return NULL; 00056 if ( ( (unsigned)ncols > parent->width ) || 00057 ( (unsigned)nlines > parent->height ) ) 00058 return NULL; 00059 child->ori_y = parent->ori_y + begin_y; 00060 child->ori_x = parent->ori_x + begin_x; 00061 child->height = nlines; 00062 child->width = ncols; 00063 child->parent = parent; 00064 child->scr = parent->scr; 00065 return child; 00066 }
Create a duplicate of the specified window.
| orig | original window |
| ptr | pointer to duplicate window |
Definition at line 74 of file windows.c.
References _curses_window::attrs, _curses_window::curs_x, _curses_window::curs_y, _curses_window::height, malloc(), NULL, _curses_window::ori_x, _curses_window::ori_y, _curses_window::scr, and _curses_window::width.
00074 { 00075 WINDOW *copy; 00076 if ( orig == NULL ) 00077 return NULL; 00078 if ( ( copy = malloc( sizeof( WINDOW ) ) ) == NULL ) 00079 return NULL; 00080 copy->scr = orig->scr; 00081 copy->attrs = orig->attrs; 00082 copy->ori_y = orig->ori_y; 00083 copy->ori_x = orig->ori_x; 00084 copy->curs_y = orig->curs_y; 00085 copy->curs_x = orig->curs_x; 00086 copy->height = orig->height; 00087 copy->width = orig->width; 00088 return copy; 00089 }
| int mvwin | ( | WINDOW * | win, | |
| int | y, | |||
| int | x | |||
| ) |
Move window origin to specified coordinates.
| *win | window to move | |
| y | Y position | |
| x | X position |
| rc | return status code |
Definition at line 99 of file windows.c.
References COLS, ERR, _curses_window::height, LINES, NULL, OK, _curses_window::ori_x, _curses_window::ori_y, and _curses_window::width.
00099 { 00100 if ( win == NULL ) 00101 return ERR; 00102 if ( ( ( (unsigned)y + win->height ) > LINES ) || 00103 ( ( (unsigned)x + win->width ) > COLS ) ) 00104 return ERR; 00105 00106 win->ori_y = y; 00107 win->ori_x = x; 00108 00109 return OK; 00110 }
| WINDOW* newwin | ( | int | nlines, | |
| int | ncols, | |||
| int | begin_y, | |||
| int | begin_x | |||
| ) |
Create new WINDOW.
| nlines | number of lines | |
| ncols | number of columns | |
| begin_y | column origin | |
| begin_x | line origin |
| *win | return pointer to new window |
Definition at line 121 of file windows.c.
References _curses_window::height, malloc(), NULL, _curses_window::ori_x, _curses_window::ori_y, _curses_window::parent, _curses_window::scr, stdscr, and _curses_window::width.
Referenced by subwin().
00121 { 00122 WINDOW *win; 00123 if ( ( win = malloc( sizeof(WINDOW) ) ) == NULL ) 00124 return NULL; 00125 if ( ( (unsigned)( begin_y + nlines ) > stdscr->height ) && 00126 ( (unsigned)( begin_x + ncols ) > stdscr->width ) ) 00127 return NULL; 00128 win->ori_y = begin_y; 00129 win->ori_x = begin_x; 00130 win->height = nlines; 00131 win->width = ncols; 00132 win->scr = stdscr->scr; 00133 win->parent = stdscr; 00134 return win; 00135 }
Create a new sub-window.
| orig | parent window | |
| nlines | window height | |
| ncols | window width | |
| begin_y | window y origin (absolute) | |
| begin_x | window x origin (absolute) |
| ptr | return pointer to child window |
Definition at line 147 of file windows.c.
References malloc(), newwin(), NULL, _curses_window::parent, and _curses_window::scr.
00148 { 00149 WINDOW *child; 00150 if ( parent == NULL ) 00151 return NULL; 00152 if ( ( child = malloc( sizeof( WINDOW ) ) ) == NULL ) 00153 return NULL; 00154 child = newwin( nlines, ncols, begin_y, begin_x ); 00155 child->parent = parent; 00156 child->scr = parent->scr; 00157 return child; 00158 }
1.5.7.1