-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Allow table rotation and resizing to be disabled #36
base: master
Are you sure you want to change the base?
Conversation
This allows tables to be integrated with an external pager
it 'ignores the maximum width constraint' do | ||
expect(columns).not_to receive(:shrink) | ||
column_widths = columns.enforce | ||
expect(column_widths).to eql([2,2,2,2]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/SpaceAfterComma: Space missing after comma.
context 'without resize (nil)' do | ||
let(:options) { { width: 8, resize: nil }} | ||
|
||
it 'ignores the maximum width constraint' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@@ -54,6 +54,17 @@ | |||
expect(table.orientation.name).to eql(:vertical) | |||
end | |||
end | |||
|
|||
context 'without resize (nil)' do | |||
let(:options) { { width: 8, resize: nil }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/SpaceInsideBlockBraces: Space missing inside }.
@@ -54,6 +54,17 @@ | |||
expect(table.orientation.name).to eql(:vertical) | |||
end | |||
end | |||
|
|||
context 'without resize (nil)' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@@ -42,7 +42,7 @@ | |||
end | |||
end | |||
|
|||
context 'without resize' do | |||
context 'without resize (false)' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Hi William, Thanks for using Agreed, there should be a way to disable automatic rotation. I'm not sure though this is the approach I'd take to tackle this. The |
Okay I will look into making the change from Just one reservation about the naming of the new How about a |
I share your naming concern. Having said that, I usually stay away from naming options |
context 'without resize nor rotate' do | ||
let(:options) { { width: 8, resize: false, rotate: false } } | ||
|
||
it 'does not alter the column width nor table orientation' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@@ -54,6 +54,17 @@ | |||
expect(table.orientation.name).to eql(:vertical) | |||
end | |||
end | |||
|
|||
context 'without resize nor rotate' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@@ -42,8 +42,8 @@ | |||
end | |||
end | |||
|
|||
context 'without resize' do | |||
let(:options) { { width: 8, resize: false }} | |||
context 'with rotate and without resize' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Okay I've added the |
I've been having a couple of issues with the
resize
feature and external pagers. When rendering an extra large table withless
, one of the two happens:resize: false
the table is rotated, orresize: true
the table is shrunk.This occurs because the terminal width is not "technically increased" by the pager. However in practice the width is infinitely large. Instead it would be useful if the resizing and rotation feature can be disabled entirely.
I have updated
ColumnConstraint
to support aresize: nil
option which disables the terminal width check. This causes the table to be rendered according to its nature_width. Then a pager can handle the extra wide tables.Both the
resize: true
andresize: false
options are unaffected by this change add the default is stillfalse
.