Skip to content

Commit

Permalink
Remove statusline (#289)
Browse files Browse the repository at this point in the history
For v1.0 I want to make sure every existing feature is justified (being
used) and have all the necessary features (e.g. config field fields).

I think status line is one of the features that no one uses, because
it's currently painful to use. You need to enable it manually every time
you run tiny because we never implemented the config file fields. Also,
I think it's not too useful. It shows three things:

- Channel name
- /ignore status
- /notify status

First one is already shown in the TUI always, no need to show it again.
(2) and (3) can be seen by running the commands and I'm not sure if
they're important enough to show always.

(I think a more helpful status line would show: channel status and
topic, maybe number of nicks in the channel)

Instead of finishing a feature that no one uses I think it makes more
sense to just remove it. No need to maintain dead code.
  • Loading branch information
osa1 authored Dec 26, 2020
1 parent 0144a84 commit 6abc671
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 155 deletions.
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

0 comments on commit 6abc671

Please sign in to comment.