Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions CommentWrapper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
objects = {

/* Begin PBXBuildFile section */
474458A2264B520000B30C22 /* SettingsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 474458A1264B520000B30C22 /* SettingsViewController.xib */; };
474458A4264B54E000B30C22 /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 474458A3264B54E000B30C22 /* SettingsViewController.swift */; };
474458A6264B64EA00B30C22 /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 474458A5264B64EA00B30C22 /* Settings.swift */; };
474458A7264B653700B30C22 /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 474458A5264B64EA00B30C22 /* Settings.swift */; };
474458A8264B653700B30C22 /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 474458A5264B64EA00B30C22 /* Settings.swift */; };
670349A92095A7C1002A1E30 /* ExternalLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 670349A82095A7C1002A1E30 /* ExternalLinks.swift */; };
6720E7E2208B7E1200D07850 /* CommentWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67A3C0A32078260E00E93876 /* CommentWrapper.swift */; };
6720E7E3208B7E1700D07850 /* CommentUnwrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67A3C0B6207A89F700E93876 /* CommentUnwrapper.swift */; };
Expand Down Expand Up @@ -96,6 +101,9 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
474458A1264B520000B30C22 /* SettingsViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SettingsViewController.xib; sourceTree = "<group>"; };
474458A3264B54E000B30C22 /* SettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = "<group>"; };
474458A5264B64EA00B30C22 /* Settings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Settings.swift; sourceTree = "<group>"; };
670349A82095A7C1002A1E30 /* ExternalLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalLinks.swift; sourceTree = "<group>"; };
6720E7E4208B827C00D07850 /* ContentBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentBuilder.swift; sourceTree = "<group>"; };
6720E7E6208B8B9600D07850 /* AttributedTextViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttributedTextViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -165,6 +173,15 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
4744589E264B509100B30C22 /* Settings */ = {
isa = PBXGroup;
children = (
474458A1264B520000B30C22 /* SettingsViewController.xib */,
474458A3264B54E000B30C22 /* SettingsViewController.swift */,
);
path = Settings;
sourceTree = "<group>";
};
6720E7EA208B8C7B00D07850 /* Content */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -227,6 +244,7 @@
6720E7E7208B8B9600D07850 /* AttributedTextViewController.xib */,
672771C8208B4B9D00256933 /* Installation Instructions */,
672771C9208B4BE900256933 /* About */,
4744589E264B509100B30C22 /* Settings */,
67A3C073207822B000E93876 /* Assets.xcassets */,
67A3C078207822B100E93876 /* Info.plist */,
67A3C079207822B100E93876 /* CommentWrapper.entitlements */,
Expand Down Expand Up @@ -277,6 +295,7 @@
children = (
67A3C0B0207A886700E93876 /* Character+Extensions.swift */,
67A3C0A7207A847900E93876 /* String+Extensions.swift */,
474458A5264B64EA00B30C22 /* Settings.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -408,6 +427,7 @@
buildActionMask = 2147483647;
files = (
6720E7E9208B8B9600D07850 /* AttributedTextViewController.xib in Resources */,
474458A2264B520000B30C22 /* SettingsViewController.xib in Resources */,
67A3C074207822B000E93876 /* Assets.xcassets in Resources */,
672771C7208B4B8700256933 /* InstallationInstructionsViewController.xib in Resources */,
67A3C077207822B000E93876 /* Main.storyboard in Resources */,
Expand Down Expand Up @@ -517,7 +537,9 @@
6720E7EE208B8D7400D07850 /* InstructionsContent.swift in Sources */,
6720E7E8208B8B9600D07850 /* AttributedTextViewController.swift in Sources */,
67A3C070207822B000E93876 /* AppDelegate.swift in Sources */,
474458A4264B54E000B30C22 /* SettingsViewController.swift in Sources */,
6720E7EC208B8C9000D07850 /* IntroductionContent.swift in Sources */,
474458A6264B64EA00B30C22 /* Settings.swift in Sources */,
672771CC208B4BFB00256933 /* AboutViewController.swift in Sources */,
6720E7E2208B7E1200D07850 /* CommentWrapper.swift in Sources */,
6720E7E5208B827C00D07850 /* ContentBuilder.swift in Sources */,
Expand All @@ -532,6 +554,7 @@
files = (
678F0EE020853DB300D94D9D /* ItemizerTests.swift in Sources */,
67A3C0AF207A855C00E93876 /* String+Extensions.swift in Sources */,
474458A8264B653700B30C22 /* Settings.swift in Sources */,
67A3C0B3207A88E800E93876 /* Character+ExtensionsTests.swift in Sources */,
67A3C0BE207A8D3E00E93876 /* CommentUnwrapperTests.swift in Sources */,
67A3C0BA207A8AE600E93876 /* Itemizer.swift in Sources */,
Expand All @@ -551,6 +574,7 @@
files = (
67A3C0B8207A89F700E93876 /* CommentUnwrapper.swift in Sources */,
67A3C0BB207A8AE600E93876 /* Itemizer.swift in Sources */,
474458A7264B653700B30C22 /* Settings.swift in Sources */,
67A3C0A8207A847900E93876 /* String+Extensions.swift in Sources */,
67A3C097207822DD00E93876 /* SourceEditorExtension.swift in Sources */,
67A3C0A42078260E00E93876 /* CommentWrapper.swift in Sources */,
Expand Down
25 changes: 12 additions & 13 deletions CommentWrapper/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="18122"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
<capability name="system font weights other than Regular or Bold" minToolsVersion="7.0"/>
</dependencies>
<scenes>
<!--Application-->
Expand Down Expand Up @@ -62,7 +60,7 @@
<menu key="submenu" title="View" id="HyV-fh-RgO">
<items>
<menuItem title="Enter Full Screen" keyEquivalent="f" id="4J7-dP-txa">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
<modifierMask key="keyEquivalentModifierMask" shift="YES" control="YES" command="YES"/>
<connections>
<action selector="toggleFullScreen:" target="Ady-hI-5gd" id="dU3-MA-1Rq"/>
</connections>
Expand Down Expand Up @@ -136,7 +134,7 @@
<scene sceneID="R2V-B0-nI4">
<objects>
<windowController id="B8D-0N-5wS" sceneMemberID="viewController">
<window key="window" title="Comment Wrapper" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
<window key="window" title="Comment Wrapper" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="480" height="270"/>
Expand Down Expand Up @@ -170,28 +168,29 @@
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="Icon" id="sPT-Sm-hye"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="KWp-l9-yTq">
<rect key="frame" x="309" y="403" width="123" height="17"/>
<rect key="frame" x="309" y="404" width="123" height="16"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Comment Wrapper" id="qZg-9S-v48">
<font key="font" metaFont="systemSemibold" size="13"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="dbu-6u-I9e">
<rect key="frame" x="20" y="20" width="700" height="322"/>
<rect key="frame" x="20" y="20" width="700" height="324"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="300" id="QED-Z9-m0l"/>
<constraint firstAttribute="width" constant="700" id="dPd-qn-DGX"/>
</constraints>
</customView>
<segmentedControl verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="c85-CW-ted">
<rect key="frame" x="251" y="360" width="238" height="24"/>
<rect key="frame" x="184" y="362" width="372" height="23"/>
<segmentedCell key="cell" borderStyle="border" alignment="left" segmentDistribution="fillEqually" style="capsule" trackingMode="selectOne" id="Gto-Cc-orR">
<font key="font" metaFont="system"/>
<segments>
<segment label="What" width="77" selected="YES"/>
<segment label="How" width="77" tag="1"/>
<segment label="Who" width="76"/>
<segment label="What" width="88" selected="YES"/>
<segment label="How" width="88" tag="1"/>
<segment label="Who" width="86"/>
<segment label="Settings"/>
</segments>
</segmentedCell>
<connections>
Expand Down Expand Up @@ -219,7 +218,7 @@
</viewController>
<customObject id="rPt-NT-nkU" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="128.5" y="808.5"/>
<point key="canvasLocation" x="128" y="808.5"/>
</scene>
</scenes>
<resources>
Expand Down
12 changes: 8 additions & 4 deletions CommentWrapper/CommentWrapper.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>group.CommentWrapper</string>
</array>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
53 changes: 53 additions & 0 deletions CommentWrapper/Settings/SettingsViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// SettingsViewController.swift
// Comment Wrapper Host
//
// Created by Peter Schorn on 5/11/21.
// Copyright © 2021 Steve Barnegren. All rights reserved.
//

import AppKit

class SettingsViewController: NSViewController {

@IBOutlet weak var lineLengthPopupButton: NSPopUpButton!

override func viewDidLoad() {
super.viewDidLoad()

for option in LineLengthOption.allCases {
self.lineLengthPopupButton.addItem(withTitle: option.rawValue)
}

switch Settings.lineLength {
case .absolute:
self.lineLengthPopupButton.selectItem(at: 1)
default /* .excludingLeadingIndentation */:
self.lineLengthPopupButton.selectItem(at: 0)
}


}


@IBAction func selectedLineLengthPopupButton(
_ popupButton: NSPopUpButton
) {
let lineLength: LineLengthOption
let index = popupButton.indexOfSelectedItem
switch index {
case 0:
lineLength = .excludingLeadingIndentation
case 1:
lineLength = .absolute
default:
print("unexpected index for popup button: \(index)")
return
}

Settings.lineLength = lineLength
print("set line length to \(lineLength)")

}

}
63 changes: 63 additions & 0 deletions CommentWrapper/Settings/SettingsViewController.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="18122" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="18122"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="SettingsViewController" customModule="Comment_Wrapper" customModuleProvider="target">
<connections>
<outlet property="lineLengthPopupButton" destination="lXE-Ls-cyz" id="NQe-CD-vfJ"/>
<outlet property="view" destination="c22-O7-iKe" id="SRg-4L-UGb"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="c22-O7-iKe">
<rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="jcs-BG-ih5">
<rect key="frame" x="189" y="128" width="75" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Line Length" id="7F8-Cc-4hA">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lXE-Ls-cyz">
<rect key="frame" x="269" y="122" width="39" height="25"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="4Fq-6z-OFK">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="2v2-Wd-hWX"/>
</popUpButtonCell>
<connections>
<action selector="selectedLineLengthPopupButton:" target="-2" id="qcD-42-gHA"/>
</connections>
</popUpButton>
</subviews>
<constraints>
<constraint firstItem="jcs-BG-ih5" firstAttribute="centerY" secondItem="c22-O7-iKe" secondAttribute="centerY" id="54E-Gg-1st"/>
<constraint firstItem="lXE-Ls-cyz" firstAttribute="centerY" secondItem="jcs-BG-ih5" secondAttribute="centerY" id="KqG-9g-ubJ"/>
<constraint firstItem="lXE-Ls-cyz" firstAttribute="leading" secondItem="jcs-BG-ih5" secondAttribute="trailing" constant="10" id="UEQ-Fd-oJy"/>
<constraint firstItem="jcs-BG-ih5" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" constant="191" id="ycs-lO-458"/>
</constraints>
<point key="canvasLocation" x="141" y="154"/>
</customView>
<menu id="X4k-3p-dgi">
<items>
<menuItem title="Item 1" id="6kx-cO-cSk">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Item 2" id="dcr-fK-Omc">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Item 3" id="Ff1-Mj-BjY">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
</items>
<point key="canvasLocation" x="10" y="-146"/>
</menu>
</objects>
</document>
8 changes: 8 additions & 0 deletions CommentWrapper/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ViewController: NSViewController {
case introduction
case installationInstructions
case about
case settings
}

// MARK: - Properties
Expand Down Expand Up @@ -46,6 +47,7 @@ class ViewController: NSViewController {
case 0: showContent(type: .introduction)
case 1: showContent(type: .installationInstructions)
case 2: showContent(type: .about)
case 3: showContent(type: .settings)
default: fatalError("Unhandled segmented control selection")
}
}
Expand All @@ -72,6 +74,12 @@ class ViewController: NSViewController {
case .about:
let about = AboutViewController(nibName: "AboutViewController", bundle: nil)
displayContent(viewController: about)

case .settings:
let settings = SettingsViewController(
nibName: "SettingsViewController", bundle: nil
)
displayContent(viewController: settings)
}

self.contentType = type
Expand Down
9 changes: 8 additions & 1 deletion CommentWrapperExt/CommentWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ class CommentWrapper {
.joined(separator: "\n")

let items = Itemizer.itemize(string: unprefixedString)
let wrappedString = wrap(items: items, lineLength: lineLength)
let adjustedLineLength: Int
switch Settings.lineLength {
case .absolute:
adjustedLineLength = lineLength - prefix.count
default:
adjustedLineLength = lineLength
}
let wrappedString = wrap(items: items, lineLength: adjustedLineLength)

let wrappedWithPrefix = wrappedString
.lines()
Expand Down
4 changes: 4 additions & 0 deletions CommentWrapperExt/CommentWrapperExt.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>group.CommentWrapper</string>
</array>
</dict>
</plist>
Loading