Add preference toggle for auto-incrementing numbered lists

This commit is contained in:
Tommy Goode
2014-09-18 12:25:15 -05:00
parent 2d1abfdec5
commit ca57a2bfa8
6 changed files with 48 additions and 28 deletions
+1 -1
View File
@@ -679,7 +679,7 @@ static void (^MPGetPreviewLoadingCompletionHandler(id obj))()
{
if ([textView insertMappedContent])
return NO;
if ([textView completeNextListItem])
if ([textView completeNextListItem:self.preferences.editorAutoIncrementNumberedLists])
return NO;
if ([textView completeNextBlockquoteLine])
return NO;
@@ -30,7 +30,7 @@
- (void)indentSelectedLinesWithPadding:(NSString *)padding;
- (void)unindentSelectedLines;
- (BOOL)insertMappedContent;
- (BOOL)completeNextListItem;
- (BOOL)completeNextListItem:(BOOL)autoIncrement;
- (BOOL)completeNextBlockquoteLine;
- (BOOL)completeNextIndentedLine;
- (void)makeHeaderForSelectedLinesWithLevel:(NSUInteger)level;
@@ -451,7 +451,7 @@ static NSString * const kMPBlockquoteLinePattern = @"^((?:\\> ?)+).*$";
return YES;
}
- (BOOL)completeNextListItem
- (BOOL)completeNextListItem:(BOOL)autoIncrement
{
NSRange selectedRange = self.selectedRange;
NSUInteger location = selectedRange.location;
@@ -511,7 +511,9 @@ static NSString * const kMPBlockquoteLinePattern = @"^((?:\\> ?)+).*$";
NSRange range = [result rangeAtIndex:3];
range.length -= 1; // Exclude trailing space.
NSString *captured = [line substringWithRange:range];
NSInteger i = captured.integerValue + 1;
NSInteger i = captured.integerValue;
if (autoIncrement)
i += 1;
t = [NSString stringWithFormat:@"%ld.", i];
}
if (!t)
+1
View File
@@ -33,6 +33,7 @@ extern NSString * const MPDidDetectFreshInstallationNotification;
@property (assign) BOOL markdownManualRender;
@property (assign) NSDictionary *editorBaseFontInfo;
@property (assign) BOOL editorAutoIncrementNumberedLists;
@property (assign) BOOL editorConvertTabs;
@property (assign) BOOL editorCompleteMatchingCharacters;
@property (assign) BOOL editorSyncScrolling;
+3
View File
@@ -75,6 +75,7 @@ static NSString * const kMPDefaultHtmlStyleName = @"GitHub2";
@dynamic markdownManualRender;
@dynamic editorAutoIncrementNumberedLists;
@dynamic editorConvertTabs;
@dynamic editorCompleteMatchingCharacters;
@dynamic editorSyncScrolling;
@@ -148,6 +149,8 @@ static NSString * const kMPDefaultHtmlStyleName = @"GitHub2";
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if (![defaults objectForKey:@"editorMaximumWidth"])
self.editorMaximumWidth = 1000.0;
if (![defaults objectForKey:@"editorAutoIncrementNumberedLists"])
self.editorAutoIncrementNumberedLists = YES;
}
@end
@@ -16,11 +16,11 @@
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<customView id="Hz6-mo-xeY">
<rect key="frame" x="0.0" y="0.0" width="482" height="274"/>
<rect key="frame" x="0.0" y="0.0" width="482" height="294"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="g0N-qr-H8K">
<rect key="frame" x="111" y="234" width="229" height="22"/>
<rect key="frame" x="111" y="254" width="229" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" refusesFirstResponder="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="center" drawsBackground="YES" allowsEditingTextAttributes="YES" id="5dX-oK-p9L">
<font key="font" metaFont="system"/>
@@ -29,7 +29,7 @@
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lt1-Up-OVO">
<rect key="frame" x="18" y="237" width="87" height="17"/>
<rect key="frame" x="18" y="257" width="87" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Base font:" id="eXF-SL-hBq">
<font key="font" metaFont="system"/>
@@ -38,7 +38,7 @@
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="pwq-Pg-zCk">
<rect key="frame" x="18" y="207" width="87" height="17"/>
<rect key="frame" x="18" y="227" width="87" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Theme:" id="vA9-IT-8Z7">
<font key="font" metaFont="system"/>
@@ -47,7 +47,7 @@
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="4Ew-mW-Q4X">
<rect key="frame" x="18" y="150" width="87" height="17"/>
<rect key="frame" x="18" y="170" width="87" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Text insets:" id="Ee6-Cj-SWW">
<font key="font" metaFont="system"/>
@@ -56,7 +56,7 @@
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="fRw-As-iJo">
<rect key="frame" x="342" y="228" width="126" height="32"/>
<rect key="frame" x="342" y="248" width="126" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Change…" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="8bz-cc-gLF">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@@ -67,14 +67,14 @@
</connections>
</button>
<box autoresizesSubviews="NO" title="Behavior" borderType="line" translatesAutoresizingMaskIntoConstraints="NO" id="6JP-Pc-JFd">
<rect key="frame" x="17" y="16" width="449" height="92"/>
<rect key="frame" x="17" y="16" width="449" height="112"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<view key="contentView">
<rect key="frame" x="1" y="1" width="447" height="76"/>
<rect key="frame" x="1" y="1" width="447" height="93"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Hdc-ZZ-0Bg">
<rect key="frame" x="16" y="50" width="415" height="18"/>
<rect key="frame" x="16" y="70" width="415" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Insert spaces instead of tabs" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="XSN-mi-gbk">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@@ -85,7 +85,7 @@
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="nxG-74-mdM">
<rect key="frame" x="16" y="30" width="415" height="18"/>
<rect key="frame" x="16" y="50" width="415" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Auto-complete matching characters" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="o4K-iG-sGA">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@@ -96,7 +96,7 @@
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="NV7-zh-ydN">
<rect key="frame" x="16" y="10" width="415" height="18"/>
<rect key="frame" x="16" y="30" width="415" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="⌘← jumps to first non-whitespace character in line" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="2Yf-FT-MDH">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@@ -106,6 +106,17 @@
<binding destination="-2" name="value" keyPath="self.preferences.editorSmartHome" id="glH-vi-Olv"/>
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="Z2A-Wj-Kgq">
<rect key="frame" x="16" y="10" width="415" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Auto-increment numbered lists" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="bmj-00-Et0">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="-2" name="value" keyPath="self.preferences.editorAutoIncrementNumberedLists" id="mpa-up-rp0"/>
</connections>
</button>
</subviews>
</view>
<constraints>
@@ -115,6 +126,9 @@
<constraint firstItem="Hdc-ZZ-0Bg" firstAttribute="leading" secondItem="6JP-Pc-JFd" secondAttribute="leading" constant="16" id="diE-Es-gXO"/>
<constraint firstItem="NV7-zh-ydN" firstAttribute="top" secondItem="nxG-74-mdM" secondAttribute="bottom" constant="6" id="fgZ-en-j2O"/>
<constraint firstAttribute="trailing" secondItem="Hdc-ZZ-0Bg" secondAttribute="trailing" constant="16" id="ipD-gk-Ajf"/>
<constraint firstItem="Z2A-Wj-Kgq" firstAttribute="trailing" secondItem="NV7-zh-ydN" secondAttribute="trailing" id="mjB-5f-ofg"/>
<constraint firstItem="Z2A-Wj-Kgq" firstAttribute="top" secondItem="NV7-zh-ydN" secondAttribute="bottom" constant="6" id="oVm-7c-J3V"/>
<constraint firstItem="Z2A-Wj-Kgq" firstAttribute="leading" secondItem="NV7-zh-ydN" secondAttribute="leading" id="paq-Wh-8V8"/>
<constraint firstItem="nxG-74-mdM" firstAttribute="leading" secondItem="NV7-zh-ydN" secondAttribute="leading" id="pjG-Ee-mup"/>
<constraint firstItem="Hdc-ZZ-0Bg" firstAttribute="leading" secondItem="nxG-74-mdM" secondAttribute="leading" id="qbV-ui-DfR"/>
<constraint firstItem="nxG-74-mdM" firstAttribute="top" secondItem="Hdc-ZZ-0Bg" secondAttribute="bottom" constant="6" id="zMy-dJ-Rlp"/>
@@ -123,7 +137,7 @@
<color key="fillColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</box>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="JZh-8k-zMC">
<rect key="frame" x="109" y="202" width="234" height="26"/>
<rect key="frame" x="109" y="222" width="234" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="4C5-3K-7bE" id="Zr8-Em-EhD">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
@@ -141,7 +155,7 @@
</connections>
</popUpButton>
<segmentedControl horizontalHuggingPriority="300" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="jde-Kw-4ly">
<rect key="frame" x="346" y="203" width="118" height="24"/>
<rect key="frame" x="346" y="223" width="118" height="24"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<segmentedCell key="cell" alignment="left" style="rounded" trackingMode="momentary" id="GHX-3h-1HI">
<font key="font" metaFont="smallSystem"/>
@@ -155,7 +169,7 @@
</connections>
</segmentedControl>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="3ow-hg-Gmo">
<rect key="frame" x="216" y="151" width="19" height="17"/>
<rect key="frame" x="216" y="171" width="19" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="×" id="g5w-Qw-Khw">
<font key="font" metaFont="system"/>
@@ -164,7 +178,7 @@
</textFieldCell>
</textField>
<textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="uWf-nW-3Ez">
<rect key="frame" x="111" y="148" width="85" height="22"/>
<rect key="frame" x="111" y="168" width="85" 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" focusRingType="none" alignment="right" title="0" drawsBackground="YES" id="797-vo-Lg9">
<numberFormatter key="formatter" formatterBehavior="custom10_4" numberStyle="decimal" usesGroupingSeparator="NO" minimumIntegerDigits="1" maximumIntegerDigits="2" id="Z1m-eN-5ss">
@@ -186,7 +200,7 @@
</connections>
</textField>
<textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="77u-zZ-bC0">
<rect key="frame" x="238" y="148" width="87" height="22"/>
<rect key="frame" x="238" y="168" width="87" 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" focusRingType="none" alignment="right" title="0" drawsBackground="YES" id="557-oZ-4zf">
<numberFormatter key="formatter" formatterBehavior="custom10_4" usesGroupingSeparator="NO" groupingSize="0" minimumIntegerDigits="1" maximumIntegerDigits="2" id="E8M-bY-H1G">
@@ -208,7 +222,7 @@
</connections>
</textField>
<stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="u4r-9h-qMR">
<rect key="frame" x="195" y="145" width="19" height="27"/>
<rect key="frame" x="195" y="165" width="19" height="27"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<stepperCell key="cell" continuous="YES" alignment="left" maxValue="35" id="YKV-Q4-Mio"/>
<connections>
@@ -216,7 +230,7 @@
</connections>
</stepper>
<stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="uUN-8R-G1c">
<rect key="frame" x="324" y="145" width="19" height="27"/>
<rect key="frame" x="324" y="165" width="19" height="27"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<stepperCell key="cell" continuous="YES" alignment="left" maxValue="35" id="W0c-qa-cIF"/>
<connections>
@@ -224,7 +238,7 @@
</connections>
</stepper>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lmO-8l-df9">
<rect key="frame" x="18" y="180" width="87" height="17"/>
<rect key="frame" x="18" y="200" width="87" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Line spacing:" id="InD-Fc-CTS">
<font key="font" metaFont="system"/>
@@ -233,7 +247,7 @@
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ogi-ll-Yii">
<rect key="frame" x="111" y="177" width="214" height="22"/>
<rect key="frame" x="111" y="197" width="214" 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" alignment="right" title="0" drawsBackground="YES" id="Qlw-QZ-XWE">
<numberFormatter key="formatter" formatterBehavior="custom10_4" numberStyle="decimal" usesGroupingSeparator="NO" groupingSize="0" minimumIntegerDigits="1" maximumIntegerDigits="309" id="cbO-Ho-XRq">
@@ -249,7 +263,7 @@
</connections>
</textField>
<stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="qZo-S6-Vbh">
<rect key="frame" x="324" y="174" width="19" height="27"/>
<rect key="frame" x="324" y="194" width="19" height="27"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<stepperCell key="cell" continuous="YES" alignment="left" maxValue="100" id="6T1-uq-ddF"/>
<connections>
@@ -257,7 +271,7 @@
</connections>
</stepper>
<button translatesAutoresizingMaskIntoConstraints="NO" id="JV2-Ef-pKx">
<rect key="frame" x="18" y="118" width="151" height="18"/>
<rect key="frame" x="18" y="138" width="151" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Limit editor width to" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="bhL-NA-9No">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@@ -268,7 +282,7 @@
</connections>
</button>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="IAf-0I-hfF">
<rect key="frame" x="175" y="116" width="150" height="22"/>
<rect key="frame" x="175" y="136" width="150" 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" alignment="right" title="300" drawsBackground="YES" id="M8w-C7-PC0">
<numberFormatter key="formatter" formatterBehavior="custom10_4" numberStyle="decimal" usesGroupingSeparator="NO" minimumIntegerDigits="1" maximumIntegerDigits="5" id="MQ9-lM-ZUg">
@@ -285,7 +299,7 @@
</connections>
</textField>
<stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="mql-gy-6Sv">
<rect key="frame" x="324" y="114" width="19" height="27"/>
<rect key="frame" x="324" y="134" width="19" height="27"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<stepperCell key="cell" continuous="YES" alignment="left" minValue="300" maxValue="10000" doubleValue="300" id="SN0-ZN-Y1k"/>
<connections>