~bduggan/raku-terminal-ui

090e686b1e240537b7ad96dfb79aa89a78a26ec7 — Brian Duggan 2 years ago 8344a38
remove-top
3 files changed, 18 insertions(+), 2 deletions(-)

M eg/30-remove-frame-2.raku -rw-r--r-- => -rwxr-xr-x
M eg/30-remove-frame.raku -rw-r--r-- => -rwxr-xr-x
M lib/Terminal/UI/Frame.rakumod
M eg/30-remove-frame-2.raku => eg/30-remove-frame-2.raku +1 -2
@@ 15,8 15,7 @@ for ui.panes.kv -> $i, $p {
   if ( ui.frame.remove-pane($p) ) {
     ui.refresh(:hard);
     ui.alert("removed pane $i");
     ui.panes[0].clear;
     ui.panes[0].put: ui.screen.frame.check(ui.panes) // 'okay';
     ui.panes[0].put: ui.screen.frame.check(ui.panes) // "no issues removing pane $i";
   } else {
     ui.alert("failed to remove pane $i");
   }

M eg/30-remove-frame.raku => eg/30-remove-frame.raku +0 -0
M lib/Terminal/UI/Frame.rakumod => lib/Terminal/UI/Frame.rakumod +17 -0
@@ 133,12 133,29 @@ method add-pane {
  @.panes.tail;
}

#| Remove pane $pane from this frame, and extend the one above it.
multi method remove-pane(Terminal::UI::Pane $pane) {
  my Int $index = self.panes.first: :k, { $_ === $pane };
  return False without $index;
  return self.remove-pane('top') if $index == 0;
  self.remove-pane($index);
}

#| Remove the top pane and extend the second one.
multi method remove-pane('top') {
  return False if @!panes == 1;
  my $old = @!panes.shift;
  my $first = @!dividers.shift;
  $!number-of-dividers = @!dividers.elems;
  my $adjacent = @!panes[0];
  $adjacent.set-top(self.top + 1);
  $adjacent.set-size( $old.width, $adjacent.height + $old.height + 1 );
  if $.focused === $old {
    self.focus($adjacent);
  }
  return True;
}

#| Remove pane $index from this frame, and extend the one above it.
multi method remove-pane(Int $index) {
  if $index > @!panes  - 1 {