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

How to force table to rotate vertically #8

Open
summera opened this issue Mar 13, 2016 · 4 comments
Open

How to force table to rotate vertically #8

summera opened this issue Mar 13, 2016 · 4 comments
Labels

Comments

@summera
Copy link

summera commented Mar 13, 2016

Maybe I'm missing something here, but when I try to render a table that is larger than the terminal window, tty-table throws Table's width is too small to contain the content (min width 3999, currently set 3999). When I mess with resize and width options, the table still does not want to rotate.

If I try

table.render width: 4000, resize: true

it throws NoMethodError: undefined method 'rindex' for nil:NilClass.

How do I get the table to flip vertically if it is too large? Also, can I have it so that the content overflows horizontally?

@piotrmurach
Copy link
Owner

Thanks for using the library!

It has some rough edges still, auto resizing is one of them. However, you should be able to flip the orientation:

table = TTY::Table.new ..... orientation: :vertical

@summera
Copy link
Author

summera commented Mar 13, 2016

@peter-murach thanks for quick response

Just tried as you said, but something odd is happening

>> x = []
=> []
>> 2000.times{ |i| x <<i }
=> 2000
>> require 'tty-table'
=> true
>> table = TTY::Table.new [x, x], orientation: :vertical
=> #<TTY::Table header=nil rows=[#<TTY::Table::Row fields=["1", 0]>, #<TTY::Table::Row fields=["2", 1]>, #<TTY::Table::Row fields=["3", 2]>, #<TTY::Table::Row fields=["1", 0]>, #<TTY::Table::Row fields=["2", 1]>, #<TTY::Table::Row fields=["3", 2]>] orientation=#<TTY::Table::Orientation::Vertical:0x007fd439cd1530 @name=:vertical> original_rows=2 original_columns=2000>
>> puts table
1 0
2 1
3 2
1 0
2 1
3 2
=> nil

@epinault
Copy link

I have a similar issue. The vertical rotate is nice. But if my terminal is too small and resize is set to true, I get the NoMethodError: undefined method 'rindex' for nil:NilClass in truncate. I would be in favor of either throw an something that force to turn of resize true, or send a message to the user the table is to big for the terminal and need to be expanded or switch the resize to false to have vertical row..

@SpComb
Copy link

SpComb commented Mar 16, 2018

Full backtrace for the resize: true bug when the terminal width is too small for a column:

NoMethodError: undefined method `rindex' for nil:NilClass
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/verse-0.5.0/lib/verse/truncation.rb:71:in `truncate'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/verse-0.5.0/lib/verse/truncation.rb:36:in `truncate'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/verse-0.5.0/lib/verse.rb:47:in `truncate'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/tty-table-0.9.0/lib/tty/table/operation/truncation.rb:38:in `call'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/tty-table-0.9.0/lib/tty/table/operations.rb:65:in `block (4 levels) in run_operations'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/tty-table-0.9.0/lib/tty/table/operations.rb:64:in `each'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/tty-table-0.9.0/lib/tty/table/operations.rb:64:in `block (3 levels) in run_operations'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/tty-table-0.9.0/lib/tty/table/operations.rb:63:in `each'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/tty-table-0.9.0/lib/tty/table/operations.rb:63:in `block (2 levels) in run_operations'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/tty-table-0.9.0/lib/tty/table/operations.rb:61:in `each'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/tty-table-0.9.0/lib/tty/table/operations.rb:61:in `each_with_index'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/tty-table-0.9.0/lib/tty/table/operations.rb:61:in `block in run_operations'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/tty-table-0.9.0/lib/tty/table/operations.rb:60:in `each'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/tty-table-0.9.0/lib/tty/table/operations.rb:60:in `each_with_index'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/tty-table-0.9.0/lib/tty/table/operations.rb:60:in `run_operations'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/tty-table-0.9.0/lib/tty/table/renderer/basic.rb:203:in `render'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/tty-table-0.9.0/lib/tty/table/renderer.rb:96:in `render'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/tty-table-0.9.0/lib/tty/table/renderer.rb:77:in `render_with'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/tty-table-0.9.0/lib/tty/table.rb:451:in `render_with'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/tty-table-0.9.0/lib/tty/table.rb:425:in `render'
  /home/kontena/kontena/kontena/cli/lib/kontena/cli/table_generator.rb:74:in `render'
  /home/kontena/kontena/kontena/cli/lib/kontena/cli/table_generator.rb:35:in `generate_table'
  /home/kontena/kontena/kontena/cli/lib/kontena/cli/table_generator.rb:39:in `print_table'
  /home/kontena/kontena/kontena/cli/lib/kontena/cli/containers/list_command.rb:25:in `execute'
  /home/kontena/kontena/kontena/cli/lib/kontena/command.rb:216:in `run'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/clamp-1.2.1/lib/clamp/subcommand/execution.rb:11:in `execute'
  /home/kontena/kontena/kontena/cli/lib/kontena/command.rb:216:in `run'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/clamp-1.2.1/lib/clamp/subcommand/execution.rb:11:in `execute'
  /home/kontena/kontena/kontena/cli/lib/kontena/command.rb:216:in `run'
  /home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/clamp-1.2.1/lib/clamp/command.rb:132:in `run'
  bin/kontena:22:in `<top (required)>'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants