diff --git a/rust/src/plane/methods.rs b/rust/src/plane/methods.rs index ec9df7cef..62831e3fb 100644 --- a/rust/src/plane/methods.rs +++ b/rust/src/plane/methods.rs @@ -13,7 +13,7 @@ use crate::{ impl NcPlaneOptions { /// New NcPlaneOptions using the horizontal x. pub fn new(y: NcOffset, x: NcOffset, rows: NcDim, cols: NcDim) -> Self { - Self::with_flags(y, x, rows, cols, None, 0) + Self::with_flags(y, x, rows, cols, None, 0, 0, 0) } /// New NcPlaneOptions with horizontal alignment. @@ -68,8 +68,8 @@ impl NcPlaneOptions { name: null(), resizecb: crate::ncresizecb_to_c(resizecb), flags, - 0, - 0, + margin_b: 0, + margin_r: 0, } } } diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 4244cfe97..079093d11 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -2184,9 +2184,27 @@ int (*ncplane_resizecb(const ncplane* n))(ncplane*){ } int ncplane_resize_marginalized(ncplane* n){ - (void)n;// FIXME uhhh do something here -fprintf(stderr, "NEED TO RESIZE THIS MARGINALIZED-ASS PLANE\n"); - return 0; + const ncplane* parent = ncplane_parent_const(n); + // a marginalized plane cannot be larger than its oppressor plane =] + int maxy, maxx; + if(parent == n){ // root plane, need to use pile size + return 0; // FIXME + }else{ + ncplane_dim_yx(parent, &maxy, &maxx); + } + if((maxy -= n->margin_b) < 1){ + maxy = 1; + } + if((maxx -= n->margin_r) < 1){ + maxx = 1; + } + // FIXME mix in top/left margins (absy/absx) + int oldy, oldx; + ncplane_dim_yx(n, &oldy, &oldx); // current dimensions of 'n' + int keepleny = oldy > maxy ? maxy : oldy; + int keeplenx = oldx > maxx ? maxx : oldx; + // FIXME place it according to top/left + return ncplane_resize_internal(n, 0, 0, keepleny, keeplenx, 0, 0, maxy, maxx); } int ncplane_resize_maximize(ncplane* n){