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

about_popup: Terminal size added. #1542

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion tests/ui_tools/test_popups.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ def mock_external_classes(self, mocker: MockerFixture) -> None:

mocker.patch(MODULE + ".detected_python_in_full", lambda: "[Python version]")

terminal_size = "24 rows x 80 cols"

self.about_view = AboutView(
self.controller,
"About",
Expand All @@ -208,6 +210,7 @@ def mock_external_classes(self, mocker: MockerFixture) -> None:
maximum_footlinks=3,
exit_confirmation_enabled=False,
transparency_enabled=False,
terminal_size=terminal_size,
)

@pytest.mark.parametrize(
Expand Down Expand Up @@ -259,6 +262,7 @@ def test_feature_level_content(
maximum_footlinks=3,
exit_confirmation_enabled=False,
transparency_enabled=False,
terminal_size="24 rows x 80 cols",
)

assert len(about_view.feature_level_content) == (
Expand Down Expand Up @@ -299,7 +303,8 @@ def test_copied_content(self) -> None:

#### Detected Environment
Platform: WSL
Python: [Python version]"""
Python: [Python version]
Terminal Size: 24 rows x 80 cols"""
assert self.about_view.copy_info == expected_output


Expand Down
5 changes: 5 additions & 0 deletions zulipterminal/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import itertools
import os
import shutil
import signal
import sys
import time
Expand Down Expand Up @@ -301,6 +302,9 @@ def popup_with_message(self, text: str, width: int) -> None:
self.show_pop_up(NoticeView(self, text, width, "NOTICE"), "area:error")

def show_about(self) -> None:
terminal_size = shutil.get_terminal_size()
Copy link
Collaborator

Choose a reason for hiding this comment

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

You changed to using shutil here - was there as a specific reason for this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Swarnim114 To confirm, this looks good, but I wasn't sure why you switched to this.

Copy link
Collaborator Author

@Swarnim114 Swarnim114 Aug 21, 2024

Choose a reason for hiding this comment

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

@neiljp I thought it would be just simpler and give me no issues..

Copy link

Choose a reason for hiding this comment

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

os.get_terminal_size() works fine, no?
I tried to replicate what @Swarnim114 did in this PR but without using shutil and it's working for me.

Screenshot 2024-10-29 115454

@Swarnim114 are there any shortcomings of doing it this way?

Copy link

Choose a reason for hiding this comment

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

@neiljp, any advice on this?

terminal_size_str = f"{terminal_size.columns} cols x {terminal_size.lines} rows"

self.show_pop_up(
AboutView(
self,
Expand All @@ -315,6 +319,7 @@ def show_about(self) -> None:
maximum_footlinks=self.maximum_footlinks,
exit_confirmation_enabled=self.exit_confirmation,
transparency_enabled=self.transparency_enabled,
terminal_size=terminal_size_str,
),
"area:help",
)
Expand Down
7 changes: 6 additions & 1 deletion zulipterminal/ui_tools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,7 @@ def __init__(
notify_enabled: bool,
exit_confirmation_enabled: bool,
transparency_enabled: bool,
terminal_size: str,
) -> None:
self.feature_level_content = (
[("Feature level", str(server_feature_level))]
Expand Down Expand Up @@ -1119,7 +1120,11 @@ def __init__(
),
(
"Detected Environment",
[("Platform", PLATFORM), ("Python", detected_python_in_full())],
[
("Platform", PLATFORM),
("Python", detected_python_in_full()),
("Terminal Size", terminal_size),
],
),
]

Expand Down
Loading