benthayer / git-gud

Wanna git gud? Then get git-gud, and git gud at git!
MIT License
401 stars 42 forks source link

Word Wrap #274

Open benthayer opened 3 years ago

benthayer commented 3 years ago

Words tend to be cut off and finished on a new line when we just print them out directly, so word wrap would be a great usability feature.

sahansk2 commented 3 years ago

A combination of the textwrap module and shutil.get_terminal_size() should do the trick. Using from builtins import print as python_print (or whatever, the name python_print was arbitrary) may be useful if we want to define our own print that wraps the builtin printing function.

This shouldn't be too difficult to implement, so I won't take this issue in case there's anyone who'd like to work on the issue. I'd guess that the code for this new print function should be in gitgud/skills/user_messages.py.

benthayer commented 3 years ago

That's one option. We can actually modify the print function output stream directly, but we'd need that to be the first thing executed in the code so that the change is in effect. This would reduce refactoring and it'll make sure we're always using the right function. I'm not sure if I'm a fan of this method, but it's possible. I do like the idea of having all output messages in user_messages.py though, even more than are there now, which would eventually help with adding multiple languages

benthayer commented 3 years ago

I agree this would be a good issue for newcomers. I added the appropriate tags. Anyone interested, feel free to comment