aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2021-01-28 18:29:44 +0100
committerGitHub <noreply@github.com>2021-01-28 18:29:44 +0100
commitdd56deb2d285e12f8d2399ac1b757b5b067dffe5 (patch)
tree2933952cb27b6d7b3e1c11cd0943bb3e595912c7
parentMin max height and width (#155) (diff)
downloadsl0ppij-dd56deb2d285e12f8d2399ac1b757b5b067dffe5.tar.gz
sl0ppij-dd56deb2d285e12f8d2399ac1b757b5b067dffe5.tar.xz
sl0ppij-dd56deb2d285e12f8d2399ac1b757b5b067dffe5.zip
feat(statusbar): max status bar height (#156)
-rw-r--r--assets/plugins/status-bar.wasmbin412269 -> 479232 bytes
-rw-r--r--src/errors.rs2
-rw-r--r--src/main.rs6
-rw-r--r--src/panes/plugin_pane.rs8
-rw-r--r--src/panes/terminal_pane.rs8
-rw-r--r--src/screen.rs1
-rw-r--r--src/tab.rs6
-rw-r--r--src/wasm_vm.rs12
8 files changed, 43 insertions, 0 deletions
diff --git a/assets/plugins/status-bar.wasm b/assets/plugins/status-bar.wasm
index 0b012080..97b9be0c 100644
--- a/assets/plugins/status-bar.wasm
+++ b/assets/plugins/status-bar.wasm
Binary files differ
diff --git a/src/errors.rs b/src/errors.rs
index cb483bbc..ad2ae7eb 100644
--- a/src/errors.rs
+++ b/src/errors.rs
@@ -167,6 +167,7 @@ pub enum ScreenContext {
CloseFocusedPane,
ToggleActiveTerminalFullscreen,
SetSelectable,
+ SetMaxHeight,
ClosePane,
ApplyLayout,
NewTab,
@@ -202,6 +203,7 @@ impl From<&ScreenInstruction> for ScreenContext {
ScreenContext::ToggleActiveTerminalFullscreen
}
ScreenInstruction::SetSelectable(..) => ScreenContext::SetSelectable,
+ ScreenInstruction::SetMaxHeight(..) => ScreenContext::SetMaxHeight,
ScreenInstruction::ClosePane(_) => ScreenContext::ClosePane,
ScreenInstruction::ApplyLayout(_) => ScreenContext::ApplyLayout,
ScreenInstruction::NewTab(_) => ScreenContext::NewTab,
diff --git a/src/main.rs b/src/main.rs
index cee7398d..140c95e8 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -406,6 +406,12 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
// FIXME: Is this needed?
screen.render();
}
+ ScreenInstruction::SetMaxHeight(id, max_height) => {
+ screen
+ .get_active_tab_mut()
+ .unwrap()
+ .set_pane_max_height(id, max_height);
+ }
ScreenInstruction::ClosePane(id) => {
screen.get_active_tab_mut().unwrap().close_pane(id);
screen.render();
diff --git a/src/panes/plugin_pane.rs b/src/panes/plugin_pane.rs
index a93ff8c0..aeda170a 100644
--- a/src/panes/plugin_pane.rs
+++ b/src/panes/plugin_pane.rs
@@ -13,6 +13,7 @@ pub struct PluginPane {
pub position_and_size: PositionAndSize,
pub position_and_size_override: Option<PositionAndSize>,
pub send_plugin_instructions: SenderWithContext<PluginInstruction>,
+ pub max_height: Option<usize>,
}
impl PluginPane {
@@ -28,6 +29,7 @@ impl PluginPane {
position_and_size,
position_and_size_override: None,
send_plugin_instructions,
+ max_height: None,
}
}
}
@@ -100,6 +102,9 @@ impl Pane for PluginPane {
fn set_selectable(&mut self, selectable: bool) {
self.selectable = selectable;
}
+ fn set_max_height(&mut self, max_height: usize) {
+ self.max_height = Some(max_height);
+ }
fn render(&mut self) -> Option<String> {
// if self.should_render {
if true {
@@ -172,4 +177,7 @@ impl Pane for PluginPane {
fn clear_scroll(&mut self) {
unimplemented!()
}
+ fn max_height(&self) -> Option<usize> {
+ self.max_height
+ }
}
diff --git a/src/panes/terminal_pane.rs b/src/panes/terminal_pane.rs
index 853ae064..fe7fb585 100644
--- a/src/panes/terminal_pane.rs
+++ b/src/panes/terminal_pane.rs
@@ -46,6 +46,7 @@ pub struct TerminalPane {
pub position_and_size: PositionAndSize,
pub position_and_size_override: Option<PositionAndSize>,
pub cursor_key_mode: bool, // DECCKM - when set, cursor keys should send ANSI direction codes (eg. "OD") instead of the arrow keys (eg. "")
+ pub max_height: Option<usize>,
pending_styles: CharacterStyles,
clear_viewport_before_rendering: bool,
}
@@ -177,6 +178,12 @@ impl Pane for TerminalPane {
fn set_selectable(&mut self, selectable: bool) {
self.selectable = selectable;
}
+ fn set_max_height(&mut self, max_height: usize) {
+ self.max_height = Some(max_height);
+ }
+ fn max_height(&self) -> Option<usize> {
+ self.max_height
+ }
fn render(&mut self) -> Option<String> {
// if self.should_render {
if true {
@@ -309,6 +316,7 @@ impl TerminalPane {
position_and_size_override: None,
cursor_key_mode: false,
clear_viewport_before_rendering: false,
+ max_height: None,
}
}
pub fn mark_for_rerender(&mut self) {
diff --git a/src/screen.rs b/src/screen.rs
index 7fb19b6c..551fff65 100644
--- a/src/screen.rs
+++ b/src/screen.rs
@@ -43,6 +43,7 @@ pub enum ScreenInstruction {
CloseFocusedPane,
ToggleActiveTerminalFullscreen,
SetSelectable(PaneId, bool),
+ SetMaxHeight(PaneId, usize),
ClosePane(PaneId),
ApplyLayout((Layout, Vec<RawFd>)),
NewTab(RawFd),
diff --git a/src/tab.rs b/src/tab.rs
index fd8cfb30..190292a0 100644
--- a/src/tab.rs
+++ b/src/tab.rs
@@ -86,6 +86,7 @@ pub trait Pane {
fn set_should_render(&mut self, should_render: bool);
fn selectable(&self) -> bool;
fn set_selectable(&mut self, selectable: bool);
+ fn set_max_height(&mut self, max_height: usize);
fn render(&mut self) -> Option<String>;
fn pid(&self) -> PaneId;
fn reduce_height_down(&mut self, count: usize);
@@ -1894,6 +1895,11 @@ impl Tab {
}
}
}
+ pub fn set_pane_max_height(&mut self, id: PaneId, max_height: usize) {
+ if let Some(pane) = self.panes.get_mut(&id) {
+ pane.set_max_height(max_height);
+ }
+ }
pub fn close_pane(&mut self, id: PaneId) {
if self.panes.get(&id).is_some() {
self.close_pane_without_rerender(id);
diff --git a/src/wasm_vm.rs b/src/wasm_vm.rs
index 97a1a587..5a68f636 100644
--- a/src/wasm_vm.rs
+++ b/src/wasm_vm.rs
@@ -35,6 +35,7 @@ pub fn mosaic_imports(store: &Store, plugin_env: &PluginEnv) -> ImportObject {
imports! {
"mosaic" => {
"host_open_file" => Function::new_native_with_env(store, plugin_env.clone(), host_open_file),
+ "host_set_max_height" => Function::new_native_with_env(store, plugin_env.clone(), host_set_max_height),
"host_set_selectable" => Function::new_native_with_env(store, plugin_env.clone(), host_set_selectable),
"host_get_help" => Function::new_native_with_env(store, plugin_env.clone(), host_get_help),
}
@@ -62,6 +63,17 @@ fn host_set_selectable(plugin_env: &PluginEnv, selectable: i32) {
.unwrap()
}
+fn host_set_max_height(plugin_env: &PluginEnv, max_height: i32) {
+ let max_height = max_height as usize;
+ plugin_env
+ .send_screen_instructions
+ .send(ScreenInstruction::SetMaxHeight(
+ PaneId::Plugin(plugin_env.plugin_id),
+ max_height,
+ ))
+ .unwrap()
+}
+
fn host_get_help(plugin_env: &PluginEnv) {
let (state_tx, state_rx) = channel();
// FIXME: If I changed the application so that threads were sent the termination