From 48d1f623d3fd3216a52b58e8f1f43718666ee7d3 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 21 Sep 2015 14:50:35 +0200 Subject: fix interface assignment menus running off VGA screen When using VGA console, interface assignment can be a real pain in the ass because of the standard 80 columns width. Dmesg reports the many interface description names in very long strings that don't fit in a row, this breaks the nice appearance of the interface list in the assignment menu. The aestethics is one thing, but the real pain is that the interface list goes off screen by the time the menu asks for the WAN interface name, if there are many interfaces present. It's a real problem to choose from a list which is not visible anymore. One fix is to maximize the length of the interface description to 48 chars. The second fix (and also improvement for better overlooking when the list really goes off) is to print a small list of the interface names at each question. This is necessary because when somebody wants to assign the first interface to the last Optional port, the big list will be way off screen by then, and the name of it won't be visible. This also makes it nice clean and straightforward. --- etc/inc/config.console.inc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'etc') diff --git a/etc/inc/config.console.inc b/etc/inc/config.console.inc index bd46e6c..19eb0d2 100644 --- a/etc/inc/config.console.inc +++ b/etc/inc/config.console.inc @@ -85,8 +85,9 @@ EOD; $iflist = array(); } else { foreach ($iflist as $iface => $ifa) { + $ifsmallist = trim($ifsmallist . " " . $iface); echo sprintf("% -7s%s %s %s\n", $iface, $ifa['mac'], - $ifa['up'] ? " (up)" : "(down)", $ifa['dmesg']); + $ifa['up'] ? " (up)" : "(down)", substr($ifa['dmesg'], 0, 48)); } } @@ -186,6 +187,7 @@ EOD; "VLAN tag {$vlan['tag']}, parent interface {$vlan['if']}"); $iflist[$vlan['if'] . '_vlan' . $vlan['tag']] = array(); + $ifsmallist = trim($ifsmallist . " " . $vlan['if'] . '_vlan' . $vlan['tag']); } } @@ -198,7 +200,8 @@ hitting 'a' to initiate auto detection. EOD; do { - echo "\n" . gettext("Enter the WAN interface name or 'a' for auto-detection:") . " "; + echo "\n" . gettext("Enter the WAN interface name or 'a' for auto-detection") . " "; + printf(gettext("%s(%s or a): "), "\n", $ifsmallist); $wanif = chop(fgets($fp)); if ($wanif === "") { return; @@ -210,12 +213,13 @@ EOD; unset($wanif); continue; } + $ifsmallist = trim(str_replace(" ", " ", str_replace($wanif, "", $ifsmallist))); } while (!$wanif); do { printf(gettext("%sEnter the LAN interface name or 'a' for auto-detection %s" . "NOTE: this enables full Firewalling/NAT mode.%s" . - "(or nothing if finished):%s"), "\n", "\n", "\n", " "); + "(%s a or nothing if finished):%s"), "\n", "\n", "\n", $ifsmallist, " "); $lanif = chop(fgets($fp)); @@ -235,6 +239,7 @@ EOD; unset($lanif); continue; } + $ifsmallist = trim(str_replace(" ", " ", str_replace($lanif, "", $ifsmallist))); } while (!$lanif); /* optional interfaces */ @@ -251,7 +256,7 @@ EOD; printf(gettext("%sOptional interface %s description found: %s"), "\n", $io, $config['interfaces']['opt' . $io]['descr']); printf(gettext("%sEnter the Optional %s interface name or 'a' for auto-detection%s" . - "(or nothing if finished):%s"), "\n", $io, "\n", " "); + "(%s a or nothing if finished):%s"), "\n", $io, "\n", $ifsmallist, " "); $optif[$i] = chop(fgets($fp)); @@ -267,6 +272,7 @@ EOD; unset($optif[$i]); continue; } + $ifsmallist = trim(str_replace(" ", " ", str_replace($optif[$i], "", $ifsmallist))); } else { unset($optif[$i]); break; -- cgit v1.1