X-Git-Url: https://plomlompom.com/repos/index.html?a=blobdiff_plain;f=windows.c;h=659318deeea90a4343f95437eec3f9cc92804c4c;hb=c4dd7e96a38e28dbfd50104cfc8ab35eff5fbf77;hp=af6647978a0aa98b2411c6d16e089ef9bcfa99bd;hpb=a068b574ce8ac851be5ca1aefbaa487ef6c8e60e;p=plomrogue
diff --git a/windows.c b/windows.c
index af66479..659318d 100644
--- a/windows.c
+++ b/windows.c
@@ -13,8 +13,16 @@ 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; }
+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) {
// Create and populate Win struct with sane default values.
struct Win win;
@@ -186,32 +194,34 @@ void draw_all_windows (struct WinMeta * win_meta) {
void resize_window (struct WinMeta * win_meta, char change) {
// Grow or shrink currently active window. Correct its geometry and that of its followers.
- if (change == '-' && win_meta->active->height > 1)
+ 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)
+ 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); }
+ else if (change == '*')
+ win_meta->active->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.
- if ('n' == dir) {
- if (win_meta->active->next != 0)
- win_meta->active = win_meta->active->next;
- else
- win_meta->active = win_meta->chain_start; }
- else {
- if (win_meta->active->prev != 0)
- win_meta->active = win_meta->active->prev;
- else
- win_meta->active = win_meta->chain_end; } }
+ if (0 != win_meta->active) {
+ if ('n' == dir) {
+ if (win_meta->active->next != 0)
+ win_meta->active = win_meta->active->next;
+ else
+ win_meta->active = win_meta->chain_start; }
+ else {
+ if (win_meta->active->prev != 0)
+ win_meta->active = win_meta->active->prev;
+ else
+ win_meta->active = win_meta->chain_end; } } }
void shift_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;