X-Git-Url: https://plomlompom.com/repos/index.html?a=blobdiff_plain;f=windows.c;h=6a649a325b187894c8ddc46b6eb34b51f680f68f;hb=5e78457b82ee45796bd391daeeb1e35ff5b8fe17;hp=659318deeea90a4343f95437eec3f9cc92804c4c;hpb=c4dd7e96a38e28dbfd50104cfc8ab35eff5fbf77;p=plomrogue
diff --git a/windows.c b/windows.c
index 659318d..6a649a3 100644
--- a/windows.c
+++ b/windows.c
@@ -23,7 +23,7 @@ void scroll_pad (struct WinMeta * win_meta, char dir) {
else if ('-' == dir && win_meta->pad_offset > 0)
win_meta->pad_offset--; }
-struct Win init_window (struct WinMeta * win_meta, char * title) {
+struct Win init_window (struct WinMeta * win_meta, char * title, void * data, void * func) {
// Create and populate Win struct with sane default values.
struct Win win;
win.prev = 0;
@@ -32,6 +32,8 @@ struct Win init_window (struct WinMeta * win_meta, char * title) {
win.title = title;
win.width = 20;
win.height = win_meta->height - 1;
+ win.data = data;
+ win.draw = func;
return win; }
void append_window (struct WinMeta * win_meta, struct Win * win) {
@@ -192,17 +194,11 @@ void draw_all_windows (struct WinMeta * win_meta) {
free(all_corners); }
doupdate(); }
-void resize_window (struct WinMeta * win_meta, char change) {
+void resize_active_window (struct WinMeta * win_meta, int height, int width) {
// Grow or shrink currently active window. Correct its geometry and that of its followers.
- if (0 != win_meta->active) {
- if (change == '-' && win_meta->active->height > 1)
- win_meta->active->height--;
- else if (change == '+' && win_meta->active->height < win_meta->height - 1)
- win_meta->active->height++;
- else if (change == '_' && win_meta->active->width > 1)
- win_meta->active->width--;
- else if (change == '*')
- win_meta->active->width++;
+ if (0 != win_meta->active && width > 0 && height > 0 && height < win_meta->height) {
+ win_meta->active->height = height;
+ win_meta->active->width = width;
update_windows(win_meta, win_meta->chain_start); } }
void cycle_active_window (struct WinMeta * win_meta, char dir) {
@@ -219,7 +215,7 @@ void cycle_active_window (struct WinMeta * win_meta, char dir) {
else
win_meta->active = win_meta->chain_end; } } }
-void shift_window (struct WinMeta * win_meta, char dir) {
+void shift_active_window (struct WinMeta * win_meta, char dir) {
// Move active window forward/backward in window chain. If jumping beyond start/end, move to other chain end.
if (0 != win_meta->active && win_meta->chain_start != win_meta->chain_end && (dir == 'f' || dir == 'b')) {
int i, i_max;