Improve process detection of SyphonInject captures

File based text input can now handle HTML formatted files. You need to set a style in the file for font/font size.
This commit is contained in:
Zakk 2019-09-26 01:32:55 -04:00
parent a1cad1d7a7
commit 795091c2fc
10 changed files with 176 additions and 71 deletions

View file

@ -57,9 +57,10 @@
NSScreen *cropScreen = [self findScreeenForDisplayID:captureDevice.captureDevice];
[NSMenu setMenuBarVisible:NO];
[self.cropSelectionWindow setOpaque:NO];
[self.cropSelectionWindow setLevel:kCGPopUpMenuWindowLevel];
[self.cropSelectionWindow setLevel:NSStatusWindowLevel];
self.cropSelectionWindow.floatingPanel = YES;
[self.cropSelectionWindow setIgnoresMouseEvents:NO];
@ -127,6 +128,7 @@
viewBounds.origin.y = -(viewBounds.origin.y - NSHeight(screenFrame)) - NSHeight(viewBounds);
[self.captureObj resetRegionRect:viewBounds];
[self.cropSelectionWindow close];
[NSMenu setMenuBarVisible:YES];
}
-(IBAction)resetCroppedArea:(id)sender
@ -139,6 +141,7 @@
if (self.cropSelectionWindow)
{
[self.cropSelectionWindow cancelOperation:nil];
[NSMenu setMenuBarVisible:YES];
}
}
@end

View file

@ -15,11 +15,11 @@
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="Hz6-mo-xeY">
<rect key="frame" x="0.0" y="0.0" width="256" height="141"/>
<rect key="frame" x="0.0" y="0.0" width="256" height="195"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="u9Z-Pg-s0r">
<rect key="frame" x="1" y="125" width="61" height="14"/>
<rect key="frame" x="1" y="179" width="61" height="14"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Resolution" id="XPT-7I-1qm">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -27,7 +27,7 @@
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="iwZ-dN-QyQ">
<rect key="frame" x="67" y="100" width="41" height="19"/>
<rect key="frame" x="67" y="154" width="41" height="19"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="unn-of-x3W">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -38,7 +38,7 @@
</connections>
</textField>
<button translatesAutoresizingMaskIntoConstraints="NO" id="NEU-TS-EJA">
<rect key="frame" x="0.0" y="77" width="97" height="18"/>
<rect key="frame" x="0.0" y="131" width="97" height="18"/>
<constraints>
<constraint firstAttribute="width" constant="92" id="doA-PC-P2M"/>
</constraints>
@ -51,7 +51,7 @@
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="cSZ-ei-e7J">
<rect key="frame" x="1" y="30" width="38" height="14"/>
<rect key="frame" x="1" y="84" width="38" height="14"/>
<constraints>
<constraint firstAttribute="width" constant="34" id="4JO-th-p36"/>
</constraints>
@ -62,7 +62,7 @@
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="1XV-C0-CqP">
<rect key="frame" x="45" y="27" width="42" height="19"/>
<rect key="frame" x="45" y="81" width="42" height="19"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="ACb-87-qEx">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -73,7 +73,7 @@
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="pLd-Ys-cOI">
<rect key="frame" x="99" y="30" width="38" height="14"/>
<rect key="frame" x="99" y="84" width="38" height="14"/>
<constraints>
<constraint firstAttribute="width" constant="34" id="bAC-EK-Q1q"/>
</constraints>
@ -84,7 +84,7 @@
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="3Px-Af-yqB">
<rect key="frame" x="143" y="27" width="40" height="19"/>
<rect key="frame" x="143" y="81" width="40" height="19"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="U7U-uc-XxH">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -95,7 +95,7 @@
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="mNt-q8-haM">
<rect key="frame" x="-2" y="3" width="38" height="14"/>
<rect key="frame" x="-2" y="57" width="38" height="14"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Width" id="dKY-qh-kAR">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -103,7 +103,7 @@
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="esZ-gq-1qW">
<rect key="frame" x="45" y="0.0" width="42" height="19"/>
<rect key="frame" x="45" y="54" width="42" height="19"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="MNZ-Eo-l3a">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -114,7 +114,7 @@
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="II4-dC-DDc">
<rect key="frame" x="1" y="103" width="29" height="14"/>
<rect key="frame" x="1" y="157" width="29" height="14"/>
<constraints>
<constraint firstAttribute="width" constant="25" id="UUD-Nx-81s"/>
</constraints>
@ -125,7 +125,7 @@
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="LCx-mf-zKr">
<rect key="frame" x="67" y="122" width="41" height="19"/>
<rect key="frame" x="67" y="176" width="41" height="19"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="6Dk-7W-GaH">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -136,7 +136,7 @@
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="B5P-ip-38J">
<rect key="frame" x="112" y="125" width="11" height="14"/>
<rect key="frame" x="112" y="179" width="11" height="14"/>
<constraints>
<constraint firstAttribute="width" constant="7" id="tzV-9T-YvZ"/>
</constraints>
@ -147,7 +147,7 @@
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="BZN-NR-e3t">
<rect key="frame" x="-2" y="48" width="128" height="27"/>
<rect key="frame" x="-2" y="102" width="128" height="27"/>
<buttonCell key="cell" type="push" title="Set Capture Region" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="tf2-h3-yJI">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="smallSystem"/>
@ -166,7 +166,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xUe-Ag-64N">
<rect key="frame" x="121" y="48" width="140" height="27"/>
<rect key="frame" x="121" y="102" width="140" height="27"/>
<buttonCell key="cell" type="push" title="Reset Capture Region" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="qsR-5N-cM7">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="smallSystem"/>
@ -176,7 +176,7 @@
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="aCF-eX-mDo">
<rect key="frame" x="99" y="3" width="38" height="14"/>
<rect key="frame" x="99" y="57" width="38" height="14"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Height" id="xcn-b2-85u">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -184,7 +184,7 @@
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Aav-9n-GhZ">
<rect key="frame" x="143" y="0.0" width="40" height="19"/>
<rect key="frame" x="143" y="54" width="40" height="19"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="YPS-Ie-xEg">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -195,7 +195,7 @@
</connections>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="yqx-Fn-lSJ">
<rect key="frame" x="126" y="122" width="41" height="19"/>
<rect key="frame" x="126" y="176" width="41" height="19"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="L6L-UP-xGg">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -252,7 +252,7 @@
<constraint firstItem="LCx-mf-zKr" firstAttribute="trailing" secondItem="iwZ-dN-QyQ" secondAttribute="trailing" id="zTX-LA-EhO"/>
<constraint firstItem="NEU-TS-EJA" firstAttribute="top" secondItem="iwZ-dN-QyQ" secondAttribute="bottom" constant="8" symbolic="YES" id="zZm-nt-UiH"/>
</constraints>
<point key="canvasLocation" x="-163" y="-171"/>
<point key="canvasLocation" x="-163" y="-144.5"/>
</customView>
<objectController id="YxM-Vh-gvX" userLabel="DesktopCaptureController">
<connections>

