Add a preference for the PHP binary path for syntax highlighting.
authorRobert Sesek <rsesek@bluestatic.org>
Sat, 1 Jan 2022 18:07:23 +0000 (13:07 -0500)
committerRobert Sesek <rsesek@bluestatic.org>
Sat, 1 Jan 2022 18:08:35 +0000 (13:08 -0500)
Other attempts like trying to find the executable via running a command
in the user shell are flaky: not all users will have $PATH set up in
non-interactive rc files, for example.

CHANGES
Source/AppDelegate.m
Source/BSSourceView.m
Source/PreferenceNames.h
Source/PreferenceNames.m
en.lproj/Preferences.xib

diff --git a/CHANGES b/CHANGES
index a3f4e481f755c0a8f5b8308b16f21096ace38250..9a190d7030c138b8c9ee57ff61946e053ce3f228 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,7 @@ MacGDBp                                                               CHANGE LOG
 2.0.4
 #####################
 - Fix: #266  Plain text fallback source display does not paint the ruler.
+- New: #266  Add preference for PHP binary path for syntax highlighting.
 
 
 2.0.3
index f059e2cee42caf4c7fc9bb03b21b4a89bf944e3d..cfcad38b269d6fbee3cf77d269b0dee68a022ff0 100644 (file)
@@ -42,6 +42,7 @@ static NSString* const kAppcastUnstable = @"appcast-unstable.xml";
       kPrefPort                     : @9000,
       kPrefInspectorWindowVisible   : @YES,
       kPrefPathReplacements         : [NSMutableArray array],
+      kPrefPhpPath                  : @"/usr/bin/php",
 #if USE_APP_SANDBOX
       kPrefFileAccessBookmarks      : [NSMutableDictionary dictionary],
 #endif
index fbd2766001dcc18dd4300a762fab0372d51efdec..d263060076359c52d766a57183f7cbbdb498759e 100644 (file)
@@ -16,6 +16,7 @@
 
 #import "BSSourceView.h"
 
+#import "PreferenceNames.h"
 #import "BSLineNumberRulerView.h"
 #import "BSSourceViewTextView.h"
 
