X-Git-Url: https://plomlompom.com/repos/index.html?a=blobdiff_plain;f=windows.c;h=6a649a325b187894c8ddc46b6eb34b51f680f68f;hb=e1ae0a05e12a8a0aec170d9d3b795ca0dc74e6ed;hp=77a35b28556e267a837e59d08c53b4f869db8d08;hpb=969ba2899d6abd9d06a187098a5cd015d1aac1e0;p=plomrogue
diff --git a/windows.c b/windows.c
index 77a35b2..6a649a3 100644
--- a/windows.c
+++ b/windows.c
@@ -13,9 +13,17 @@ struct WinMeta init_win_meta (WINDOW * screen) {
win_meta.chain_end = 0;
win_meta.pad_offset = 0;
win_meta.pad = newpad(win_meta.height, 1);
+ win_meta.active = 0;
return win_meta; }
-struct Win init_window (struct WinMeta * win_meta, char * title) {
+void scroll_pad (struct WinMeta * win_meta, char dir) {
+// Scroll pad left (if possible) or right.
+ if ('+' == dir)
+ win_meta->pad_offset++;
+ else if ('-' == dir && win_meta->pad_offset > 0)
+ win_meta->pad_offset--; }
+
+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;
@@ -24,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) {
@@ -184,17 +194,12 @@ 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 (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++;
- update_windows(win_meta, win_meta->chain_start); }
+ 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) {
// Cycle active window selection forwards (dir = 'n') or backwards.
@@ -210,9 +215,9 @@ 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 (win_meta->chain_start != win_meta->chain_end && (dir == 'f' || dir == 'b')) {
+ if (0 != win_meta->active && win_meta->chain_start != win_meta->chain_end && (dir == 'f' || dir == 'b')) {
int i, i_max;
struct Win * win_shift = win_meta->active;
char wrap = 0;