#include "windows.h"
#include <stdint.h> /* for uint16_t, uint32_t */
-#include <ncurses.h> /* for LOTS of stuff */
+#include <ncurses.h> /* for typedefs WINDOW, chtype, wresize(), getmaxx(), */
+ /* getmaxy(), supbad(), delwin(), mvwaddch(), */
+ /* mvwaddstr(), newpad(), wnoutrefres(), erase(), */
+ /* werase(), pnoutrefresh(), doupdate() */
#include <stdlib.h> /* for malloc(), free() */
-#include <string.h> /* for strlen(), memcpy() */
+#include <string.h> /* for strlen(), strnlen(), memcpy() */
#include "yx_uint16.h" /* for yx_uint16 coordinates */
-static void update_wins (struct WinMeta * wmeta, struct Win * w)
+static void update_wins(struct WinMeta * wmeta, struct Win * w)
{
if (0 != w->frame.curses_win)
{
- destroy_win (w);
+ destroy_win(w);
}
place_win(wmeta, w);
refit_pad(wmeta);
w->start.y, w->start.x);
if (0 != w->next)
{
- update_wins (wmeta, w->next);
+ update_wins(wmeta, w->next);
}
}
-static void place_win (struct WinMeta * wmeta, struct Win * w)
+static void place_win(struct WinMeta * wmeta, struct Win * w)
{
/* First window goes into the upper-left corner. */
w->start.x = 0;
w->draw(w);
if (0 != w->next)
{
- draw_wins (w->next);
+ draw_wins(w->next);
}
}
draw_win_borderlines(w, active, pad);
if (0 != w->next)
{
- draw_wins_borderlines (w->next, w_active, pad);
+ draw_wins_borderlines(w->next, w_active, pad);
}
}
extern struct Win init_win(struct WinMeta * wmeta, char * title,
+ uint16_t height, uint16_t width,
void * data, void * func)
{
struct Win w;
w.next = 0;
w.frame.curses_win = 0;
w.title = title;
- w.frame.size.x = 20;
- w.frame.size.y = wmeta->padframe.size.y - 1;
w.data = data;
w.draw = func;
+ if (width > 0)
+ {
+ w.frame.size.x = width;
+ }
+ else
+ {
+ w.frame.size.x = 1;
+ }
+ if (height > 0 && height <= wmeta->padframe.size.y - 1)
+ {
+ w.frame.size.y = height;
+ }
+ else
+ {
+ w.frame.size.y = wmeta->padframe.size.y - 1;
+ }
return w;
}