Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove statusline #289

Merged
merged 3 commits into from
Dec 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ Commands start with `/` character.

- `/switch <string>`: Switch to the first tab which has the given string in the name.

- `/statusline`: Enable or disable status line on top which gives you info about
current settings of a tab.

- `/ignore`: Ignore `join/quit` messages in a channel. Running this command in
a server tab applies it to all channels of that server. You can check your
ignore state in the status line.
Expand Down
6 changes: 0 additions & 6 deletions libtiny_tui/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ pub struct Colors {
pub tab_new_msg: Style,
pub tab_highlight: Style,
pub tab_joinpart: Style,
pub statusline_normal: Style,
pub statusline_left: Style,
pub statusline_right: Style,
}

impl Default for Colors {
Expand Down Expand Up @@ -117,9 +114,6 @@ impl Default for Colors {
fg: 11,
bg: TB_DEFAULT,
},
statusline_normal: Style { fg: 15, bg: 8 },
statusline_left: Style { fg: 10, bg: 8 },
statusline_right: Style { fg: 7, bg: 8 },
}
}
}
Expand Down
1 change: 0 additions & 1 deletion libtiny_tui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ mod messaging;
#[doc(hidden)]
pub mod msg_area; // Public to be able to use in an example
mod notifier;
mod statusline;
mod tab;
mod termbox;
pub mod test_utils;
Expand Down
81 changes: 0 additions & 81 deletions libtiny_tui/src/statusline.rs

This file was deleted.

68 changes: 4 additions & 64 deletions libtiny_tui/src/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::config::{parse_config, Colors, Config, Style};
use crate::editor;
use crate::messaging::{MessagingUI, Timestamp};
use crate::notifier::Notifier;
use crate::statusline::{draw_statusline, statusline_visible};
use crate::tab::Tab;
use crate::widget::WidgetRet;

Expand Down Expand Up @@ -63,17 +62,9 @@ const NOTIFY_CMD: CmdUsage = CmdUsage::new(
"/notify [off|mentions|messages]",
);
const SWITCH_CMD: CmdUsage = CmdUsage::new("switch", "Switches to tab", "/switch <tab name>");
const STATUSLINE_CMD: CmdUsage = CmdUsage::new("statusline", "Toggles statusline", "/statusline");
const RELOAD_CMD: CmdUsage = CmdUsage::new("reload", "Reloads config file", "/reload");

const TUI_COMMANDS: [CmdUsage; 6] = [
CLEAR_CMD,
IGNORE_CMD,
NOTIFY_CMD,
SWITCH_CMD,
STATUSLINE_CMD,
RELOAD_CMD,
];
const TUI_COMMANDS: [CmdUsage; 5] = [CLEAR_CMD, IGNORE_CMD, NOTIFY_CMD, SWITCH_CMD, RELOAD_CMD];

pub struct TUI {
/// Termbox instance
Expand All @@ -91,10 +82,6 @@ pub struct TUI {
height: i32,
h_scroll: i32,

/// Do we want to show statusline?
show_statusline: bool,
/// Is there room for statusline?
statusline_visible: bool,
/// Config file path
config_path: Option<PathBuf>,
}
Expand Down Expand Up @@ -137,8 +124,6 @@ impl TUI {
width,
height,
h_scroll: 0,
show_statusline: false,
statusline_visible: statusline_visible(width, height),
config_path,
};

Expand Down Expand Up @@ -253,10 +238,6 @@ impl TUI {
}
true
}
Some("statusline") => {
self.toggle_statusline();
true
}
Some("reload") => {
self.reload_config();
true
Expand Down Expand Up @@ -346,21 +327,11 @@ impl TUI {
ret
};

let statusline_height = if self.statusline_visible && self.show_statusline {
1
} else {
0
};
self.tabs.insert(
idx,
Tab {
alias,
widget: MessagingUI::new(
self.width,
self.height - 1 - statusline_height,
status,
self.scrollback,
),
widget: MessagingUI::new(self.width, self.height - 1, status, self.scrollback),
src,
style: TabStyle::Normal,
switch,
Expand Down Expand Up @@ -710,17 +681,8 @@ impl TUI {
}

fn resize_(&mut self) {
// self.statusline_visible = statusline_visible(self.width, self.height);
let statusline_height =
if statusline_visible(self.width, self.height) && self.show_statusline {
1
} else {
0
};

for tab in &mut self.tabs {
tab.widget
.resize(self.width, self.height - 1 - statusline_height);
tab.widget.resize(self.width, self.height - 1);
}
// scroll the tab bar so that currently active tab is still visible
let (mut tab_left, mut tab_right) = self.rendered_tabs();
Expand Down Expand Up @@ -866,26 +828,9 @@ impl TUI {
return;
}

let statusline_height = if self.statusline_visible && self.show_statusline {
1
} else {
0
};

if self.show_statusline && self.statusline_visible {
draw_statusline(
&mut self.tb,
self.width,
&self.colors,
&self.tabs[self.active_idx].visible_name(),
self.tabs[self.active_idx].notifier,
self.tabs[self.active_idx].widget.is_showing_status(),
);
}

self.tabs[self.active_idx]
.widget
.draw(&mut self.tb, &self.colors, 0, statusline_height);
.draw(&mut self.tb, &self.colors, 0, 0);

// decide whether we need to draw left/right arrows in tab bar
let left_arr = self.draw_left_arrow();
Expand Down Expand Up @@ -1340,11 +1285,6 @@ impl TUI {
self.apply_to_target(target, &|tab: &mut Tab, _| tab.widget.clear());
}

pub(crate) fn toggle_statusline(&mut self) {
self.show_statusline = !self.show_statusline;
self.resize();
}

pub(crate) fn toggle_ignore(&mut self, target: &MsgTarget) {
if let MsgTarget::AllServTabs { serv } = *target {
let mut status_val: bool = false;
Expand Down