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
|
date_shown = true
|
||||||
# The format of the date and time outputs. Formats can be found at https://strftime.org/.
|
# The format of the date and time outputs. Formats can be found at https://strftime.org/.
|
||||||
date_format = "%a %b %e %T %Y"
|
date_format = "%a %b %e %T %Y"
|
||||||
# The longest a username can be.
|
# If the username should be shown.
|
||||||
maximum_username_length = 26
|
username_shown = true
|
||||||
# Which side the username should be aligned to.
|
|
||||||
username_alignment = "right"
|
|
||||||
# The color palette for the username column: pastel (default), vibrant, warm, cool.
|
# The color palette for the username column: pastel (default), vibrant, warm, cool.
|
||||||
palette = "pastel"
|
palette = "pastel"
|
||||||
# Show title with time and channel.
|
# Show title with time and channel.
|
||||||
|
@ -43,6 +43,7 @@ pub fn init_terminal(frontend_config: &FrontendConfig) -> Terminal<CrosstermBack
|
|||||||
CursorType::Line => SetCursorStyle::BlinkingBar,
|
CursorType::Line => SetCursorStyle::BlinkingBar,
|
||||||
CursorType::Block => SetCursorStyle::BlinkingBlock,
|
CursorType::Block => SetCursorStyle::BlinkingBlock,
|
||||||
CursorType::UnderScore => SetCursorStyle::BlinkingUnderScore,
|
CursorType::UnderScore => SetCursorStyle::BlinkingUnderScore,
|
||||||
|
CursorType::User => SetCursorStyle::DefaultUserShape,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut stdout = stdout();
|
let mut stdout = stdout();
|
||||||
|
@ -78,9 +78,6 @@ pub struct Cli {
|
|||||||
/// Show the date/time
|
/// Show the date/time
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
pub date_shown: bool,
|
pub date_shown: bool,
|
||||||
/// Maximum length for Twitch usernames
|
|
||||||
#[arg(short = 'u', long)]
|
|
||||||
pub max_username_length: Option<u16>,
|
|
||||||
/// Username color palette
|
/// Username color palette
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
pub palette: Option<Palette>,
|
pub palette: Option<Palette>,
|
||||||
@ -121,9 +118,6 @@ pub fn merge_args_into_config(config: &mut CompleteConfig, args: Cli) {
|
|||||||
// Frontend arguments
|
// Frontend arguments
|
||||||
config.frontend.date_shown = config.frontend.date_shown || args.date_shown;
|
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 {
|
if let Some(palette) = args.palette {
|
||||||
config.frontend.palette = palette;
|
config.frontend.palette = palette;
|
||||||
}
|
}
|
||||||
|
@ -89,8 +89,8 @@ pub struct FrontendConfig {
|
|||||||
pub date_shown: bool,
|
pub date_shown: bool,
|
||||||
/// The format of string that will show up in the terminal.
|
/// The format of string that will show up in the terminal.
|
||||||
pub date_format: String,
|
pub date_format: String,
|
||||||
/// The maximum length of a Twitch username.
|
/// If the username should be shown.
|
||||||
pub maximum_username_length: u16,
|
pub username_shown: bool,
|
||||||
/// The color palette.
|
/// The color palette.
|
||||||
pub palette: Palette,
|
pub palette: Palette,
|
||||||
/// Show Title with time and channel.
|
/// Show Title with time and channel.
|
||||||
@ -141,7 +141,7 @@ impl Default for FrontendConfig {
|
|||||||
Self {
|
Self {
|
||||||
date_shown: true,
|
date_shown: true,
|
||||||
date_format: "%a %b %e %T %Y".to_string(),
|
date_format: "%a %b %e %T %Y".to_string(),
|
||||||
maximum_username_length: 26,
|
username_shown: true,
|
||||||
palette: Palette::default(),
|
palette: Palette::default(),
|
||||||
title_shown: true,
|
title_shown: true,
|
||||||
margin: 0,
|
margin: 0,
|
||||||
|
@ -74,8 +74,8 @@ impl MessageData {
|
|||||||
) -> Vec<String> {
|
) -> Vec<String> {
|
||||||
let width_sub_margin = width - (frontend_config.margin as usize * 2);
|
let width_sub_margin = width - (frontend_config.margin as usize * 2);
|
||||||
|
|
||||||
// Subtraction of 2 for the spaces in between the date, user, and message.
|
// 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() - 2;
|
let first_line_limit = width_sub_margin - time_sent.len() - self.author.len() - 3;
|
||||||
|
|
||||||
let mut message_split = textwrap::wrap(
|
let mut message_split = textwrap::wrap(
|
||||||
&self.payload,
|
&self.payload,
|
||||||
@ -158,18 +158,20 @@ impl MessageData {
|
|||||||
vec![]
|
vec![]
|
||||||
};
|
};
|
||||||
|
|
||||||
info.extend(vec![
|
if frontend_config.username_shown {
|
||||||
Span::styled(
|
info.extend(vec![
|
||||||
self.author.clone(),
|
Span::styled(
|
||||||
if self.system {
|
self.author.clone(),
|
||||||
SYSTEM_CHAT
|
if self.system {
|
||||||
} else {
|
SYSTEM_CHAT
|
||||||
Style::default().fg(self.hash_username(&frontend_config.palette))
|
} else {
|
||||||
},
|
Style::default().fg(self.hash_username(&frontend_config.palette))
|
||||||
),
|
},
|
||||||
Span::raw(" "),
|
),
|
||||||
message_spans[0].clone(),
|
Span::raw(": "),
|
||||||
]);
|
message_spans[0].clone(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
let mut info_spans = vec![Spans::from(info)];
|
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();
|
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()
|
let h_chunk = Layout::default()
|
||||||
.direction(Direction::Horizontal)
|
.direction(Direction::Horizontal)
|
||||||
.constraints([Constraint::Min(1)])
|
.constraints([Constraint::Min(1)])
|
||||||
|
Loading…
Reference in New Issue
Block a user