Skip to content

Fix various width issues #220

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

Merged
merged 12 commits into from
Dec 24, 2019
Merged

Fix various width issues #220

merged 12 commits into from
Dec 24, 2019

Conversation

AydinHassan
Copy link
Member

Hopefully this should fix #219. This has taken me all day to fix 😭

Also adds a few utils, debug mode for menu style and mock terminal class for tests.

Going to add a few more tests for the changes regarding width and margins.

@codecov-io
Copy link

codecov-io commented Dec 22, 2019

Codecov Report

Merging #220 into master will increase coverage by <.01%.
The diff coverage is 97.61%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #220      +/-   ##
============================================
+ Coverage     93.01%   93.02%   +<.01%     
- Complexity      591      606      +15     
============================================
  Files            30       31       +1     
  Lines          1761     1791      +30     
============================================
+ Hits           1638     1666      +28     
- Misses          123      125       +2
Impacted Files Coverage Δ Complexity Δ
src/Util/StringUtil.php 100% <100%> (ø) 8 <2> (+2) ⬆️
src/Util/ArrayUtil.php 100% <100%> (ø) 1 <1> (?)
src/MenuStyle.php 96.35% <97.22%> (-0.45%) 76 <6> (+12)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1316f37...587fd8b. Read the comment docs.

@AydinHassan
Copy link
Member Author

@jtreminio could you make some tests with PR see if it fixes your problems?

This was referenced Dec 22, 2019
@jtreminio
Copy link
Contributor

This is almost perfect, but the margin is being applied only to left-side:

I've highlighted the scrollbar area on my terminal:

image

This is with your patch of

    protected function calculateContentWidth() : void
    {
        $this->contentWidth = $this->width
            - ($this->paddingLeftRight * 2)
            - ($this->borderRightWidth + $this->borderLeftWidth)
            - ($this->margin);

        if ($this->contentWidth < 0) {
            $this->contentWidth = 0;
        }
    }

image

@AydinHassan
Copy link
Member Author

AydinHassan commented Dec 24, 2019

That was the wrong fix actually, it's all related to shrinking the menu width when the terminal is too narrow. Regarding the right margin, yeah we actually don't ever print that because it's obviously empty space, so it never got handled when the terminal is too narrow. Will implement that in another PR.

@AydinHassan AydinHassan merged commit b7872dd into master Dec 24, 2019
@AydinHassan AydinHassan deleted the width branch December 24, 2019 18:36
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

Successfully merging this pull request may close these issues.

Columns < 100 results in broken submenu layouts/colors
3 participants