Revision: 12590
          http://sourceforge.net/p/skim-app/code/12590
Author:   hofman
Date:     2021-11-30 23:33:56 +0000 (Tue, 30 Nov 2021)
Log Message:
-----------
Set variables to partial AppleScript code conditionally on arguments rather 
than have different code paths in if blocks

Modified Paths:
--------------
    trunk/displayline

Modified: trunk/displayline
===================================================================
--- trunk/displayline   2021-11-30 15:35:39 UTC (rev 12589)
+++ trunk/displayline   2021-11-30 23:33:56 UTC (rev 12590)
@@ -15,19 +15,19 @@
 fi
 
 # get arguments
-revert=false
-bar=false
-activate=true
+revert="false"
+showing_bar=""
+activate="activate"
 zerobased=
 while [[ "${1:0:1}" == "-" ]]; do
   if [[ "$1" == "-r" || "$1" == "-revert" ]]; then
-    revert=true
+    revert="true"
   elif [[ "$1" == "-b" || "$1" == "-readingbar" ]]; then
-    bar=true
+    showing_bar="with showing reading bar"
   elif [[ "$1" == "-g" || "$1" == "-background" ]]; then
-    activate=false
+    activate=""
   elif [[ "$1" == "-z" || "$1" == "-zerobased" ]]; then
-    zerobased=1
+    zerobased="1"
   fi
   shift
 done
@@ -40,11 +40,12 @@
 [[ "${file:0:1}" == "/" ]] || file="${PWD}/${file}"
 [[ "${src}" == "" || "${src:0:1}" == "/" ]] || src="${PWD}/${src}"
 
-[[ -z $zerobased ]] || (( line+=1 ))
+[[ "${src}" == "" ]] && from_source="" || from_source="from POSIX file 
\"$src\""
 
+[[ -z ${zerobased} ]] || (( line+=1 ))
+
 # run AppleScript
 /usr/bin/osascript << EOF
-  set theLine to $line as integer
   set theFile to POSIX file "$file"
   tell application "Skim"
     if $revert then
@@ -55,12 +56,7 @@
       end try
     end if
     open theFile
-    if "$src" is "" then
-      tell front document to go to TeX line theLine showing reading bar $bar
-    else
-      set theSource to POSIX file "$src"
-      tell front document to go to TeX line theLine from theSource showing 
reading bar $bar
-    end if
-  if $activate then activate
+    tell front document to go to TeX line $line $from_source $showing_bar
+    $activate
   end tell
 EOF

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to