Giter Club home page Giter Club logo

Comments (4)

piotrmurach avatar piotrmurach commented on August 31, 2024

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

from tty-table.

summera avatar summera commented on August 31, 2024

@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

from tty-table.

epinault avatar epinault commented on August 31, 2024

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..

from tty-table.

SpComb avatar SpComb commented on August 31, 2024

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)>'

from tty-table.

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.