X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=windows.c;h=ba6401b2191a28f6a64938d3b955905a9ff1e206;hb=891ff33aec8906fe8203910a26c56650ce74b904;hp=121c9faf369fdc0cd51f7dd9387c11a4b538835f;hpb=cfe04ddf916aaab0c64ce640e3ca39c7779799d8;p=plomrogue diff --git a/windows.c b/windows.c index 121c9fa..ba6401b 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; @@ -184,17 +192,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,7 +213,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;