From bec14baeb0a1738e2b2548e64ba030866dc4a14a Mon Sep 17 00:00:00 2001 From: Sebastian Schmelzer Date: Wed, 17 Jun 2009 17:25:10 +0000 Subject: autobreak system description on pxe menu generation (#425) git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@2964 95ad53e4-c205-0410-b2fa-d234c58c8868 --- boot-env/OpenSLX/BootEnvironment/PXE.pm | 42 ++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'boot-env/OpenSLX/BootEnvironment/PXE.pm') diff --git a/boot-env/OpenSLX/BootEnvironment/PXE.pm b/boot-env/OpenSLX/BootEnvironment/PXE.pm index b8c5b9a6..35b0a3b8 100644 --- a/boot-env/OpenSLX/BootEnvironment/PXE.pm +++ b/boot-env/OpenSLX/BootEnvironment/PXE.pm @@ -117,8 +117,48 @@ sub writeBootloaderMenuFor ? "$menuMargin" : "0"; my $marginAsText = ' ' x $margin; + + my $menuWidth; + while ($pxeConfig =~ m{^\s*MENU WIDTH (\S+?)\s*$}gims) { + chomp($menuWidth = $1); + } + my $width + = defined $menuWidth + ? "$menuWidth" + : "80"; + $width = $width - 2* $margin + 2; + + my @atomicHelpText = split(/ /, $helpText); + my $lineCounter = 0; + + $helpText = ""; + + foreach my $word (@atomicHelpText){ + if ($lineCounter + length($word) + 1 < $width) { + $helpText .= "$word "; + $lineCounter += length($word) + 1; + } else { + my $nobreak = 1; + while ($nobreak == 1) { + my $pos = index($word,"-"); + $nobreak = 0; + if ($pos != -1) { + if ($lineCounter + $pos + 1 < $width) { + $helpText .= substr($word, 0, $pos+1); + $word = substr($word, $pos + 1, length($word)); + $nobreak = 1; + } + } + } + $helpText .= "\n$word "; + $lineCounter = length($word); + } + } + $helpText =~ s{^}{$marginAsText}gms; - $slxLabels .= "\tTEXT HELP\n$helpText\n\tENDTEXT\n"; + $slxLabels .= "\tTEXT HELP\n"; + $slxLabels .= "$helpText\n"; + $slxLabels .= "\tENDTEXT\n"; } } # now add the slx-labels (inline or appended) and write the config file -- cgit v1.2.3-55-g7522