Skip to content

Commit fa12ce6

Browse files
committed
cephfs-top: exception when terminal size greater than PAD_WIDTH
Fixes: https://tracker.ceph.com/issues/69669 Signed-off-by: Jos Collin <[email protected]>
1 parent 8f415be commit fa12ce6

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/tools/cephfs/top/cephfs-top

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,6 @@ class FSTop(FSTopBase):
360360
# requested it will raise an exception
361361
pass
362362

363-
# Check the window size before creating the pad. For large windows,
364-
# PAD_WIDTH = window width.
365-
h, w = self.stdscr.getmaxyx()
366-
if (w > DEFAULT_PAD_WIDTH):
367-
self.PAD_WIDTH = w
368-
self.fstop_pad = curses.newpad(self.PAD_HEIGHT, self.PAD_WIDTH)
369363
self.run_all_display()
370364

371365
def display_fs_menu(self, stdscr, selected_row_idx):
@@ -964,8 +958,13 @@ class FSTop(FSTopBase):
964958
top, left = 0, 0 # where to place pad
965959
vscrollOffset, hscrollOffset = 0, 0 # scroll offsets
966960

967-
# calculate the initial viewport height and width
961+
# Check the window size before creating the pad. For large windows, PAD_WIDTH=window width.
968962
windowsize = self.stdscr.getmaxyx()
963+
if (windowsize[1] > DEFAULT_PAD_WIDTH):
964+
self.PAD_WIDTH = windowsize[1]
965+
self.fstop_pad = curses.newpad(self.PAD_HEIGHT, self.PAD_WIDTH)
966+
967+
# calculate the initial viewport height and width
969968
self.viewportHeight, self.viewportWidth = windowsize[0] - 1, windowsize[1] - 1
970969

971970
# create header subpad
@@ -1098,8 +1097,13 @@ class FSTop(FSTopBase):
10981097
top, left = 0, 0 # where to place pad
10991098
vscrollOffset, hscrollOffset = 0, 0 # scroll offsets
11001099

1101-
# calculate the initial viewport height and width
1100+
# Check the window size before creating the pad. For large windows, PAD_WIDTH=window width.
11021101
windowsize = self.stdscr.getmaxyx()
1102+
if (windowsize[1] > DEFAULT_PAD_WIDTH):
1103+
self.PAD_WIDTH = windowsize[1]
1104+
self.fstop_pad = curses.newpad(self.PAD_HEIGHT, self.PAD_WIDTH)
1105+
1106+
# calculate the initial viewport height and width
11031107
self.viewportHeight, self.viewportWidth = windowsize[0] - 1, windowsize[1] - 1
11041108

11051109
# create header subpad

0 commit comments

Comments
 (0)