@@ -200,7 +201,14 @@ NSString* ColorHEXStringINIDirective(NSString* directive, NSColor* color) {
     NSPipe* errPipe = [NSPipe pipe];
     NSTask* task = [[NSTask alloc] init];
 
-    [task setLaunchPath:@"/usr/bin/php"]; // This is the path to the default Leopard PHP executable
+    NSString* phpPath = [[NSUserDefaults standardUserDefaults] stringForKey:kPrefPhpPath];
+    if (!phpPath) {
+      // This is the path to the default Leopard PHP executable, but it will not
+      // exist on future macOS versions.
+      phpPath = @"/usr/bin/php";
+    }
+
+    [task setLaunchPath:phpPath];
     [task setArguments:@[
       @"--syntax-highlight",
       @"--define", ColorHEXStringINIDirective(@"highlight.string", [NSColor systemRedColor]),
@@ -214,7 +222,8 @@ NSString* ColorHEXStringINIDirective(NSString* directive, NSColor* color) {
     [task setTerminationHandler:^(NSTask* taskBlock) {
       if (task.terminationStatus != 0) {
         NSLog(@"Failed to highlight PHP file %@. Termination status=%d. stderr: %@",
-              filePath, taskBlock.terminationStatus, [[errPipe fileHandleForReading] readDataToEndOfFile]);
+              filePath, taskBlock.terminationStatus,
+              [[NSString alloc] initWithData:[[errPipe fileHandleForReading] readDataToEndOfFile] encoding:NSUTF8StringEncoding]);
       }
     }];
     [task launch];
index fa75db10557b27fd01238e54874e0ba7ec06eeff..b80900b268b9f1be68dc5941f2cd6bda5db68c1f 100644 (file)
@@ -25,6 +25,9 @@ extern NSString* const kPrefInspectorWindowVisible;
 // NSMutableArray of path replacements.
 extern NSString* const kPrefPathReplacements;
 
+// NSString to the path to the PHP binary used for syntax highlighting.
+extern NSString* const kPrefPhpPath;
+
 #if USE_APP_SANDBOX
 // NSMutableDictionary of NSString paths to NSData file access bookmarks.
 extern NSString* const kPrefFileAccessBookmarks;
index d5ded4489404baab8498890bb0b2a28e46b4bb6e..d6e9ec4d0e711fe92e54af2f3c8f63e585ae3136 100644 (file)
@@ -22,6 +22,8 @@ NSString* const kPrefInspectorWindowVisible = @"InspectorWindowVisible";
 
 NSString* const kPrefPathReplacements = @"PathReplacements";
 
+NSString* const kPrefPhpPath = @"PhpPath";
+
 #if USE_APP_SANDBOX
 NSString* const kPrefFileAccessBookmarks = @"FileAccessBookmarks";
 
index f1832b354f0e628bd18cbd3ffedefe0e368d208f..ed65e20c1562e2f55aa0cd994a3d98a1abf54fa6 100644 (file)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14868" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="19529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14868"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19529"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -25,7 +25,7 @@
             <windowStyleMask key="styleMask" titled="YES" closable="YES"/>
             <windowPositionMask key="initialPositionMask" leftStrut="YES" bottomStrut="YES"/>
             <rect key="contentRect" x="196" y="388" width="420" height="120"/>
-            <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
+            <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>
             <view key="contentView" id="2">
                 <rect key="frame" x="0.0" y="0.0" width="420" height="120"/>
                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                     <toolbarItem implicitItemIdentifier="NSToolbarSpaceItem" id="25"/>
                     <toolbarItem implicitItemIdentifier="NSToolbarFlexibleSpaceItem" id="26"/>
                     <toolbarItem implicitItemIdentifier="6AEED900-187C-4FE3-B185-35C4C2105744" label="General" paletteLabel="General" tag="-1" image="NSPreferencesGeneral" autovalidates="NO" id="43">
+                        <size key="minSize" width="22" height="22"/>
+                        <size key="maxSize" width="22" height="22"/>
                         <connections>
                             <action selector="showGeneral:" target="-2" id="49"/>
                         </connections>
                     </toolbarItem>
                     <toolbarItem implicitItemIdentifier="9B9A0426-715E-44F5-A7FC-FA2874232849" label="File Access" paletteLabel="File Access" tag="-1" image="NSFolder" id="e1C-OK-KSi">
+                        <size key="minSize" width="22" height="22"/>
+                        <size key="maxSize" width="22" height="22"/>
                         <connections>
                             <action selector="showFileAccess:" target="-2" id="g2h-j3-gGu"/>
                         </connections>
                     </toolbarItem>
                     <toolbarItem implicitItemIdentifier="7E7339A3-79C3-4087-B2F7-2479CFD10818" label="Remote Paths" paletteLabel="Remote Paths" tag="-1" image="NSNetwork" autovalidates="NO" id="50">
+                        <size key="minSize" width="22" height="22"/>
+                        <size key="maxSize" width="22" height="22"/>
                         <connections>
                             <action selector="showPaths:" target="-2" id="51"/>
                         </connections>
         </window>
         <userDefaultsController representsSharedInstance="YES" id="13"/>
         <customView id="29" userLabel="GeneralPreferences">
-            <rect key="frame" x="0.0" y="0.0" width="421" height="152"/>
+            <rect key="frame" x="0.0" y="0.0" width="421" height="181"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
             <subviews>
                 <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="93">
-                    <rect key="frame" x="15" y="115" width="146" height="17"/>
+                    <rect key="frame" x="15" y="144" width="146" height="17"/>
                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Debugger Behavior:" id="94">
                         <font key="font" metaFont="system"/>
@@ -78,7 +84,7 @@
                     </textFieldCell>
                 </textField>
                 <button toolTip="If enabled, MacGDBp will automatically step into the first line of code when the debugger is attached." fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="91">
-                    <rect key="frame" x="164" y="113" width="216" height="18"/>
+                    <rect key="frame" x="164" y="142" width="216" height="18"/>
                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                     <buttonCell key="cell" type="check" title="Break on first line of execution" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="92">
                         <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@@ -89,7 +95,7 @@
                     </connections>
                 </button>
                 <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="5zF-CC-p0i">
-                    <rect key="frame" x="15" y="90" width="146" height="17"/>
+                    <rect key="frame" x="15" y="119" width="146" height="17"/>
                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Beta Updates:" id="kFb-9R-eo2">
                         <font key="font" metaFont="system"/>
                     </textFieldCell>
                 </textField>
                 <button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cnO-5M-q8v">
-                    <rect key="frame" x="164" y="89" width="167" height="18"/>
+                    <rect key="frame" x="164" y="118" width="167" height="18"/>
                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                     <buttonCell key="cell" type="check" title="Update to beta versions" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="5c6-mr-EWk">
                         <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
                     </connections>
                 </button>
                 <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="36">
-                    <rect key="frame" x="18" y="47" width="387" height="28"/>
+                    <rect key="frame" x="17" y="47" width="387" height="28"/>
                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                     <textFieldCell key="cell" sendsActionOnEndEditing="YES" title="You must close and reopen MacGDBp before these preference values take effect." id="37">
                         <font key="font" metaFont="smallSystem"/>
                     </textFieldCell>
                 </textField>
                 <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="33">
-                    <rect key="frame" x="169" y="20" width="60" height="22"/>
+                    <rect key="frame" x="168" y="20" width="60" height="22"/>
                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="40">
                         <numberFormatter key="formatter" formatterBehavior="default10_4" usesGroupingSeparator="NO" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="42" id="fAx-s6-Oqh"/>
                     </connections>
                 </textField>
                 <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="32">
-                    <rect key="frame" x="78" y="22" width="86" height="17"/>
+                    <rect key="frame" x="77" y="22" width="86" height="17"/>
                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Xdebug Port:" id="41">
                         <font key="font" metaFont="system"/>
                         <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                     </textFieldCell>
                 </textField>
+                <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="dd5-eP-mLt">
+                    <rect key="frame" x="166" y="92" width="235" height="21"/>
+                    <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
+                    <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" id="S1Q-B0-iy2">
+                        <font key="font" metaFont="system"/>
+                        <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                        <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                    </textFieldCell>
+                    <connections>
+                        <binding destination="13" name="value" keyPath="values.PhpPath" id="nz5-De-8FQ"/>
+                    </connections>
+                </textField>
+                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="shR-tP-IGm">
+                    <rect key="frame" x="54" y="95" width="107" height="16"/>
+                    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+                    <textFieldCell key="cell" lineBreakMode="clipping" alignment="right" title="PHP Binary Path:" id="Inm-aY-Aua">
+                        <font key="font" metaFont="system"/>
+                        <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                        <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                    </textFieldCell>
+                </textField>
             </subviews>
-            <point key="canvasLocation" x="-141.5" y="-422"/>
+            <point key="canvasLocation" x="-141.5" y="-617.5"/>
         </customView>
         <customView id="53" userLabel="PathsPreferences">
             <rect key="frame" x="0.0" y="0.0" width="711" height="213"/>
                 <scrollView fixedFrame="YES" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="55">
                     <rect key="frame" x="-1" y="20" width="712" height="193"/>
                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
-                    <clipView key="contentView" ambiguous="YES" id="egR-Mj-j4E">
-                        <rect key="frame" x="1" y="0.0" width="710" height="192"/>
+                    <clipView key="contentView" id="egR-Mj-j4E">
+                        <rect key="frame" x="1" y="1" width="710" height="191"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" autosaveColumns="NO" headerView="59" id="58">
-                                <rect key="frame" x="0.0" y="0.0" width="710" height="169"/>
-                                <autoresizingMask key="autoresizingMask"/>
+                                <rect key="frame" x="0.0" y="0.0" width="710" height="168"/>
+                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                 <size key="intercellSpacing" width="3" height="2"/>
                                 <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
                                 <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
                                 <tableColumns>
                                     <tableColumn width="349.5" minWidth="40" maxWidth="1000" id="61">
                                         <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Local">
-                                            <font key="font" metaFont="smallSystem"/>
                                             <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
                                             <color key="backgroundColor" white="0.33333299" alpha="1" colorSpace="calibratedWhite"/>
                                         </tableHeaderCell>
                                             <binding destination="78" name="value" keyPath="arrangedObjects.local" id="82"/>
                                         </connections>
                                     </tableColumn>
-                                    <tableColumn width="354.5" minWidth="40" maxWidth="1000" id="60">
+                                    <tableColumn width="345.5" minWidth="40" maxWidth="1000" id="60">
                                         <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Remote">
-                                            <font key="font" metaFont="smallSystem"/>
                                             <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
                                             <color key="backgroundColor" white="0.33333299" alpha="1" colorSpace="calibratedWhite"/>
                                         </tableHeaderCell>
                         <rect key="frame" x="411" y="17" width="15" height="160"/>
                         <autoresizingMask key="autoresizingMask"/>
                     </scroller>
-                    <tableHeaderView key="headerView" id="59">
+                    <tableHeaderView key="headerView" wantsLayer="YES" id="59">
                         <rect key="frame" x="0.0" y="0.0" width="710" height="23"/>
                         <autoresizingMask key="autoresizingMask"/>
                     </tableHeaderView>
             <point key="canvasLocation" x="151.5" y="-194.5"/>
         </customView>
         <dictionaryController objectClassName="_NSDictionaryControllerKeyValuePair" id="PYc-SP-Fvw" userLabel="File Access Controller">
+            <classReference key="objectClass" className="_NSDictionaryControllerKeyValuePair"/>
             <connections>
                 <binding destination="13" name="contentDictionary" keyPath="values.FileAccessBookmarks" id="DnO-2q-xFf"/>
             </connections>
                 <scrollView fixedFrame="YES" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="v93-oV-uce">
                     <rect key="frame" x="-1" y="20" width="429" height="193"/>
                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
-                    <clipView key="contentView" ambiguous="YES" id="L7V-Zd-iEr">
-                        <rect key="frame" x="1" y="0.0" width="427" height="192"/>
+                    <clipView key="contentView" id="L7V-Zd-iEr">
+                        <rect key="frame" x="1" y="1" width="427" height="191"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" autosaveColumns="NO" headerView="7XQ-Y6-gfo" id="s4m-Zv-l8Z">
-                                <rect key="frame" x="0.0" y="0.0" width="427" height="167"/>
-                                <autoresizingMask key="autoresizingMask"/>
+                                <rect key="frame" x="0.0" y="0.0" width="427" height="166"/>
+                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                 <size key="intercellSpacing" width="3" height="2"/>
                                 <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
                                 <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
                                 <tableColumns>
-                                    <tableColumn editable="NO" width="423" minWidth="40" maxWidth="1000" id="tV5-Ih-Xw6">
+                                    <tableColumn editable="NO" width="394" minWidth="40" maxWidth="1000" id="tV5-Ih-Xw6">
                                         <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Path">
-                                            <font key="font" metaFont="smallSystem"/>
                                             <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
                                             <color key="backgroundColor" white="0.33333299" alpha="1" colorSpace="calibratedWhite"/>
                                         </tableHeaderCell>
                         <rect key="frame" x="411" y="17" width="15" height="160"/>
                         <autoresizingMask key="autoresizingMask"/>
                     </scroller>
-                    <tableHeaderView key="headerView" id="7XQ-Y6-gfo">
+                    <tableHeaderView key="headerView" wantsLayer="YES" id="7XQ-Y6-gfo">
                         <rect key="frame" x="0.0" y="0.0" width="427" height="25"/>
                         <autoresizingMask key="autoresizingMask"/>
                     </tableHeaderView>
         </customView>
     </objects>
     <resources>
-        <image name="NSAddTemplate" width="11" height="11"/>
+        <image name="NSAddTemplate" width="14" height="13"/>
         <image name="NSFolder" width="32" height="32"/>
         <image name="NSNetwork" width="32" height="32"/>
         <image name="NSPreferencesGeneral" width="32" height="32"/>
-        <image name="NSRemoveTemplate" width="11" height="11"/>
+        <image name="NSRemoveTemplate" width="14" height="4"/>
     </resources>
 </document>