GithubHelp home page GithubHelp logo

Comments (13)

practicingruby avatar practicingruby commented on September 26, 2024

That sounds right to me. Please prepare a patch and I'll take a look at it.

from highline.

JEG2 avatar JEG2 commented on September 26, 2024

That said, I think the old behavior does have some merit. Perhaps we could have an option to go either way?

from highline.

practicingruby avatar practicingruby commented on September 26, 2024

Can you come up with an example where the old behavior would be preferable? I'm sure one exists just at a loss for it right now, especially if we have a padding option.

from highline.

yfeldblum avatar yfeldblum commented on September 26, 2024

The current behavior would be preferable when the columns have similar max element widths. In that case, having columns with widths of [8, 9, 7, 9, 7, 8] might be a little distracting, while forcing the widths to [9, 9, 9, 9, 9, 9] might be less distracting.

However, where the columns have rather different max element widths - [8, 36, 1, 1, 10] - it is better to keep the widths rather than to force them to [36, 36, 36, 36, 36].

from highline.

yfeldblum avatar yfeldblum commented on September 26, 2024

The example of [8, 36, 1, 1, 10] is based on a real-world example from the knife-rackspace gem for the command knife rackspace server list (the ui method returns a HighLine instance).

from highline.

JEG2 avatar JEG2 commented on September 26, 2024

Yeah, I think it's mostly taste. I fine the equal widths easier to grok quickly. Also, if it was numerical spreadsheet like data, lining up the numbers might look more natural.

from highline.

yfeldblum avatar yfeldblum commented on September 26, 2024

Taste plays a big factor. But what tends to happen in my example is that, because one column is wide (30+ characters wide, multiple times wider than any other column) and the rest are narrow, each line of the grid wraps around and fills up its own line plus half of the next line in the terminal.

My terminal window is decently wide. But this makes the grid unreadable anyway. Not because there's too much data to fit in the grid, but because the grid is so sparse - because one column is multiple times wider than any other column, making every column in the grid display equally wide. I've got multiple columns which should be two characters wide each actually taking up 30-40 characters of screen real-estate simply because one of the columns is that wide.

It's taste up until it forces a sparse grid to wrap.

from highline.

JEG2 avatar JEG2 commented on September 26, 2024

I totally agree with Greg, there's no reason we shouldn't patch it. I'm just suggesting we, go the distance. With one simple if, we can have it both ways, right?

from highline.

yfeldblum avatar yfeldblum commented on September 26, 2024

Having it both ways, controlled by an option of some kind, would be fantastic.

That way, the default strategy for most programs would be to continue to assume the current behavior.

But programs such as knife rackspace server list that know their grid columns can have highly variable widths can customize the behavior to suit.

Best of both worlds.

from highline.

JEG2 avatar JEG2 commented on September 26, 2024

Agreed. It's an easy patch. Can you put it together for us?

from highline.

JEG2 avatar JEG2 commented on September 26, 2024

I added :uneven_columns_across and :uneven_columns_down as modes for list().

from highline.

yfeldblum avatar yfeldblum commented on September 26, 2024

This patch seems to work fine in the usual case.

ruby-1.9.2-p180 :007 > a = %w(Blah a b c ad e fs f g)
 => ["Blah", "a", "b", "c", "ad", "e", "fs", "f", "g"] 
ruby-1.9.2-p180 :008 > puts ui.list(a, :uneven_columns_across, 3)
Blah  a   b
c     ad  e
fs    f   g
 => nil 

However, when there's bold formatting on the first row, it doesn't seem to work right:

ruby-1.9.2-p180 :009 > a = [ui.color("Blah", :bold), ui.color("a", :bold), ui.color("b", :bold), "c", "ad", "e", "fs", "f", "g"]
 => ["\e[1mBlah\e[0m", "\e[1ma\e[0m", "\e[1mb\e[0m", "c", "ad", "e", "fs", "f", "g"] 
ruby-1.9.2-p180 :010 > puts ui.list(a, :uneven_columns_across, 3)
Blah  a  b
c             ad         e        
fs            f          g        
 => nil 

from highline.

yfeldblum avatar yfeldblum commented on September 26, 2024

One specific use case for this issue is the knife-rackspace library. Example.

from highline.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.