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

Utilize rich "soft_wrap" feature for Improved Display #861

Merged
merged 3 commits into from
Aug 21, 2023

Conversation

Arker123
Copy link
Collaborator

@Arker123 Arker123 commented Aug 20, 2023

We can leverage the rich library's soft_wrap feature, which neatly handles line breaks while maintaining the string's integrity.

Reference:- https://github.com/pycontribs/enrich

Fixes:- #826

@mr-tz
Copy link
Collaborator

mr-tz commented Aug 21, 2023

Cool, can you share a before and after output? Also black is not happy here, so please address.

@Arker123
Copy link
Collaborator Author

Currently, the terminal wraps long lines, as depicted in the following images:


image


image

In contrast, in previous instances, the terminal did not wrap long lines, as illustrated by this image:
image

@@ -301,7 +301,7 @@ def get_color(color):

def render(results: floss.results.ResultDocument, verbose, disable_headers, color):
sys.__stdout__.reconfigure(encoding="utf-8")
console = Console(file=io.StringIO(), color_system=get_color(color), highlight=False)
console = Console(file=io.StringIO(), color_system=get_color(color), highlight=False, redirect=False)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be using soft_wrap=True? i don't see how this change affects the wrapping.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the soft_wrap parameter is already set to true by default.


Screenshot from 2023-08-21 17-07-36

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we could also achieve this with rich and setting soft_wrap=True?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see, my mistake! You're right. Using rich and turning on soft_wrap=True would definitely give us the result we want. Thanks for letting me know! 😅

@Arker123 Arker123 changed the title Utilize enrich for Improved Display Utilize rich "soft_wrap" feature for Improved Display Aug 21, 2023
@mr-tz mr-tz merged commit baf2d92 into mandiant:master Aug 21, 2023
19 checks passed
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.

3 participants