MPW 3.3, alas requires System 7

This commit is contained in:
Elliot Nunn
2018-11-06 13:05:08 +08:00
parent 8829962159
commit 3218aa64d4
925 changed files with 251209 additions and 117914 deletions
+104 -254
View File
@@ -1,7 +1,7 @@
# CompareFiles -
# Compare two source files and show the differences
#
# Version 3.2.2
# Version 3.3
#
# Usage:
# CompareFiles [-9 | -LC -13 | -16 | -Portrait | -TwoPage | -b x y | -r t,l,b,r] oldFile newFile - open up the files and add menu
@@ -38,10 +38,11 @@
# Copyright Apple Computer, Inc. 1988 - 1992
# All rights reserved.
#
# Version 3.3 by Peter Potrebic with enhancements by Greg Branche
#
# Understanding the code…
#
# CompareFiles is actually a few scripts rolled into one. The action
# CompareFiles is actually a set of scripts. The action
# depends on the parameters. Here is what happens:
#
# CompareFiles oldFile newFile
@@ -50,281 +51,130 @@
# Create a script to execute on quit
# Move the windows around next to each other
# Create the Compare Menu
# Call itself with -n
# CompareFiles -n - show next change
# CompareFiles -old - Paste change from old into new
# CompareFiles -new - Paste change from new into old
# CompareFiles -q - execute quit script
# Call CompareFiles-NextChange
#
# CompareFiles•NextChange - show next change
# CompareFiles•Quit - cleans up
#
Set Exit 0
Set CaseSensitive 0
Set ErrorMessage "### CompareFiles - Incorrect order, or missing or illegal option"
Set Usage "# Usage - CompareFiles [-9 | -LC | -13 | -16 | -Portrait | -TwoPage | -b x y | -r t,l,b,r] oldFile newFile"
# Get rid of display spec if entering the script from a menu command
# This is to allow aliasing of "CompareFiles" to "CompareFiles screenSpec"
If (( ∂
"{1}" =~ /-b/ ∂
) ∂
&& ∂
( ∂
"{4}" =~ /-n/ ∂
|| "{4}" =~ /-old/ ∂
|| "{4}" =~ /-new/ ∂
|| "{4}" =~ /-q/ ∂
))
Shift 3 # Remove "-b x y" from command line parameters
Else If (( ∂
"{1}" =~ /-r/ ∂
) ∂
&& ∂
( ∂
"{3}" =~ /-n/ ∂
|| "{3}" =~ /-old/ ∂
|| "{3}" =~ /-new/ ∂
|| "{3}" =~ /-q/ ∂
))
Shift 2 # Remove "-r t,l,b,r" from command line parameters
Else If ∂
(( ∂
"{1}" =~ /-9/ ∂
|| "{1}" =~ /-LC/ ∂
|| "{1}" =~ /-13/ ∂
|| "{1}" =~ /-16/ ∂
|| "{1}" =~ /-Portrait/ ∂
|| "{1}" =~ /-SkyHawk/ ∂
|| "{1}" =~ /-TwoPage/ ∂
|| "{1}" =~ /-Kong/ ∂
) ∂
&& ∂
( ∂
"{2}" =~ /-n/ ∂
|| "{2}" =~ /-old/ ∂
|| "{2}" =~ /-new/ ∂
|| "{2}" =~ /-q/ ∂
))
Shift
End
if "{1}" == "-n" #### Find next change
Find ¡1 "{ShellDirectory}"Compare_File # get past current line
Set MyStatus {Status}
if {MyStatus} != 0
Exit {MyStatus}
end
Find \###\ "{ShellDirectory}"Compare_File
if {Status} != 0 # end of change log
Beep
Confirm "No more changes. Are you done comparing these files?"
if {Status} == 0
DeleteMenu Compare
Close -n "{ShellDirectory}Compare_File" ≥ dev:null
"{ShellDirectory}Compare_State" ≥ dev:null
Delete "{ShellDirectory}Compare_File" ≥ dev:null
Delete "{ShellDirectory}Compare_State" ≥ dev:null
end
else
Find !1 "{ShellDirectory}"Compare_File # select entire line
Mark -y § Current_Line "{ShellDirectory}"Compare_File
Execute "{ShellDirectory}Compare_File.§"
end
else if "{1}" == "-q" #### Quit
DeleteMenu Compare
Close -n "{ShellDirectory}Compare_File" ≥ dev:null
"{ShellDirectory}Compare_State" ≥ dev:null
Delete "{ShellDirectory}Compare_File" ≥ dev:null
Delete "{ShellDirectory}Compare_State" ≥ dev:null
else if "{1}" == "-old" #### Copy selection from old to new (target to active)
Find Current_Line "{ShellDirectory}"Compare_File # re-sync the two files
Set MyStatus {Status}
if {MyStatus} != 0
Exit {MyStatus}
end
Execute "{ShellDirectory}Compare_File.§"
Set selChars `Position -c "{Target}"` # see if we need to copy/paste or just cut
(Evaluate {selChars} =~ /([0-9]+)®1,([0-9]+)®2/ ) ∑ dev:null
if {®1} == {®2}
Cut § "{Active}"
else
Copy § "{Target}"
Mark -y § Compare_Mark "{Active}"
Paste § "{Active}"
Find Compare_Mark "{Active}"
Unmark Compare_Mark "{Active}"
end
else if "{1}" == "-new" #### Copy selection from new to old (active to target)
Find Current_Line "{ShellDirectory}"Compare_File # re-sync the two files
Set MyStatus {Status}
if {MyStatus} != 0
Exit {MyStatus}
end
Execute "{ShellDirectory}Compare_File.§"
Set selChars `Position -c "{Active}"` # see if we need to copy/paste or just cut
(Evaluate {selChars} =~ /([0-9]+)®1,([0-9]+)®2/ ) ∑ dev:null
if {®1} == {®2}
Cut § "{Target}"
else
Copy § "{Active}"
Mark -y § Compare_Mark "{Target}"
Paste § "{Target}"
Find Compare_Mark "{Target}"
Unmark Compare_Mark "{Target}"
end
else #### Compare the files and set up menu
Set Left 7 # default the left edge of the windows
if "{1}" == "-b" || "{1}" == "-B" # user specified size
if {#} != 5
echo "{ErrorMessage}"
echo "{Usage}"
Exit 1
end > Dev:StdErr
If "{CompareFilesTileRectangle}" == ""
Set Left 7 # default the left edge of the windows
If "{1}" =~ /-Kong/ || "{1}" =~ /-TwoPage/ # Apple Two-Page Monochrome Monitor
Set CompareFilesTileRectangle "0, 5, 749, 1148"
Set Bottom 750
Set Right 1138
Shift 1
else if "{1}" =~ /-SkyHawk/ || "{1}" =~ /-Portrait/ # Apple Macintosh Portrait Display
Set CompareFilesTileRectangle "0, 5, 749, 635"
Set Bottom 750
Set Right 626
Shift 1
else if "{1}" == "-16" # Apple 16" screen
Set CompareFilesTileRectangle "0, 5, 482, 828"
Set Bottom 483
Set Right 819
Shift 1
else if "{1}" =~ /-13/ # MacII screen
Set CompareFilesTileRectangle "0, 5, 344, 635"
Set Bottom 345
Set Right 626
Shift 1
else if "{1}" =~ /-LC/ # LC 12" RGB screen
Set CompareFilesTileRectangle "0, 3, 240, 510"
Set Bottom 241
Set Right 500
Shift 1
else if "{1}" == "-9" # Mac+ and MacSE screen
Set CompareFilesTileRectangle "0, 3, 198, 510"
Set Bottom 199
Set Right 500
Shift 1
else if "{1}" == "-b" || "{1}" == "-B" # user specified size
Evaluate Right = {2} - 5
Evaluate Bottom = {3} - 140
Set TileRectangle "0,5,{Bottom},{Right}"
Set CompareFilesTileRectangle "0,5,{Bottom},{Right}"
Evaluate Bottom = {Bottom} + 1
Evaluate Right = {Right} - 9
Shift 3
else if "{1}" == "-r"|| "{1}" == "-R" # custom user-specified rect
if {#} != 4
echo "{ErrorMessage}"
echo "{Usage}"
Exit 1
end > Dev:StdErr
else if "{1}" == "-r" || "{1}" == "-R" # custom user-specified rect
(Evaluate "{2}" =~ /(≈)®1,(≈)®2,(≈)®3,(≈)®4/) >Dev:Null
Set Top "{®1}"
Set Left "{®2}"
Set Bottom "{®3}"
Set Right "{®4}"
Evaluate Bottom = {Bottom} - 120
Set TileRectangle "{Top}, {Left}, {Bottom}, {Right}"
Set CompareFilesTileRectangle "{Top}, {Left}, {Bottom}, {Right}"
Evaluate Bottom = {Bottom} + 1
Evaluate Left = {Left} + 2
Evaluate Right = {Right} - {Left} - 2
Shift 2
else if "{1}" == "-9" # Mac+ and MacSE screen
if {#} != 3
echo "{ErrorMessage}"
echo "{Usage}"
Exit 1
end > Dev:StdErr
Set TileRectangle "0, 3, 198, 510"
Set Bottom 199
Set Right 500
Shift 1
else if "{1}" =~ /-LC/ # LC 12" RGB screen
if {#} != 3
echo "{ErrorMessage}"
echo "{Usage}"
Exit 1
end > Dev:StdErr
Set TileRectangle "0, 3, 240, 510"
Set Bottom 241
Set Right 500
Shift 1
else if "{1}" == "-13" # MacII screen
if {#} != 3
echo "{ErrorMessage}"
echo "{Usage}"
Exit 1
end > Dev:StdErr
Set TileRectangle "0, 5, 344, 635"
Set Bottom 345
Set Right 626
Shift 1
else if "{1}" == "-16" # Apple 16" screen
if {#} != 3
echo "{ErrorMessage}"
echo "{Usage}"
Exit 1
end > Dev:StdErr
Set TileRectangle "0, 5, 482, 828"
Set Bottom 483
Set Right 819
Shift 1
else if "{1}" =~ /-SkyHawk/ || "{1}" =~ /-Portrait/ # Apple Macintosh Portrait Display
if {#} != 3
echo "{ErrorMessage}"
echo "{Usage}"
Exit 1
end > Dev:StdErr
Set TileRectangle "0, 5, 749, 635"
Set Bottom 750
Set Right 626
Shift 1
else if "{1}" =~ /-Kong/ || "{1}" =~ /-TwoPage/ # Apple Two-Page Monochrome Monitor
if {#} != 3
echo "{ErrorMessage}"
echo "{Usage}"
Exit 1
end > Dev:StdErr
Set TileRectangle "0, 5, 749, 1148"
Set Bottom 750
Set Right 1138
Shift 1
else # MacII screen (default)
if {#} != 2
echo "{ErrorMessage}"
echo "{Usage}"
Exit 1
end > Dev:StdErr
Set TileRectangle "0, 5, 344, 635"
else # default
Set CompareFilesTileRectangle "0, 5, 344, 635"
Set Bottom 345
Set Right 626
end
Compare -b -m "{1}" "{2}" > "{ShellDirectory}"Compare_File
Set MyStatus {Status}
if {MyStatus} == 2 # Files don't match - set everything up
Set 1 "`Files -f -q "{1}"`"
Set 2 "`Files -f -q "{2}"`"
Set openFile1 0
Set openFile2 0
for i in `windows` # Remember if either file is already open
if "{i}" == "{1}"
Set openFile1 1
else if "{i}" == "{2}"
Set openFile2 1
end
end
if {openFile1} == 0
Open "{1}"
end
if {openFile2} == 0
Open "{2}"
end
Begin # Create end script
MoveWindow "{1}" # Get the current window states
SizeWindow "{1}"
MoveWindow "{2}"
SizeWindow "{2}"
if {openFile1} == 0
Echo Close ∂""{1}"∂"
end
if {openFile2} == 0
Echo Close ∂""{2}"∂"
end
End > "{ShellDirectory}"Compare_State
AddMenu Compare 'Find Next Change/ƒ' 'CompareFiles "-n"'
AddMenu Compare '(-1' ''
AddMenu Compare 'Copy Selection »»' 'CompareFiles "-old"'
AddMenu Compare '«« Copy Selection ' 'CompareFiles "-new"'
AddMenu Compare '(-2' ''
AddMenu Compare 'Done' 'CompareFiles "-q"'
Open "{ShellDirectory}"Compare_File
Find ∞ "{ShellDirectory}"Compare_File
TileWindows -v -r "{TileRectangle}" "{1}" "{2}"
MoveWindow {Left} {Bottom} "{ShellDirectory}"Compare_File
SizeWindow {Right} 75 "{ShellDirectory}"Compare_File
CompareFiles "-n"
else if {MyStatus} == 0
Echo "### Files are equal: {1} - {2}"
Delete -i "{ShellDirectory}Compare_File" ≥ dev:null
end > Dev:StdOut
End
if {#} ≠ 2
Echo "{ErrorMessage}"
Echo "{Usage}"
Exit 1
end >Dev:StdErr
Set CompareStatus 0
Compare -g 3 -b -m -t "{{1}}" "{{2}}" > "{ShellDirectory}"Compare_File || Set CompareStatus {Status}
if {CompareStatus} == 0
Echo "### files are equal (ignoring blanks): {1} - {2}"
Delete -i "{ShellDirectory}Compare_File" ≥ dev:null
else if {CompareStatus} == 2 # files dont match - set everything up
StreamEdit "{{ShellDirectory}}"Compare_File -o "{{ShellDirectory}}"Compare_File ∂
-e '/•[ ∂t]*File (≈)®1; Line (≈)®2; File (≈)®3; Line (≈)®4/ Change " Find "®2" "®1"; Find "®4" "®3'
Set NothingMatches 1
Search -s /•∂*∂*∂* Nothing seems to match ∂*∂*∂*/ "{{ShellDirectory}}"Compare_File ∑∑dev:null || Set NothingMatches 0
If {NothingMatches}
Echo "### nothing matches: {1} - {2}"
Delete -i "{{ShellDirectory}}"Compare_File
Exit 0
End
Set 1 "``Files -f -q "{{1}}"``" # get full pathnames
Set 2 "``Files -f -q "{{2}}"``"
Unset Close1 Close2 # remember if either file is already open
Set openWindows " ``Windows`` "
If "{{openWindows}}" !~ /≈ [∂']*"{{1}}"[∂']* ≈/; Open "{{1}}"; Set Close1 1; End
If "{{openWindows}}" !~ /≈ [∂']*"{{2}}"[∂']* ≈/; Open "{{2}}"; Set Close2 1; End
Begin # create end script
MoveWindow "{{1}}"; SizeWindow "{{1}}"
Quote Find • "{{1}}"
If {Close1}; Quote Close "{{1}}"; End
MoveWindow "{{2}}"; SizeWindow "{{2}}"
Quote Find • "{{2}}"
If {Close2}; Quote Close "{{2}}"; End
End > "{{ShellDirectory}}Compare_State"
TileWindows -v -r "{CompareFilesTileRectangle}" "{{1}}" "{{2}}"
Open -t "{{ShellDirectory}}"Compare_File
MoveWindow {Left} {Bottom} "{ShellDirectory}"Compare_File
SizeWindow {Right} 75 "{ShellDirectory}"Compare_File
Find ∞ "{{ShellDirectory}}"Compare_File
AddMenu Compare "Find Next Change/ƒ" "CompareFiles•NextChange"
AddMenu Compare "(-1" ""
AddMenu Compare "Copy Selection »»" "Catenate ∂"{{1}}∂".§ > ∂"{{2}}∂".§; #CompareFiles•NextChange"
AddMenu Compare "«« Copy Selection" "Catenate ∂"{{2}}∂".§ > ∂"{{1}}∂".§; #CompareFiles•NextChange"
AddMenu Compare "(-2" ""
AddMenu Compare "Done" "CompareFiles•Quit"
CompareFiles•NextChange
Exit "{MyStatus}"
end
Exit {CompareStatus}