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

Add nick coloring to nick_list #232

Merged
merged 3 commits into from
Feb 20, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Unreleased

Added:

- Option to colorize nicks in the nick list (and an option to control it separately from in the buffer)

Fixed:

- Input not visible on Server and Query (DM) buffers
Expand Down
5 changes: 5 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ buffer:
# - Left: Left side of pane
# - Right: Right side of pane [default]
position: Right
# User list color settings:
# - Unique: Unique user colors [default]
# - Solid: Solid user colors
color: Unique


# Dashboard settings
dashboard:
Expand Down
2 changes: 1 addition & 1 deletion data/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl Brackets {
}
}

#[derive(Debug, Clone, Default, Deserialize)]
#[derive(Debug, Clone, Copy, Default, Deserialize)]
pub enum Color {
Solid,
#[default]
Expand Down
4 changes: 4 additions & 0 deletions data/src/config/channel.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use serde::Deserialize;

use crate::buffer::Color;
use crate::channel::Position;

#[derive(Debug, Clone, Default, Deserialize)]
Expand All @@ -11,13 +12,16 @@ pub struct Users {
pub(crate) visible: bool,
#[serde(default)]
pub position: Position,
#[serde(default)]
pub color: Color,
}

impl Default for Users {
fn default() -> Self {
Self {
visible: true,
position: Position::default(),
color: Color::default(),
}
}
}
10 changes: 6 additions & 4 deletions src/buffer/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub fn view<'a>(

let users = clients.get_channel_users(&state.server, &state.channel);
let channels = clients.get_channels(&state.server);
let nick_list = nick_list::view(users).map(Message::UserContext);
let nick_list = nick_list::view(users, config).map(Message::UserContext);

let show_text_input = match config.buffer.input_visibility {
data::buffer::InputVisibility::Focused => is_focused && status.connected(),
Expand Down Expand Up @@ -218,7 +218,7 @@ impl Channel {
}

mod nick_list {
use data::User;
use data::{User, Config};
use iced::widget::{column, container, scrollable, text};
use iced::Length;
use user_context::Message;
Expand All @@ -227,7 +227,7 @@ mod nick_list {
use crate::theme;
use crate::widget::Element;

pub fn view(users: &[User]) -> Element<Message> {
pub fn view<'a>(users: &[User], config: &'a Config) -> Element<'a,Message> {
let column = column(users.iter().map(|user| {
let content = text(format!(
"{}{}",
Expand All @@ -237,7 +237,9 @@ mod nick_list {
.style(if user.is_away() {
theme::Text::Transparent
} else {
theme::Text::Primary
theme::Text::Nickname(
user.color_seed(&config.buffer.channel.users.color)
)
});

user_context::view(content, user.clone())
Expand Down
Loading