From: Ben Soares Date: Fri, 19 May 2023 15:02:48 +0000 (+0100) Subject: JAL-629 Updated launching scripts to 1) not insert '-open' arg and 2) tell Jalview... X-Git-Tag: Release_2_11_4_0~314 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=810d16f4bf7bd2db5c38d66ff0f529e4f769102b;p=jalview.git JAL-629 Updated launching scripts to 1) not insert '-open' arg and 2) tell Jalview the CONSOLEWIDTH. NEEDS TESTING IN Cygwin, WSL, Powershell 5, Powershell 7 --- diff --git a/utils/eclipse/jalview b/utils/eclipse/jalview index ccb1d75..3c986a1 100755 --- a/utils/eclipse/jalview +++ b/utils/eclipse/jalview @@ -1,3 +1,11 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash -java -cp "./bin/main:./j11lib/*:./resources:./help" jalview.bin.Launcher "${@}" +if command -v tput 2>&1 >/dev/null; then + COLUMNS=$(tput cols) 2>/dev/null +elif command -v stty 2>&1 >/dev/null; then + COLUMNS=$(stty size | cut -d" " -f2) 2>/dev/null +elif command -v resize 2>&1 >/dev/null; then + COLUMNS=$(resize -u | grep COLUMNS= | sed -e 's/.*=//;s/;//') 2>/dev/null +fi + +java "-DCONSOLEWIDTH=${COLUMNS}" -cp "./bin/main:./j11lib/*:./resources:./help" jalview.bin.Launcher "${@}" diff --git a/utils/eclipse/launcher b/utils/eclipse/launcher deleted file mode 100755 index ccb1d75..0000000 --- a/utils/eclipse/launcher +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env sh - -java -cp "./bin/main:./j11lib/*:./resources:./help" jalview.bin.Launcher "${@}" diff --git a/utils/getdown/bin/jalview.ps1 b/utils/getdown/bin/jalview.ps1 index 7ae9a57..a5c0354 100755 --- a/utils/getdown/bin/jalview.ps1 +++ b/utils/getdown/bin/jalview.ps1 @@ -57,12 +57,6 @@ $CMDPATH = ( Get-Item $MyInvocation.MyCommand.Path ) $SCRIPTPATH = Readlink-f -Link $CMDPATH $DIR = Split-Path -Path $SCRIPTPATH -Parent -# set the "-open" parameter if myArg1 is non-zero-length, and not "open" or starts with a "-" -$OPEN = "" -if ( $myArg1.length -gt 0 -and ( -not $myArg1.StartsWith("-") ) -and $myArg1 -cne "open" ) { - $OPEN = "-open" -} - $APPDIR = If ( ( Split-Path -Path $DIR -Leaf ) -eq "bin" ) { Split-Path -Path $DIR -Parent } Else { $DIR } $JAVAEXE = If ( $myIsWindows ) { "java.exe" } Else { "java" } $JAVA = Join-Path -Path $APPDIR -ChildPath ( "jre/" + $( If ( $myIsMacOS ) { "Contents/Home/" } Else { "" } ) + "bin/${JAVAEXE}" ) @@ -81,7 +75,10 @@ if ( -not ( Test-Path -Path "${JAVA}" ) ) { $CLASSPATH = ( Select-String -Path "${GETDOWNTXT}" -AllMatches -Pattern "code\s*=\s*(.*)$" | foreach { Join-Path -Path $APPDIR -ChildPath $($_.Matches.Groups[1].Value ) } ) -join $( If ( $myIsWindows ) { ";" } Else { ":" } ) +# get console width +$CONSOLEWIDTH = $Host.UI.RawUI.WindowSize.Width + # quote the args and the command (in case of spaces) with escape chars (`) and precede with & to indicate command not string $myArgsString = '"' + $($myArgs -join '" "') + '"' -Invoke-Expression -Command "& `"${JAVA}`" -cp `"${CLASSPATH}`" jalview.bin.Launcher ${OPEN} ${myArgsString}" +Invoke-Expression -Command "& `"${JAVA}`" `"-DCONSOLEWIDTH=${CONSOLEWIDTH}`" -cp `"${CLASSPATH}`" jalview.bin.Launcher ${myArgsString}" diff --git a/utils/getdown/bin/jalview.sh b/utils/getdown/bin/jalview.sh index 112c3e6..912f1ad 100755 --- a/utils/getdown/bin/jalview.sh +++ b/utils/getdown/bin/jalview.sh @@ -77,7 +77,7 @@ fi # WINDOWS ONLY (Cygwin or WSL) # change paths for Cygwin or Windows Subsystem for Linux (WSL) -if [ "${ISMACOS}" != 1 ]; then # macos doesn't like uname -o, best to avoid +if [ "${ISMACOS}" != 1 ]; then # older macos doesn't like uname -o, best to avoid if [ "$(uname -o)" = "Cygwin" ]; then # CYGWIN echo "When using relative paths in args within Cygwin, please start with './' or '../'" >&2 @@ -115,18 +115,20 @@ if [ "${ISMACOS}" != 1 ]; then # macos doesn't like uname -o, best to avoid fi fi +# get console width -- three ways to try, just in case +if command -v tput 2>&1 >/dev/null; then + COLUMNS=$(tput cols) 2>/dev/null +elif command -v stty 2>&1 >/dev/null; then + COLUMNS=$(stty size | cut -d" " -f2) 2>/dev/null +elif command -v resize 2>&1 >/dev/null; then + COLUMNS=$(resize -u | grep COLUMNS= | sed -e 's/.*=//;s/;//') 2>/dev/null +fi +JVMARGS=( "${JVMARGS[@]}" "-DCONSOLEWIDTH=${COLUMNS}" ) + # Is there a bundled Java? If not just try one in the PATH (do need .exe in WSL) if [ \! -e "${JAVA}" ]; then JAVA=$SYSJAVA echo "Cannot find bundled java, using system ${JAVA} and hoping for the best!" >&2 fi -# check to see if $1 is set and is not start of other cli args -OPEN="" -if [ -n "${ARG1}" -a "${ARG1}" = "${ARG1#-}" -a "${ARG1}" != "open" ]; then - # first argument exists and does not start with a "-" and is not "open" - OPEN="-open" -fi - -# don't quote $OPEN (don't want it accidentally mistaken as an empty string arg!) -"${JAVA}" "${JVMARGS[@]}" -cp "${CLASSPATH}" jalview.bin.Launcher ${OPEN} "${ARGS[@]}" +"${JAVA}" "${JVMARGS[@]}" -cp "${CLASSPATH}" jalview.bin.Launcher "${ARGS[@]}"