Skip to content

Commit

Permalink
Highlights in query buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
englut committed Dec 17, 2024
1 parent 3d97d05 commit 903df07
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
1 change: 1 addition & 0 deletions data/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ impl Client {
}

fn send(&mut self, buffer: &buffer::Upstream, mut message: message::Encoded) {
log::trace!("Message sent => {:?}", *message);
if self.supports_labels {
use proto::Tag;

Expand Down
15 changes: 7 additions & 8 deletions src/buffer/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,14 @@ pub fn view<'a>(
.push(nick)
.push(space);

let text_container =
container(message_content).style(move |theme| match our_nick {
Some(nick)
if message::references_user(user.nickname(), nick, message) =>
{
theme::container::highlight(theme)
let text_container = container(message_content).style(move |theme| {
if let Some(nick) = our_nick {
if message::references_user(user.nickname(), nick, message) {
return theme::container::highlight(theme);
}
_ => Default::default(),
});
}
Default::default()
});

match &config.buffer.nickname.alignment {
data::buffer::Alignment::Left | data::buffer::Alignment::Right => Some(
Expand Down
31 changes: 25 additions & 6 deletions src/buffer/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub fn view<'a>(
let status = clients.status(server);
let buffer = &state.buffer;
let input = history.input(buffer);
let our_nick = clients.nickname(&state.server);

let chathistory_state = clients.get_chathistory_state(server, state.nick.as_ref());

Expand Down Expand Up @@ -74,7 +75,7 @@ pub fn view<'a>(
let nick = user_context::view(text, server, None, user, None, None)
.map(scroll_view::Message::UserContext);

let message = message_content::with_context(
let message_content = message_content::with_context(
&message.content,
theme,
scroll_view::Message::Link,
Expand All @@ -95,12 +96,21 @@ pub fn view<'a>(
let timestamp_nickname_row =
row![].push_maybe(timestamp).push(nick).push(space);

let text_container = container(message_content).style(move |theme| {
if let Some(nick) = our_nick {
if message::references_user(user.nickname(), nick, message) {
return theme::container::highlight(theme);
}
}
Default::default()
});

match &config.buffer.nickname.alignment {
data::buffer::Alignment::Left | data::buffer::Alignment::Right => {
Some(row![].push(timestamp_nickname_row).push(message).into())
Some(row![].push(timestamp_nickname_row).push(text_container).into())
}
data::buffer::Alignment::Top => {
Some(column![].push(timestamp_nickname_row).push(message).into())
Some(column![].push(timestamp_nickname_row).push(text_container).into())
}
}
}
Expand Down Expand Up @@ -130,24 +140,33 @@ pub fn view<'a>(
.into(),
)
}
message::Source::Action(_) => {
message::Source::Action(user) => {
let marker = message_marker(max_nick_width, theme::selectable_text::action);

let message = message_content(
let message_content = message_content(
&message.content,
theme,
scroll_view::Message::Link,
theme::selectable_text::action,
config,
);

let text_container = container(message_content).style(move |theme| {
if let (Some(user), Some(nick)) = (user, our_nick) {
if message::references_user(user.nickname(), nick, message) {
return theme::container::highlight(theme);
}
}
Default::default()
});

Some(
container(
row![]
.push_maybe(timestamp)
.push(marker)
.push(space)
.push(message),
.push(text_container),
)
.into(),
)
Expand Down

0 comments on commit 903df07

Please sign in to comment.