Author: mesyeti <mesyeti@mesyeti.uk>
add resizing
source/app.c | 8 +++++--- source/pane.c | 17 +++++++++++++++++ source/terminal.c | 5 +++++ source/terminal.h | 1 +
diff --git a/source/app.c b/source/app.c index daaaa27944d23383c19498aec1ab46fe35c0d818..21a29ceafee71ab75e5c8994b23387de72d62152 100644 --- a/source/app.c +++ b/source/app.c @@ -50,10 +50,12 @@ Screen_OnWindowResize(); break; } default: { - for (size_t i = 0; i < app.tabNum; ++ i) { - Pane_HandleEvent(&app.tabs[i], &e); - } + } + } + + for (size_t i = 0; i < app.tabNum; ++ i) { + Pane_HandleEvent(&app.tabs[i], &e); } } diff --git a/source/pane.c b/source/pane.c index d992e96a77e0e0ee4448006074481ee2c3748843..a0e7de216ae848710b3846c08a724e2b110609de 100644 --- a/source/pane.c +++ b/source/pane.c @@ -34,6 +34,23 @@ } } void Pane_HandleEvent(Pane* pane, Event* e) { + switch (e->type) { + case EVENT_WINDOW_RESIZE: { + if (pane->type != PANE_TERMINAL) break; + + int cw; + int ch; + Font_CharSize(&screen.font, &cw, &ch); + + int newW = video.windows[0].width / cw; + int newH = (video.windows[0].height / ch) - 1; + + Terminal_Resize(&pane->v.terminal, newW, newH); + return; + } + default: break; + } + switch (pane->type) { case PANE_SPLIT: { if (pane->v.split.left) Pane_HandleEvent(pane->v.split.left, e); diff --git a/source/terminal.c b/source/terminal.c index b24212d8c1610280ec862fdc3c5497da45f40a9c..142e709e0352ba70601727fcb14f6a7f68ccee77 100644 --- a/source/terminal.c +++ b/source/terminal.c @@ -51,3 +51,8 @@ } default: break; } } + +void Terminal_Resize(Terminal* terminal, int w, int h) { + Buffer_Resize(&terminal->buffer, w, h); + SysTerm_UpdateSize(&terminal->term, w, h); +} diff --git a/source/terminal.h b/source/terminal.h index 14399f7a07dfdb138b56ce5d118903ca49ba0403..84f7482cc3567599a4033126be58e1860dcad420 100644 --- a/source/terminal.h +++ b/source/terminal.h @@ -22,5 +22,6 @@ Terminal Terminal_New(int w, int h, bool* success); void Terminal_Free(Terminal* terminal); void Terminal_Update(Terminal* terminal); void Terminal_HandleEvent(Terminal* terminal , Event* e, bool isSelected); +void Terminal_Resize(Terminal* terminal, int w, int h); #endif