squidowl / halloy

IRC application written in Rust
GNU General Public License v3.0
1.66k stars 63 forks source link

[feature request] username completion with @ #645

Open voidlily opened 2 days ago

voidlily commented 2 days ago

I'd like to be able to complete usernames with @ because that's a pretty common thing on a lot of other forms of communication. For example, typing @userna<tab> would complete to something like @username:, preserving the @ sign.

I tried to implement this myself but my Rust skills are not very good so I wasn't able to get very far with it.

voidlily commented 2 days ago
modified   src/buffer/input_view/completion.rs
@@ -600,13 +600,17 @@ impl Text {
     }

     fn process_users(&mut self, input: &str, users: &[User]) {
-        let (_, rest) = input.rsplit_once(' ').unwrap_or(("", input));
+        let (_, mut rest) = input.rsplit_once(' ').unwrap_or(("", input));

         if rest.is_empty() {
             *self = Self::default();
             return;
         }

+        if let Some((_, last)) = rest.split_once('@') {
+            rest = last;
+        }
+
         let nick = rest.to_lowercase();

         self.selected = None;

This is about as far as I was able to get with it with my limited Rust skills, but tab completing with @userna<tab> results in username:, stripping the @.

casperstorm commented 1 day ago

I am not a fan of this, as it is not very irc idiomatic to highlight users with a @. I am curious if @glguy, @4e554c4c or @andymandias has to say about this.

4e554c4c commented 1 day ago

there's not really a "standard" way to highlight on IRC and im pretty sure i've seen clients highlight with @ before. So I'm ok with this, as long as it's not the only way to highlight.

smakkerlak commented 1 day ago

The default has been just typing a nick and hitting tab in all the IRC clients I've used. Instead of making a special case of @, treat any space followed by special characters as space, so that any special character will be ignored when tab completing, but actual text will not result in various strings having ": " added.

I'm not a super big fan of this though, mostly because of confusion with IRC statuses like op @, half op, % voice + and so on.

I can see a middle ground where typing @ is turned into a feature that pops up a small type-ahead menu that narrows down users in the channel as more text is typed. But no @ actually sent to the channel :p

voidlily commented 1 day ago

there's not really a "standard" way to highlight on IRC and im pretty sure i've seen clients highlight with @ before. So I'm ok with this, as long as it's not the only way to highlight.

i've already seen the client color usernames preceded with @ before so there's that going for it already

The default has been just typing a nick and hitting tab in all the IRC clients I've used. Instead of making a special case of @, treat any space followed by special characters as space, so that any special character will be ignored when tab completing, but actual text will not result in various strings having ": " added.

not a bad idea but it may conflict with channel completion with # which i think it might be doing already?

voidlily commented 1 day ago

i think hexchat did the space thing too which effectively let you complete with @, need to remember how it works though for sure

smakkerlak commented 1 day ago

i've already seen the client color usernames preceded with @ before so there's that going for it already

Probably because any single word that matches a nick in the channel is colored. It's a good point though - highlight coloring should ignore special characters too.

not a bad idea but it may conflict with channel completion with # which i think it might be doing already?

I'm convinced that someone is able to code around all that :)

glguy commented 1 day ago

This shouldn't be the default, but I've made it configurable in my clients. The reason that convinced me to make it configurable was that some people were using the client to connect to a non-IRC service via an IRC bridge and the convention on that service was different from IRC.

In my case I made it configurable what prefix and suffix was added to a nickname both at the start and separately in the middle of a message. When completing at the start people often like a trailing comma or colon, for example.

@voidlily If you're putting @'s in front of people's nicknames on a normal IRC server you're just going to annoy a lot of people, though.

voidlily commented 1 day ago

i think configurable would make sense, i'm working on bridges as well and the convention for the services i'm bridging to also have the @-mention convention if people feel strongly enough about it that having @ completion would annoy people on "real" irc anyway