feat(statusbar): max status bar height (#156)
This commit is contained in:
parent
5191dfe416
commit
dd56deb2d2
8 changed files with 43 additions and 0 deletions
Binary file not shown.
|
|
@ -167,6 +167,7 @@ pub enum ScreenContext {
|
||||||
CloseFocusedPane,
|
CloseFocusedPane,
|
||||||
ToggleActiveTerminalFullscreen,
|
ToggleActiveTerminalFullscreen,
|
||||||
SetSelectable,
|
SetSelectable,
|
||||||
|
SetMaxHeight,
|
||||||
ClosePane,
|
ClosePane,
|
||||||
ApplyLayout,
|
ApplyLayout,
|
||||||
NewTab,
|
NewTab,
|
||||||
|
|
@ -202,6 +203,7 @@ impl From<&ScreenInstruction> for ScreenContext {
|
||||||
ScreenContext::ToggleActiveTerminalFullscreen
|
ScreenContext::ToggleActiveTerminalFullscreen
|
||||||
}
|
}
|
||||||
ScreenInstruction::SetSelectable(..) => ScreenContext::SetSelectable,
|
ScreenInstruction::SetSelectable(..) => ScreenContext::SetSelectable,
|
||||||
|
ScreenInstruction::SetMaxHeight(..) => ScreenContext::SetMaxHeight,
|
||||||
ScreenInstruction::ClosePane(_) => ScreenContext::ClosePane,
|
ScreenInstruction::ClosePane(_) => ScreenContext::ClosePane,
|
||||||
ScreenInstruction::ApplyLayout(_) => ScreenContext::ApplyLayout,
|
ScreenInstruction::ApplyLayout(_) => ScreenContext::ApplyLayout,
|
||||||
ScreenInstruction::NewTab(_) => ScreenContext::NewTab,
|
ScreenInstruction::NewTab(_) => ScreenContext::NewTab,
|
||||||
|
|
|
||||||
|
|
@ -406,6 +406,12 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
||||||
// FIXME: Is this needed?
|
// FIXME: Is this needed?
|
||||||
screen.render();
|
screen.render();
|
||||||
}
|
}
|
||||||
|
ScreenInstruction::SetMaxHeight(id, max_height) => {
|
||||||
|
screen
|
||||||
|
.get_active_tab_mut()
|
||||||
|
.unwrap()
|
||||||
|
.set_pane_max_height(id, max_height);
|
||||||
|
}
|
||||||
ScreenInstruction::ClosePane(id) => {
|
ScreenInstruction::ClosePane(id) => {
|
||||||
screen.get_active_tab_mut().unwrap().close_pane(id);
|
screen.get_active_tab_mut().unwrap().close_pane(id);
|
||||||
screen.render();
|
screen.render();
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ pub struct PluginPane {
|
||||||
pub position_and_size: PositionAndSize,
|
pub position_and_size: PositionAndSize,
|
||||||
pub position_and_size_override: Option<PositionAndSize>,
|
pub position_and_size_override: Option<PositionAndSize>,
|
||||||
pub send_plugin_instructions: SenderWithContext<PluginInstruction>,
|
pub send_plugin_instructions: SenderWithContext<PluginInstruction>,
|
||||||
|
pub max_height: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PluginPane {
|
impl PluginPane {
|
||||||
|
|
@ -28,6 +29,7 @@ impl PluginPane {
|
||||||
position_and_size,
|
position_and_size,
|
||||||
position_and_size_override: None,
|
position_and_size_override: None,
|
||||||
send_plugin_instructions,
|
send_plugin_instructions,
|
||||||
|
max_height: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -100,6 +102,9 @@ impl Pane for PluginPane {
|
||||||
fn set_selectable(&mut self, selectable: bool) {
|
fn set_selectable(&mut self, selectable: bool) {
|
||||||
self.selectable = selectable;
|
self.selectable = selectable;
|
||||||
}
|
}
|
||||||
|
fn set_max_height(&mut self, max_height: usize) {
|
||||||
|
self.max_height = Some(max_height);
|
||||||
|
}
|
||||||
fn render(&mut self) -> Option<String> {
|
fn render(&mut self) -> Option<String> {
|
||||||
// if self.should_render {
|
// if self.should_render {
|
||||||
if true {
|
if true {
|
||||||
|
|
@ -172,4 +177,7 @@ impl Pane for PluginPane {
|
||||||
fn clear_scroll(&mut self) {
|
fn clear_scroll(&mut self) {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
fn max_height(&self) -> Option<usize> {
|
||||||
|
self.max_height
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ pub struct TerminalPane {
|
||||||
pub position_and_size: PositionAndSize,
|
pub position_and_size: PositionAndSize,
|
||||||
pub position_and_size_override: Option<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. "[D")
|
pub cursor_key_mode: bool, // DECCKM - when set, cursor keys should send ANSI direction codes (eg. "OD") instead of the arrow keys (eg. "[D")
|
||||||
|
pub max_height: Option<usize>,
|
||||||
pending_styles: CharacterStyles,
|
pending_styles: CharacterStyles,
|
||||||
clear_viewport_before_rendering: bool,
|
clear_viewport_before_rendering: bool,
|
||||||
}
|
}
|
||||||
|
|
@ -177,6 +178,12 @@ impl Pane for TerminalPane {
|
||||||
fn set_selectable(&mut self, selectable: bool) {
|
fn set_selectable(&mut self, selectable: bool) {
|
||||||
self.selectable = selectable;
|
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> {
|
fn render(&mut self) -> Option<String> {
|
||||||
// if self.should_render {
|
// if self.should_render {
|
||||||
if true {
|
if true {
|
||||||
|
|
@ -309,6 +316,7 @@ impl TerminalPane {
|
||||||
position_and_size_override: None,
|
position_and_size_override: None,
|
||||||
cursor_key_mode: false,
|
cursor_key_mode: false,
|
||||||
clear_viewport_before_rendering: false,
|
clear_viewport_before_rendering: false,
|
||||||
|
max_height: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn mark_for_rerender(&mut self) {
|
pub fn mark_for_rerender(&mut self) {
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ pub enum ScreenInstruction {
|
||||||
CloseFocusedPane,
|
CloseFocusedPane,
|
||||||
ToggleActiveTerminalFullscreen,
|
ToggleActiveTerminalFullscreen,
|
||||||
SetSelectable(PaneId, bool),
|
SetSelectable(PaneId, bool),
|
||||||
|
SetMaxHeight(PaneId, usize),
|
||||||
ClosePane(PaneId),
|
ClosePane(PaneId),
|
||||||
ApplyLayout((Layout, Vec<RawFd>)),
|
ApplyLayout((Layout, Vec<RawFd>)),
|
||||||
NewTab(RawFd),
|
NewTab(RawFd),
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@ pub trait Pane {
|
||||||
fn set_should_render(&mut self, should_render: bool);
|
fn set_should_render(&mut self, should_render: bool);
|
||||||
fn selectable(&self) -> bool;
|
fn selectable(&self) -> bool;
|
||||||
fn set_selectable(&mut self, selectable: bool);
|
fn set_selectable(&mut self, selectable: bool);
|
||||||
|
fn set_max_height(&mut self, max_height: usize);
|
||||||
fn render(&mut self) -> Option<String>;
|
fn render(&mut self) -> Option<String>;
|
||||||
fn pid(&self) -> PaneId;
|
fn pid(&self) -> PaneId;
|
||||||
fn reduce_height_down(&mut self, count: usize);
|
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) {
|
pub fn close_pane(&mut self, id: PaneId) {
|
||||||
if self.panes.get(&id).is_some() {
|
if self.panes.get(&id).is_some() {
|
||||||
self.close_pane_without_rerender(id);
|
self.close_pane_without_rerender(id);
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ pub fn mosaic_imports(store: &Store, plugin_env: &PluginEnv) -> ImportObject {
|
||||||
imports! {
|
imports! {
|
||||||
"mosaic" => {
|
"mosaic" => {
|
||||||
"host_open_file" => Function::new_native_with_env(store, plugin_env.clone(), host_open_file),
|
"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_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),
|
"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()
|
.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) {
|
fn host_get_help(plugin_env: &PluginEnv) {
|
||||||
let (state_tx, state_rx) = channel();
|
let (state_tx, state_rx) = channel();
|
||||||
// FIXME: If I changed the application so that threads were sent the termination
|
// FIXME: If I changed the application so that threads were sent the termination
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue