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

Consider making output as wide as the terminal #3

Open
yarikoptic opened this issue Feb 13, 2018 · 9 comments · May be fixed by #8
Open

Consider making output as wide as the terminal #3

yarikoptic opened this issue Feb 13, 2018 · 9 comments · May be fixed by #8

Comments

@yarikoptic
Copy link

Possibly making it optional... I would have added --width=auto and did max terminal width if that information is available ... here is code from tqdm

tqdm/_utils.py-def _environ_cols_linux(fp):  # pragma: no cover
tqdm/_utils.py-
tqdm/_utils.py-    try:
tqdm/_utils.py:        from termios import TIOCGWINSZ
tqdm/_utils.py-        from fcntl import ioctl
tqdm/_utils.py-        from array import array
tqdm/_utils.py-    except ImportError:
tqdm/_utils.py-        return None
tqdm/_utils.py-    else:
tqdm/_utils.py-        try:
tqdm/_utils.py:            return array('h', ioctl(fp, TIOCGWINSZ, '\0' * 8))[1]
tqdm/_utils.py-        except:
tqdm/_utils.py-            try:
tqdm/_utils.py-                from os.environ import get
tqdm/_utils.py-            except ImportError:
tqdm/_utils.py-                return None
tqdm/_utils.py-            else:
tqdm/_utils.py-                return int(get('COLUMNS', 1)) - 1
@juhakivekas
Copy link
Owner

juhakivekas commented Feb 13, 2018

Thanks for good input :)

I assume this relates to the hexdump view? Quite a lot of people have a strong inclination to use multiples of eight in hexdump widths, but this being configurable surely covers most cases. How about supporting:

  • —width [number]
  • —width max

@yarikoptic
Copy link
Author

yeah, that is what I had in mind ;) if auto -- go after full width, if specified -- that is the one to use

@Utkarsh1308
Copy link
Contributor

I suggest an alternate approach using the os module

rows, columns = os.popen('stty size', 'r').read().split() where columns variable stores the width of the terminal

Then an additional argument can be made which asks for the number of bytes to be printed on each line
If the user calls --width max then args.width would be equal to columns

Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 1, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 1, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 1, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 1, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 1, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 1, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 1, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 1, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 1, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 1, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 1, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 1, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 1, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 1, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 1, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 1, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 1, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 1, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 1, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 1, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 2, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 2, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 2, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 2, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 2, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 2, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 2, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 2, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 2, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 2, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 2, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 3, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 3, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 3, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 3, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 3, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 3, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 3, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 3, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 3, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 3, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 3, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 3, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 3, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 3, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 3, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 3, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 3, 2019
Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 3, 2019
@juhakivekas
Copy link
Owner

@Utkarsh1308 I appreciate your efforts 👍

Utkarsh1308 added a commit to Utkarsh1308/multidiff that referenced this issue Jun 6, 2019
@Utkarsh1308 Utkarsh1308 linked a pull request Jun 9, 2019 that will close this issue
@juhakivekas
Copy link
Owner

Thanks for the pull request but there might be a little misunderstanding in what feature was requested. The idea is that we want to either use all the screen area we have available, or to group our input to other than multiples of 16 (normal hexdump format). @yarikoptic suggested this but doesn't need it.

This feature is a little like the format string given in the -e flag in the hexdump utility:

  • multidiff --width 16 should produce hexdumps similar to hecdump -C
  • multidiff --width 25 should produce hexdumps similar to hexdump -e '"%06_ax: " 25/1 "%02x " " | " 25/1 "%_p" "\n"'
  • multidiff --width 6 should produce hexdumps similar to hexdump -e '"%06_ax: " 6/1 "%02x " " | " 6/1 "%_p" "\n"'

@Utkarsh1308 if you need the feature youve implemented (filling rows with characters), then I'm happy to merge it. But if this isn't needed by you, then I'd rather not add a feature which is likely not to be used.

@Utkarsh1308
Copy link
Contributor

Utkarsh1308 commented Jun 12, 2019

I understand! Sorry for the misunderstanding. Please don't close my PR. I'll add a new attribute which does the desired behavior wanted by @yarikoptic :D

I do want the width attribute I've implemented. But I'd be happy to add an attribute which gives this behavior

@Utkarsh1308
Copy link
Contributor

Utkarsh1308 commented Jun 12, 2019

For achieving this behavior I will have to create an argument. Then I'll have to replace 16 with that argument in render.py :)
But the code runs really slow when I do this. Is there any other solution for this?
I will have to replace the argument with 16 here:

if self.rowlen == 16:

consumed = self._append(data[:16 - self.rowlen], color)

self.addr += 16

self.hexrow += 3*(16 - self.rowlen) * ' '

self.asciirow += (16 - self.rowlen) * ' '

@Utkarsh1308
Copy link
Contributor

I found an alternate approach to get the desired output. Please review my PR

@Utkarsh1308
Copy link
Contributor

Hey @juhakivekas
Any changes you would want in my PR? I'm happy to help ;)

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 a pull request may close this issue.

3 participants