Skip to content

Commit

Permalink
about_popup: Terminal size added.
Browse files Browse the repository at this point in the history
Fixes zulip#1536.
  • Loading branch information
Swarnim114 committed Aug 3, 2024
1 parent 743db7d commit 2ce2242
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
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()
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

0 comments on commit 2ce2242

Please sign in to comment.