matterhorn-chat / matterhorn

A feature-rich Unix terminal client for the Mattermost chat system
BSD 3-Clause "New" or "Revised" License
1.02k stars 75 forks source link

Align messages and user names in the text view #788

Closed nteodosio closed 1 year ago

nteodosio commented 1 year ago

I sometimes get lost when reading Matterhorn because of the multiple levels of indentations and the mix of reactions/attachments with text.

To address the former, I propose to left align messages and right align user names to a ruler column, similar to how the majority of IRC clients do (examples: 1, 2).

I know that this is more of a challenge in a protocol that has threading, reactions etc., but the following example could be doable.

Before:

[12:00] xxxxxxxxx[BOT]:
          <Bxx xxxxxx>
           │ -xxx 110.549.0
           │ +xxx 110.0.642                            
        xxxxxx: @xxxxxxx xxx xxx xxxxxxx xx xxxxxxxxx xxx ...
[13:38] │ xxxxxxx: @xxxxxx xxxxx xxxxxxxx: xx xxx xxxx xx
        │          xx'xx xxxx                              
        │          xxx 108 xx? x'x xxxxxxxx xxx (xxxxxx)
[13:56] │ xxxxxxx:
        │   xx xxxx'x xxxx x xxxx xxxxx xxx:
        │   <xxxxx://xxxxxx.xxx/xxxxxxxxx/xxxxx-xxxx/xxxxxx>
        │   x xxxxxx xxxxxxxx xxx x xxxxx xxxx xx xx xx
        │   xxxxxxxxx
[14:01] xxxxxx: I'x xxxxxxx xx xxxx xxxx xx xx xxxxx xx I'xx
                xxxxxxx xxxxx, xxx xxxx xxxxx xxxxx xxxxx
[14:02] xxxxxxx: xxxxxx :) x'xx xxx x xxxxx xx xx xx xxx xx
                 xx xxxxx xxxx xxxx x'xx xxxxxx x PR xxxx
                 xxxx xxxx xx xx (xxxxxx)
        xxxxxx: I'x xxxxxxx xx xxxx xxxx xx xx xxxxx xx I'...
[15:01] │ xxxxxx: xxxxxxxxx, xxxx xxxxx xxxxxxx
[15:13] │ xxxxxxx:
        │   xxxxxxx :xxxxx: xx xxxx xxxx, xxxx'x xxx PR:
        │   <xxxxx://xxxxxx.xxx/xxxxxxxxx/xxxxxxx-xxxx/xxxx/1
        │   xxx xxx xx xxxxxx x'x xxxxxxx xx:
        │   <xxxxx://xxxxxxxxx.xxx/~xxxxxxx/+xxxx/xxxxxxx-xxx

After:

[12:00] xxxxxxxxx[BOT] <Bxx xxxxxx>
                       -xxx 110.549.0
                       +xxx 110.0.642                            
                xxxxxx @xxxxxxx xxx xxx xxxxxxx xx xxxxxxxxx xxx ...
[13:38] │      xxxxxxx @xxxxxx xxxxx xxxxxxxx: xx xxx xxxx xx
        │              xx'xx xxxx                              
        │              xxx 108 xx? x'x xxxxxxxx xxx (edited)
[13:56] │      xxxxxxx xx xxxx'x xxxx x xxxx xxxxx xxx:
        │              <xxxxx://xxxxxx.xxx/xxxxxxxxx/xxxx-xxxx/xxxxxx>
        │              x xxxxxx xxxxxxxx xxx x xxxxx xxxx xx xx xx
        │              xxxxxxxxx
[14:01]         xxxxxx I'x xxxxxxx xx xxxx xxxx xx xx xxxxx xx I'xx
                       xxxxxxx xxxxx, xxx xxxx xxxxx xxxxx xxxxx
[14:02]        xxxxxxx xxxxxx :) x'xx xxx x xxxxx xx xx xx xxx xx
                       xx xxxxx xxxx xxxx x'xx xxxxxx x PR xxxx
                       xxxx xxxx xx xx (xxxxxx)
                xxxxxx I'x xxxxxxx xx xxxx xxxx xx xx xxxxx xx I'...
[15:01] │       xxxxxx xxxxxxxxx, xxxx xxxxx xxxxxxx
[15:13] │      xxxxxxx xxxxxxx :xxxxx: xx xxxx xxxx, xxxx'x xxx PR:
        │              <xxxxx://xxxxxx.xxx/xxxxxxxxx/xxxxxxx-xxxx/xxxx/1
        │              xxx xxx xx xxxxxx x'x xxxxxxx xx:
        │              <xxxxx://xxxxxxxxx.xxx/~xxxxxxx/+xxxx/xxxxxxx-xxx

This example is just an idea.

I'd like to point out that I also squashed the code block in lines 3-4, but one can still identify them with colors, attributes etc.

Thank you for Matterhorn. It's a breeze of fresh air compared to the GUI desktop one.

jtdaugherty commented 1 year ago

Thanks for this suggestion!

I thought about taking this approach when I first implemented the message rendering logic. This approach can work really well as long as the user names are relatively short. However, it results in a lot of wasted space when user names get long, and Mattermost and Matterhorn support displaying users by their full names and nicknames as well. That means that taking this approach will lead to the "column" of user names being potentially 30 terminal cells wide or more, and all it takes is one user in the conversation to result in a layout where the message text has very little room to get wrapped in. That, combined with the fact that many users want to run Matterhorn in a relatively narrow terminal window, means that I am not confident that this would be an overall usability improvement. I'm sorry to say that, and I know that doesn't help much with the indentation, but I wanted to give that context.

nteodosio commented 1 year ago

Thanks for sharing your thoughts.

I believe the issue you describe is similar to long channel names. Would it be viable to solve it likewise, namely with a userNameWidth variable?