Skip to content

Conversation

@trevarj
Copy link
Contributor

@trevarj trevarj commented Jan 15, 2021

Added Aligned UI, which can be turned on or off, and configured (currently only minimally).

Implementation details:

  • The message area now has a Layout -- Compact (original) and Aligned.
  • Each Line getting constructed will have a type -- regular and aligned (Msg and Aligned, within LineDataCache). Not all message lines are aligned in the aligned ui (ex. topics)
  • Drawing will consider the line type when drawing each line.

Small refactors are included.

Closes #169 and #299

Copy link
Owner

@osa1 osa1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @trevarj , and sorry for the delay.

This looks good. Left some inline comments. We should merge this and start using.

#[serde(rename_all = "snake_case")]
pub(crate) enum UiStyle {
Compact,
Aligned { max_nick_length: usize },
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny is supposed to easy to configure and provide good UX out of the box, so I think making max_nick_length optional would be good. I think I should be able to change

ui_style: compact

to

ui_style: aligned

and it should work.

Perhaps moving max_nick_length to another top-level field might make sense. Something like:

ui_style: aligned
max_nick_length: 12


#[derive(Deserialize)]
#[serde(rename_all = "snake_case")]
pub(crate) enum UiStyle {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename this to Layout maybe? (both the type name and the config field name)

/// Inserts a blank space that is the size of a timestamp
fn blank(msg_area: &mut MsgArea) {
msg_area.add_text(
&format!("{:^width$}", "", width = Timestamp::WIDTH),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allocates a String, but it's actually a static string. I think we can't create &'static str using WIDTH, but having a const/static string next to WIDTH, with documentation that the length of the string should be WIDTH should be fine.

@osa1 osa1 merged commit 43160cb into osa1:master Apr 14, 2021
@trevarj trevarj mentioned this pull request Apr 14, 2021
@trevarj trevarj deleted the aligned-ui branch August 29, 2021 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aligned table display

2 participants