mirror of
https://github.com/Xithrius/twitch-tui.git
synced 2024-09-11 05:35:26 +03:00
Added possibility of usernames getting disabled, #301
This commit is contained in:
parent
fa8bd6bd69
commit
f3d5956cb2
@ -35,10 +35,8 @@ reversed = false
|
||||
date_shown = true
|
||||
# The format of the date and time outputs. Formats can be found at https://strftime.org/.
|
||||
date_format = "%a %b %e %T %Y"
|
||||
# The longest a username can be.
|
||||
maximum_username_length = 26
|
||||
# Which side the username should be aligned to.
|
||||
username_alignment = "right"
|
||||
# If the username should be shown.
|
||||
username_shown = true
|
||||
# The color palette for the username column: pastel (default), vibrant, warm, cool.
|
||||
palette = "pastel"
|
||||
# Show title with time and channel.
|
||||
|
@ -43,6 +43,7 @@ pub fn init_terminal(frontend_config: &FrontendConfig) -> Terminal<CrosstermBack
|
||||
CursorType::Line => SetCursorStyle::BlinkingBar,
|
||||
CursorType::Block => SetCursorStyle::BlinkingBlock,
|
||||
CursorType::UnderScore => SetCursorStyle::BlinkingUnderScore,
|
||||
CursorType::User => SetCursorStyle::DefaultUserShape,
|
||||
};
|
||||
|
||||
let mut stdout = stdout();
|
||||
|
@ -78,9 +78,6 @@ pub struct Cli {
|
||||
/// Show the date/time
|
||||
#[arg(short, long)]
|
||||
pub date_shown: bool,
|
||||
/// Maximum length for Twitch usernames
|
||||
#[arg(short = 'u', long)]
|
||||
pub max_username_length: Option<u16>,
|
||||
/// Username color palette
|
||||
#[arg(short, long)]
|
||||
pub palette: Option<Palette>,
|
||||
@ -121,9 +118,6 @@ pub fn merge_args_into_config(config: &mut CompleteConfig, args: Cli) {
|
||||
// Frontend arguments
|
||||
config.frontend.date_shown = config.frontend.date_shown || args.date_shown;
|
||||
|
||||
if let Some(maximum_username_length) = args.max_username_length {
|
||||
config.frontend.maximum_username_length = maximum_username_length;
|
||||
}
|
||||
if let Some(palette) = args.palette {
|
||||
config.frontend.palette = palette;
|
||||
}
|
||||
|
@ -89,8 +89,8 @@ pub struct FrontendConfig {
|
||||
pub date_shown: bool,
|
||||
/// The format of string that will show up in the terminal.
|
||||
pub date_format: String,
|
||||
/// The maximum length of a Twitch username.
|
||||
pub maximum_username_length: u16,
|
||||
/// If the username should be shown.
|
||||
pub username_shown: bool,
|
||||
/// The color palette.
|
||||
pub palette: Palette,
|
||||
/// Show Title with time and channel.
|
||||
@ -141,7 +141,7 @@ impl Default for FrontendConfig {
|
||||
Self {
|
||||
date_shown: true,
|
||||
date_format: "%a %b %e %T %Y".to_string(),
|
||||
maximum_username_length: 26,
|
||||
username_shown: true,
|
||||
palette: Palette::default(),
|
||||
title_shown: true,
|
||||
margin: 0,
|
||||
|
@ -74,8 +74,8 @@ impl MessageData {
|
||||
) -> Vec<String> {
|
||||
let width_sub_margin = width - (frontend_config.margin as usize * 2);
|
||||
|
||||
// Subtraction of 2 for the spaces in between the date, user, and message.
|
||||
let first_line_limit = width_sub_margin - time_sent.len() - self.author.len() - 2;
|
||||
// Subtraction of 2 for the spaces and ':' in between the date, user, and message.
|
||||
let first_line_limit = width_sub_margin - time_sent.len() - self.author.len() - 3;
|
||||
|
||||
let mut message_split = textwrap::wrap(
|
||||
&self.payload,
|
||||
@ -158,18 +158,20 @@ impl MessageData {
|
||||
vec![]
|
||||
};
|
||||
|
||||
info.extend(vec![
|
||||
Span::styled(
|
||||
self.author.clone(),
|
||||
if self.system {
|
||||
SYSTEM_CHAT
|
||||
} else {
|
||||
Style::default().fg(self.hash_username(&frontend_config.palette))
|
||||
},
|
||||
),
|
||||
Span::raw(" "),
|
||||
message_spans[0].clone(),
|
||||
]);
|
||||
if frontend_config.username_shown {
|
||||
info.extend(vec![
|
||||
Span::styled(
|
||||
self.author.clone(),
|
||||
if self.system {
|
||||
SYSTEM_CHAT
|
||||
} else {
|
||||
Style::default().fg(self.hash_username(&frontend_config.palette))
|
||||
},
|
||||
),
|
||||
Span::raw(": "),
|
||||
message_spans[0].clone(),
|
||||
]);
|
||||
}
|
||||
|
||||
let mut info_spans = vec![Spans::from(info)];
|
||||
|
||||
|
@ -105,7 +105,7 @@ pub fn draw_ui<T: Backend>(frame: &mut Frame<T>, app: &mut App, config: &Complet
|
||||
|
||||
let mut scroll_offset = app.scrolling.get_offset();
|
||||
|
||||
// Horizontal chunks represents the table within the main chat window.
|
||||
// Horizontal chunks represents the list within the main chat window.
|
||||
let h_chunk = Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
.constraints([Constraint::Min(1)])
|
||||
|
Loading…
Reference in New Issue
Block a user