mirror of
https://github.com/Xithrius/twitch-tui.git
synced 2024-10-04 09:07:33 +03:00
Corrected config defaults, added scroll offset indicator
This commit is contained in:
parent
fa6953aec7
commit
acf684f5c4
@ -20,9 +20,9 @@ start_state = "dashboard"
|
||||
|
||||
[storage]
|
||||
# If previous channels switched to should be tracked.
|
||||
channels = true
|
||||
channels = false
|
||||
# If previous username mentions should be tracked.
|
||||
mentions = true
|
||||
mentions = false
|
||||
|
||||
[filters]
|
||||
# If filters should be enabled at all.
|
||||
@ -57,6 +57,8 @@ cursor_shape = "block"
|
||||
blinking_cursor = false
|
||||
# If the scrolling should be inverted.
|
||||
inverted_scrolling = false
|
||||
# If scroll offset should be shown (bottom right of chat window).
|
||||
show_scroll_offset = false
|
||||
# Show twitch emotes.
|
||||
twitch_emotes = false
|
||||
# Show betterttv emotes.
|
||||
|
@ -114,6 +114,8 @@ pub struct FrontendConfig {
|
||||
pub blinking_cursor: bool,
|
||||
/// If the scrolling should be inverted.
|
||||
pub inverted_scrolling: bool,
|
||||
/// If scroll offset integer should be shown.
|
||||
pub show_scroll_offset: bool,
|
||||
/// If twitch emotes should be displayed (requires kitty terminal).
|
||||
pub twitch_emotes: bool,
|
||||
/// If betterttv emotes should be displayed (requires kitty terminal).
|
||||
@ -167,6 +169,7 @@ impl Default for FrontendConfig {
|
||||
cursor_shape: CursorType::default(),
|
||||
blinking_cursor: false,
|
||||
inverted_scrolling: false,
|
||||
show_scroll_offset: false,
|
||||
twitch_emotes: false,
|
||||
betterttv_emotes: false,
|
||||
seventv_emotes: false,
|
||||
|
@ -13,7 +13,7 @@ impl Scrolling {
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn inverted(&self) -> bool {
|
||||
pub const fn is_inverted(&self) -> bool {
|
||||
self.inverted
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ use chrono::Local;
|
||||
use log::warn;
|
||||
use tui::{
|
||||
backend::Backend,
|
||||
layout::{Constraint, Direction, Layout, Rect},
|
||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||
style::{Color, Modifier, Style},
|
||||
text::{Line, Span, Text},
|
||||
widgets::{Block, Borders, List, ListItem},
|
||||
@ -278,7 +278,7 @@ impl Component for ChatWidget {
|
||||
final_messages.push(ListItem::new(Text::from(item)));
|
||||
}
|
||||
|
||||
let list = List::new(final_messages)
|
||||
let list = List::new(&*final_messages)
|
||||
.block(
|
||||
Block::default()
|
||||
.borders(Borders::ALL)
|
||||
@ -292,6 +292,35 @@ impl Component for ChatWidget {
|
||||
|
||||
f.render_widget(list, *first_v_chunk);
|
||||
|
||||
if self.config.borrow().frontend.show_scroll_offset {
|
||||
// Cannot scroll past the first message
|
||||
let message_amount = messages_data.len().saturating_sub(1);
|
||||
|
||||
let title_binding = format!(
|
||||
"{} / {}",
|
||||
self.scroll_offset.get_offset(),
|
||||
message_amount.to_string().as_str()
|
||||
);
|
||||
|
||||
let title = [TitleStyle::Single(&title_binding)];
|
||||
|
||||
let bottom_block = Block::default()
|
||||
.borders(Borders::BOTTOM | Borders::LEFT | Borders::RIGHT)
|
||||
.border_type(self.config.borrow().frontend.border_type.clone().into())
|
||||
.title(title_line(&title, Style::default()))
|
||||
.title_on_bottom()
|
||||
.title_alignment(Alignment::Right);
|
||||
|
||||
let rect = Rect::new(
|
||||
first_v_chunk.x,
|
||||
first_v_chunk.bottom() - 1,
|
||||
first_v_chunk.width,
|
||||
1,
|
||||
);
|
||||
|
||||
f.render_widget(bottom_block, rect);
|
||||
}
|
||||
|
||||
if self.chat_input.is_focused() {
|
||||
self.chat_input
|
||||
.draw(f, v_chunks.next().copied().unwrap(), Some(emotes));
|
||||
@ -336,12 +365,12 @@ impl Component for ChatWidget {
|
||||
Key::ScrollUp => {
|
||||
if limit {
|
||||
self.scroll_offset.up();
|
||||
} else if self.scroll_offset.inverted() {
|
||||
} else if self.scroll_offset.is_inverted() {
|
||||
self.scroll_offset.down();
|
||||
}
|
||||
}
|
||||
Key::ScrollDown => {
|
||||
if self.scroll_offset.inverted() {
|
||||
if self.scroll_offset.is_inverted() {
|
||||
if limit {
|
||||
self.scroll_offset.up();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user