summaryrefslogtreecommitdiff
path: root/src/dged/window.c
diff options
context:
space:
mode:
authorAlbert Cervin <albert@acervin.com>2023-05-07 23:59:22 +0200
committerAlbert Cervin <albert@acervin.com>2023-05-08 00:00:36 +0200
commit24cff0ec31970d5d57f61ba99ba7bfdda725cf94 (patch)
tree8304f69e38ec33d663db21ee26dbee14bf8d7a2f /src/dged/window.c
parent8d73eace6806bd67852189b1a16de5895c565688 (diff)
downloaddged-24cff0ec31970d5d57f61ba99ba7bfdda725cf94.tar.gz
dged-24cff0ec31970d5d57f61ba99ba7bfdda725cf94.tar.xz
dged-24cff0ec31970d5d57f61ba99ba7bfdda725cf94.zip
Implement file reloading
When for examplue using formatters or doing vc updates, it is useful if the file is reloaded from disk.
Diffstat (limited to 'src/dged/window.c')
-rw-r--r--src/dged/window.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/dged/window.c b/src/dged/window.c
index f24997c..efdcd29 100644
--- a/src/dged/window.c
+++ b/src/dged/window.c
@@ -5,6 +5,8 @@
#include "display.h"
#include "minibuffer.h"
+#include <math.h>
+
enum window_type {
Window_Buffer,
Window_HSplit,
@@ -96,8 +98,8 @@ static void window_tree_resize(struct window_node *root, uint32_t height,
BINTREE_PARENT(root) = NULL;
struct window *root_window = &BINTREE_VALUE(root);
- uint32_t width_ratio_percent = (width * 100) / (root_window->width);
- uint32_t height_ratio_percent = (height * 100) / (root_window->height);
+ uint32_t original_root_width = root_window->width;
+ uint32_t original_root_height = root_window->height;
root_window->width = width;
root_window->height = height;
@@ -108,8 +110,10 @@ static void window_tree_resize(struct window_node *root, uint32_t height,
if (BINTREE_PARENT(n) != NULL && n != root) {
if (BINTREE_LEFT(BINTREE_PARENT(n)) == n) {
// if left child, use scale from root
- w->width = (width_ratio_percent * w->width) / 100;
- w->height = (height_ratio_percent * w->height) / 100;
+ w->width = round(((float)w->width / (float)original_root_width) *
+ (float)root_window->width);
+ w->height = round(((float)w->height / (float)original_root_height) *
+ (float)root_window->height);
} else {
// if right child, fill rest of space after left and parent resize
struct window *left_sibling =