Skip to content

Commit

Permalink
Modify MIN_COLS based on amount of ports user want to show
Browse files Browse the repository at this point in the history
That is a quick way to get MIN_COLS check to work again

However in case `-m 0` or `-m -1` specified (all ports), check won't be
adjusted to actual number of ports available on a system
  • Loading branch information
Civil committed Feb 27, 2024
1 parent 597e822 commit 411efc8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def completenames(self, text, *ignored):
class TRexConsole(TRexGeneralCmd):
"""Trex Console"""

def __init__(self, client, verbose = False, dummy_client = False):
def __init__(self, client, verbose = False, dummy_client = False, max_ports = 4):

# cmd lock is used to make sure background job
# of the console is not done while the user excutes commands
Expand All @@ -202,7 +202,7 @@ def __init__(self, client, verbose = False, dummy_client = False):

self.terminal = None

self.tui = trex_tui.TrexTUI(self)
self.tui = trex_tui.TrexTUI(self, max_ports)
self.cap_mngr = CaptureManager(client, self.cmd_lock)
self.load_client_console_functions()
self.postcmd(False, "")
Expand Down Expand Up @@ -915,7 +915,7 @@ def run_console(client, logger, options):
if not cont:
return

console = TRexConsole(client = client, verbose = options.verbose, dummy_client = options.emu_only_server is not None)
console = TRexConsole(client = client, verbose = options.verbose, dummy_client = options.emu_only_server is not None, max_ports = options.max_ports)
console.server = options.server # set server in console so plugins can use it

# run emu if needed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,10 @@ def __init__ (self, cols, rows):
super(TrexTUI.ScreenSizeException, self).__init__(msg)


def __init__ (self, console):
def __init__ (self, console, max_ports = 4):
if max_ports > 2:
# Showing one port takes about 20 columns
TrexTUI.MIN_COLS += 20 * (max_ports - 4)
self.console = console
self.client = console.client

Expand Down

0 comments on commit 411efc8

Please sign in to comment.