Skip to content

Commit

Permalink
Merge pull request #232 from SamStrongTalks/add-color-nick-list
Browse files Browse the repository at this point in the history
Add nick coloring to nick_list
  • Loading branch information
casperstorm authored Feb 20, 2024
2 parents f0336eb + 2388158 commit 9bc18ca
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
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

0 comments on commit 9bc18ca

Please sign in to comment.