View file

@ -109,6 +109,10 @@
});
}
}
if (self.activeVideoDevice && self.activeVideoDevice.captureName)
{
self.captureName = self.activeVideoDevice.captureName;
}
}
@ -127,7 +131,16 @@
[retArr addObject:newDev];
if (!self.activeVideoDevice && [newDev.uniqueID isEqualToString:self.savedUniqueID])
NSLog(@"UNIQ APP %@ SAVED %@", newDev.uniqueID, self.savedUniqueID);
bool appMatch = NO;
if ([newDev.uniqueID isEqualToString:self.savedUniqueID])
{
appMatch = YES;
} else if ([app.executableURL.lastPathComponent isEqualToString:self.savedUniqueID.lastPathComponent]) {
appMatch = YES;
}
if (!self.activeVideoDevice && appMatch)
{
self.activeVideoDevice = newDev;
}

View file

@ -291,7 +291,7 @@
}
-(void) handleSyphonServerRetire:(NSNotification *)notification
{
NSString *retireID = [[notification object] objectForKey:SyphonServerDescriptionUUIDKey];
NSString *retireID = [[notification userInfo] objectForKey:SyphonServerDescriptionUUIDKey];
if ([retireID isEqualToString:_syphon_uuid])
{

View file

@ -10,11 +10,13 @@
@interface FileTextCapture : CSTextCaptureBase
{
dispatch_source_t _fileSource;
dispatch_queue_t _fileChangeQueue;
}
@property (assign) int startLine;
@property (assign) int lineLimit;
@property (assign) bool collapseLines;
@property (assign) bool readAsHTML;
@property (strong) NSString *currentFile;
-(void)openFile:(NSString *)filename;

View file

@ -12,6 +12,7 @@
@synthesize currentFile = _currentFile;
@synthesize startLine = _startLine;
@synthesize lineLimit = _lineLimit;
@synthesize readAsHTML = _readAsHTML;
-(instancetype)init
{
@ -20,6 +21,7 @@
self.lineLimit = 0;
self.startLine = 0;
self.collapseLines = NO;
_fileChangeQueue = dispatch_queue_create("File Watch Queue", DISPATCH_QUEUE_SERIAL);
}
return self;
@ -32,6 +34,7 @@
[aCoder encodeObject:self.currentFile forKey:@"currentFile"];
[aCoder encodeInt:self.startLine forKey:@"startLine"];
[aCoder encodeInt:self.lineLimit forKey:@"lineLimit"];
[aCoder encodeBool:self.readAsHTML forKey:@"readAsHTML"];
}
-(void)restoreWithCoder:(NSCoder *)aDecoder
@ -40,7 +43,9 @@
_lineLimit = [aDecoder decodeIntForKey:@"lineLimit"];
_startLine = [aDecoder decodeIntForKey:@"startLine"];
_readAsHTML = [aDecoder decodeBoolForKey:@"readAsHTML"];
self.currentFile = [aDecoder decodeObjectForKey:@"currentFile"];
}
@ -89,6 +94,16 @@
return _lineLimit;
}
-(void)setReadAsHTML:(bool)readAsHTML
{
_readAsHTML = readAsHTML;
[self openFile:self.currentFile];
}
-(bool)readAsHTML
{
return _readAsHTML;
}
-(void)setCurrentFile:(NSString *)currentFile
{
@ -114,40 +129,54 @@
{
return;
}
[self cancelWatch];
//[self cancelWatch];
//self.currentFile = filename;
NSString *fileText = [[NSString alloc] initWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:nil];
long lineCount = self.lineLimit;
long startLine = self.startLine;
if (lineCount || startLine)
if (self.readAsHTML)
{
NSArray *lines = [fileText componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
if (startLine > lines.count)
NSData *fileData = [NSData dataWithContentsOfFile:filename];
NSAttributedString *fileText = [[NSAttributedString alloc] initWithHTML:fileData documentAttributes:nil];
if (fileText)
{
startLine = 0;
self.attributedText = fileText;
}
long totalLength = lines.count - startLine;
self.text = nil;
} else {
self.attributedText = nil;
//self.currentFile = filename;
NSString *fileText = [[NSString alloc] initWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:nil];
if (lineCount > totalLength)
long lineCount = self.lineLimit;
long startLine = self.startLine;
if (lineCount || startLine)
{
lineCount = totalLength;
NSArray *lines = [fileText componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
if (startLine > lines.count)
{
startLine = 0;
}
long totalLength = lines.count - startLine;
if (lineCount > totalLength)
{
lineCount = totalLength;
}
NSArray *lineSlice = [lines subarrayWithRange:NSMakeRange(startLine, lineCount)];
fileText = [lineSlice componentsJoinedByString:@"\n"];
}
NSArray *lineSlice = [lines subarrayWithRange:NSMakeRange(startLine, lineCount)];
fileText = [lineSlice componentsJoinedByString:@"\n"];
if (self.collapseLines)
{
fileText = [fileText stringByReplacingOccurrencesOfString:@"\n" withString:@" "];
}
self.text = fileText;
}
if (self.collapseLines)
{
fileText = [fileText stringByReplacingOccurrencesOfString:@"\n" withString:@" "];
}
self.text = fileText;
[self watchPath:filename];
}
@ -166,8 +195,14 @@
-(void)watchPath:(NSString *)filePath
{
int fd = open([filePath UTF8String], O_EVTONLY);
if (_fileSource)
{
return;
}
int fd = open([filePath UTF8String], O_EVTONLY);
NSLog(@"FD IS %d", fd);
__block typeof(self) blockSelf = self;
_fileSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, fd, DISPATCH_VNODE_DELETE | DISPATCH_VNODE_WRITE | DISPATCH_VNODE_EXTEND | DISPATCH_VNODE_ATTRIB | DISPATCH_VNODE_LINK | DISPATCH_VNODE_RENAME | DISPATCH_VNODE_REVOKE, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0));
@ -178,9 +213,12 @@
if (flags & DISPATCH_VNODE_DELETE)
{
dispatch_source_cancel(blockSelf->_fileSource);
blockSelf->_fileSource = NULL;
[blockSelf watchPath:filePath];
} else {
[self openFile:filePath];
dispatch_async(self->_fileChangeQueue, ^{
[self openFile:filePath];
});
}
});

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12120" systemVersion="16G29" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12120"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@ -17,7 +17,7 @@
<rect key="frame" x="0.0" y="0.0" width="395" height="64"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Lbh-p4-FGF">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Lbh-p4-FGF">
<rect key="frame" x="0.0" y="46" width="26" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="File" id="nrh-Mx-3qK">
@ -26,12 +26,12 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="r47-E4-8sx">
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="r47-E4-8sx">
<rect key="frame" x="32" y="45" width="285" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="cYf-yH-BpZ">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
@ -49,7 +49,7 @@
<action selector="chooseFile:" target="-2" id="46e-pA-JfF"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WBW-sP-wFK">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="WBW-sP-wFK">
<rect key="frame" x="118" y="25" width="59" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Line count" id="ZG4-WY-7mm">
@ -69,32 +69,32 @@
<binding destination="vHC-Iv-oOo" name="value" keyPath="selection.collapseLines" id="vzF-pa-k8i"/>
</connections>
</button>
<textField verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Hlq-PY-7Wy">
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Hlq-PY-7Wy">
<rect key="frame" x="183" y="22" width="42" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" continuous="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="WLV-Vh-kAN">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<binding destination="vHC-Iv-oOo" name="value" keyPath="selection.lineLimit" id="gGy-yb-GZH"/>
</connections>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gie-Dm-cDE">
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gie-Dm-cDE">
<rect key="frame" x="60" y="22" width="42" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" continuous="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="FyZ-az-qa9">
<numberFormatter key="formatter" formatterBehavior="default10_4" numberStyle="decimal" minimumIntegerDigits="1" maximumIntegerDigits="2000000000" maximumFractionDigits="3" id="X0h-JZ-nRh"/>
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<binding destination="-2" name="value" keyPath="self.startLine" id="alE-0N-Rgl"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="r4f-fe-h76">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="r4f-fe-h76">
<rect key="frame" x="-2" y="25" width="52" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Start line" id="04e-UG-Eti">
@ -103,6 +103,17 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Zb7-yg-G9z">
<rect key="frame" x="117" y="-1" width="62" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="HTML" bezelStyle="regularSquare" imagePosition="right" controlSize="small" state="on" inset="2" id="Sxe-QQ-Aia">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="smallSystem"/>
</buttonCell>
<connections>
<binding destination="vHC-Iv-oOo" name="value" keyPath="selection.readAsHTML" id="aHH-en-FXn"/>
</connections>
</button>
</subviews>
<point key="canvasLocation" x="464.5" y="288"/>
</customView>

