Repository: osa1/tiny (language: rust)

Issue:
Highlight channels with join/part/quit events
Currently we have 3 colors/styles for showing a channel name in the tab bar:

- (1) Normal: a faded white/grey
- (2) NewMsg: a pink-ish color, used when a channel gets new messages
- (3) Highlight: bold red, used when a channel has a mention to the user

These are listed form the lowest priority to highest. For example if a channel is shown as (2) and a new message to the user is sent we show it as (3). After that new messages don't turn it back to (2). We reset the state to (1) when the channel gets focus.

I suggest we insert this for (2) and shift (2) and (3):

- (2) JoinOrLeave: yellow, used when channel has join/part/quit activity.


Discussion / hints:

Fix patch:
diff --git a/libtiny_tui/src/config.rs b/libtiny_tui/src/config.rs
index fb52f5da..9a6ecb23 100644
--- a/libtiny_tui/src/config.rs
+++ b/libtiny_tui/src/config.rs
@@ -47,6 +47,7 @@ pub struct Colors {
     pub tab_normal: Style,
     pub tab_new_msg: Style,
     pub tab_highlight: Style,
+    pub tab_joinpart: Style,
     pub statusline_normal: Style,
     pub statusline_left: Style,
     pub statusline_right: Style,
@@ -112,6 +113,10 @@ impl Default for Colors {
                 fg: 9 | TB_BOLD,
                 bg: 0,
             },
+            tab_joinpart: Style {
+                fg: 11,
+                bg: TB_DEFAULT,
+            },
             statusline_normal: Style { fg: 15, bg: 8 },
             statusline_left: Style { fg: 10, bg: 8 },
             statusline_right: Style { fg: 7, bg: 8 },
diff --git a/libtiny_tui/src/tab.rs b/libtiny_tui/src/tab.rs
index f4e179bf..00d3fde9 100644
--- a/libtiny_tui/src/tab.rs
+++ b/libtiny_tui/src/tab.rs
@@ -23,6 +23,7 @@ pub(crate) struct Tab {
 fn tab_style(style: TabStyle, colors: &Colors) -> Style {
     match style {
         TabStyle::Normal => colors.tab_normal,
+        TabStyle::JoinOrPart => colors.tab_joinpart,
         TabStyle::NewMsg => colors.tab_new_msg,
         TabStyle::Highlight => colors.tab_highlight,
     }
diff --git a/libtiny_tui/src/tui.rs b/libtiny_tui/src/tui.rs
index d58e100a..2635a48f 100644
--- a/libtiny_tui/src/tui.rs
+++ b/libtiny_tui/src/tui.rs
@@ -755,6 +755,7 @@ fn arrow_style(tabs: &[Tab], colors: &Colors) -> Style {
         .unwrap_or(TabStyle::Normal);
     match tab_style {
         TabStyle::Normal => colors.tab_normal,
+        TabStyle::JoinOrPart => colors.tab_joinpart,
         TabStyle::NewMsg => colors.tab_new_msg,
         TabStyle::Highlight => colors.tab_highlight,
     }
diff --git a/libtiny_ui/src/lib.rs b/libtiny_ui/src/lib.rs
index 89b71095..bc2b1b90 100644
--- a/libtiny_ui/src/lib.rs
+++ b/libtiny_ui/src/lib.rs
@@ -76,6 +76,7 @@ impl MsgSource {
 #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
 pub enum TabStyle {
     Normal,
+    JoinOrPart,
     NewMsg,
     Highlight,
 }
diff --git a/tiny/src/conn.rs b/tiny/src/conn.rs
index afbbfedc..5cc9f960 100644
--- a/tiny/src/conn.rs
+++ b/tiny/src/conn.rs
@@ -239,6 +239,7 @@ fn handle_irc_msg(ui: &dyn UI, client: &Client, msg: wire::Msg) {
                 if ui.user_tab_exists(serv, nick) {
                     ui.add_nick(nick, ts, &MsgTarget::User { serv, nick });
                 }
+                ui.set_tab_style(TabStyle::JoinOrPart, &MsgTarget::Chan { serv, chan: &chan })
             }
         }
 
@@ -260,6 +261,7 @@ fn handle_irc_msg(ui: &dyn UI, client: &Client, msg: wire::Msg) {
                     Some(time::now()),
                     &MsgTarget::Chan { serv, chan: &chan },
                 );
+                ui.set_tab_style(TabStyle::JoinOrPart, &MsgTarget::Chan { serv, chan: &chan })
             }
         }
 


Test patch: