Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ellisons don't play nice with column alignment #5

Closed
BAXTER001 opened this issue Sep 16, 2014 · 5 comments
Closed

Ellisons don't play nice with column alignment #5

BAXTER001 opened this issue Sep 16, 2014 · 5 comments

Comments

@BAXTER001
Copy link

For example all rows with the [...] substituted in have slightly incorrect offsets for the following columns, for example the "Digital Marketing Executive - Ar..." entry below.

dogecoin-logo.png                                                                             Binary File
Digital Marketing Executive - Ar[...]                                   Binary File
final.gif                                                                                     Binary File

Output is from a 55x186 gnome terminal session.

@sg-s
Copy link

sg-s commented Sep 16, 2014

yeah, i see this too.

@dborzov
Copy link
Owner

dborzov commented Sep 16, 2014

This is a major issue that really affects user experience. I will need to address it first, thanks for bringing it up.

@BAXTER001 BAXTER001 changed the title Ellisions don't play nice with column alignment Ellisons don't play nice with column alignment Sep 16, 2014
@BAXTER001
Copy link
Author

If you can point me to the section to stare at I'd be happy to give a fix a go.

@dborzov
Copy link
Owner

dborzov commented Sep 17, 2014

Wow, that would have been amazing, thanks @BAXTER001 ! The func in question is in fmt.go@PrintColumns(filename, description string).

There is this complication that I use colorstring library that converts colour tags within the string into escape characters to show coloured text in shell:

   fmt.Println(colorstring.Color("[blue]Hello [red]World!"))

These colour tags skew off the string lengths. Not sure how to bypass that easily at this stage. Maybe use other shell coloring library with a different syntax?

Maybe add a new ShellString type:

        type struct ShellString {
            s string
            color string
        }

        func (s ShellString) String() string {
            return colorstring.Color("["+s.color+"]"+  s.s) 
       }

        func (s ShellString) Length() string {
            return strings.RuneCountInString(s.s) 
       }

I think that would be the most idiomatic go way (see e.g. NullString in database/sql package) but that is quite a lot of refactoring.

@dborzov
Copy link
Owner

dborzov commented Sep 17, 2014

While we are at it, we can also make it support general number of columns, not just two. Something like PrintColumns(columns []string) instead of PrintColumns(filename, description string).

Should have done this right at the time. But nooo 😜

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

No branches or pull requests

3 participants