View file

@ -323,7 +323,6 @@
CGFloat frameWidth, frameHeight;
[self.layout frameTick];
frameWidth = self.layout.canvas_width;
frameHeight = self.layout.canvas_height;

View file

@ -22,7 +22,7 @@
@implementation CSTextCaptureBase
@synthesize text = _text;
@synthesize attributedText = _attributedText;
-(instancetype)init
{
if (self = [super init])
@ -85,6 +85,7 @@
}
_text = [aDecoder decodeObjectForKey:@"text"];
_attributedText = [aDecoder decodeObjectForKey:@"attributedText"];
NSFont *savedFont = [aDecoder decodeObjectForKey:@"font"];
if (savedFont)
{
@ -134,15 +135,27 @@
-(NSDictionary *)defaultAttributes
{
NSMutableDictionary *strAttrs = [NSMutableDictionary dictionaryWithDictionary:self.fontAttributes];
strAttrs[NSFontAttributeName] = self.font;
return strAttrs;
}
-(void) buildString
{
if (self.text)
if (self.text || self.attributedText)
{
NSMutableDictionary *strAttrs = [NSMutableDictionary dictionaryWithDictionary:self.fontAttributes];
strAttrs[NSFontAttributeName] = self.font;
_attribString = [[NSAttributedString alloc] initWithString:self.text attributes:strAttrs];
NSDictionary *strAttrs = self.defaultAttributes;
if (self.attributedText)
{
_attribString = self.attributedText.mutableCopy;
} else {
_attribString = [[NSMutableAttributedString alloc] initWithString:self.text attributes:strAttrs];
}
if ([self.alignmentMode isEqualToString:kCAAlignmentCenter] || [self.alignmentMode isEqualToString:kCAAlignmentRight])
{
@ -153,7 +166,7 @@
[self updateLayersWithBlock:^(CALayer *layer) {
layer.bounds = CGRectMake(0.0, 0.0, self->_attribString.size.width, self->_attribString.size.height);
//layer.bounds = CGRectMake(0.0, 0.0, self->_attribString.size.width, self->_attribString.size.height);
((CATextLayer *)layer).string = self->_attribString;
((CATextLayer *)layer).alignmentMode = self.alignmentMode;
((CATextLayer *)layer).wrapped = self.wrapped;
@ -163,8 +176,33 @@
}
}
-(NSAttributedString *)attributedText
{
return _attributedText;
}
-(void)setAttributedText:(NSAttributedString *)attributedText
{
if ([_attributedText isEqualToAttributedString:attributedText])
{
return;
}
_attributedText = attributedText;
dispatch_async(dispatch_get_main_queue(), ^{
self.captureName = attributedText.string;
});
[self buildString];
}
-(NSString *)text
{
return _text;

View file

@ -15,13 +15,14 @@
{
CGLayerRef _cgLayer;
CIImage *_ciimage;
NSAttributedString *_attribString;
NSMutableAttributedString *_attribString;
}
@property (strong) NSFont *font;
@property (strong) NSAttributedString *attributedText;
@property (strong) NSString *text;
@property (strong) NSArray *fontNames;
@property (strong) NSColor *foregroundColor;
@ -30,7 +31,7 @@
@property (strong) NSString *alignmentMode;
@property (assign) bool wrapped;
@property (readonly) NSString *saveText;
@property (readonly) NSDictionary *defaultAttributes;
@end