Update font resize actions just to scale textView

This commit is contained in:
1024jp 2016-03-20 18:22:38 +09:00
parent 071eb689e9
commit 70ce092e34
7 changed files with 73 additions and 28 deletions

View File

@ -15,7 +15,13 @@ develop
- Display the dialog asking encoding compatibility on saving as a document-modal sheet.
- Optimize document opening performance with large file.
- Improve pinch-zoom behavior.
- Improve font-size chainging behavior:
- Smoother pinch-zoom.
- Now font-size change applies only to the focused editor.
- Enable pinch-zoom to make font smaller than default font size.
- Font size changing doesn't affect the actual font anymore but just scale charaters visibly.
- Fix an issue where font-size changing could remove hanging indent.
- Fix an issue where layout of split editors will be broken if the font of one of the other split editors is changed.
- Improve recovering status of unsaved documents on window resume.
- Improve line number view drawing with selection on vertical text mode.
- Display print progress panel as a document-modal sheet.
@ -24,7 +30,6 @@ develop
### Fixes
- Fix an issue where the backgorund of navigation/status bars were not dwarn under a specific condition.
- Fix an issue where layout of split editors will be broken if the font of one of the other split editors is changed.
- Fix an issue where the numbers in the line number view could be drawn in a wrong place if the editor is vertical text mode and unwapped.

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9532"/>
<capability name="box content view" minToolsVersion="7.0"/>
</dependencies>
<objects>
@ -301,12 +301,12 @@
<toolbarItem implicitItemIdentifier="NSToolbarShowFontsItem" id="ozh-KV-skX"/>
<toolbarItem implicitItemIdentifier="A7DA403B-9AC8-4DF1-B5AB-6426322C67D5" explicitItemIdentifier="biggerFontItemID" label="Bigger" paletteLabel="Bigger Font" toolTip="Increase font size" tag="3" image="BiggerFont" id="Ptr-aN-aSD">
<connections>
<action selector="modifyFont:" target="M21-bo-PEe" id="LYq-SM-GGd"/>
<action selector="biggerFont:" target="-1" id="u40-oO-ap8"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="25E3B962-091E-4686-8218-7494D6E82F33" explicitItemIdentifier="smallerFontItemID" label="Smaller" paletteLabel="Smaller Font" toolTip="Decrease font size" tag="4" image="SmallerFont" id="5nt-ud-Ewr">
<connections>
<action selector="modifyFont:" target="M21-bo-PEe" id="GU4-F5-6zt"/>
<action selector="smallerFont:" target="-1" id="ig1-PL-QNK"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="FE7DD66B-21BE-4D6E-9916-1CC7AEC28433" explicitItemIdentifier="shiftLeftItemID" label="Shift Left" paletteLabel="Shift Left" toolTip="Shift lines to left" tag="10" image="ShiftLeft" id="77g-Yu-UgC">
@ -428,7 +428,6 @@
<outlet property="view" destination="Ezm-P5-z5i" id="UCd-p0-0fe"/>
</connections>
</viewController>
<customObject id="M21-bo-PEe" customClass="NSFontManager"/>
</objects>
<resources>
<image name="AutoTabExpand_On" width="32" height="32"/>

View File

@ -492,12 +492,12 @@
</menuItem>
<menuItem title="Bigger" tag="3" keyEquivalent="+" id="405">
<connections>
<action selector="modifyFont:" target="432" id="449"/>
<action selector="biggerFont:" target="-1" id="UGG-uK-kSZ"/>
</connections>
</menuItem>
<menuItem title="Smaller" tag="4" keyEquivalent="-" id="404">
<connections>
<action selector="modifyFont:" target="432" id="439"/>
<action selector="smallerFont:" target="-1" id="hsI-0T-1iJ"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="576">

View File

@ -74,6 +74,10 @@
<string>newDocument:</string>
<key>@o</key>
<string>openDocument:</string>
<key>@+</key>
<string>biggerFont:</string>
<key>@-</key>
<string>smallerFont:</string>
<key>@p</key>
<string>printDocument:</string>
<key>@q</key>

View File

@ -699,8 +699,7 @@ static NSDictionary<NSString *, NSString *> *kUnprintableKeyTable;
+ (nonnull NSArray<NSString *> *)selectorStringsToIgnore
//------------------------------------------------------
{
return @[@"modifyFont:",
@"changeEncoding:",
return @[@"changeEncoding:",
@"changeSyntaxStyle:",
@"changeTheme:",
@"changeTabWidth:",

View File

@ -58,7 +58,6 @@
// Action Message
- (IBAction)copyWithStyle:(nullable id)sender;
- (IBAction)resetFont:(nullable id)sender;
- (IBAction)selectLines:(nullable id)sender;
- (IBAction)changeTabWidth:(nullable id)sender;
- (IBAction)inputYenMark:(nullable id)sender;
@ -86,6 +85,15 @@
@end
@interface CETextView (Scaling)
- (IBAction)biggerFont:(nullable id)sender;
- (IBAction)smallerFont:(nullable id)sender;
- (IBAction)resetFont:(nullable id)sender;
@end
#pragma mark - CETextView+Indentation.m

View File

@ -1252,21 +1252,6 @@ static NSCharacterSet *kMatchingClosingBracketsSet;
}
// ------------------------------------------------------
///
- (void)resetFont:(nullable id)sender
// ------------------------------------------------------
{
NSString *name = [[NSUserDefaults standardUserDefaults] stringForKey:CEDefaultFontNameKey];
CGFloat size = (CGFloat)[[NSUserDefaults standardUserDefaults] doubleForKey:CEDefaultFontSizeKey];
[self setFont:[NSFont fontWithName:name size:size] ? : [NSFont userFontOfSize:size]];
// 調
[self scrollRangeToVisible:[self selectedRange]];
}
// ------------------------------------------------------
///
- (IBAction)selectLines:(nullable id)sender
@ -1884,7 +1869,7 @@ static NSCharacterSet *kMatchingClosingBracketsSet;
#pragma mark -
@implementation CETextView (PinchZoomSupport)
@implementation CETextView (Scaling)
#pragma mark Superclass Methods
@ -1930,6 +1915,39 @@ static NSCharacterSet *kMatchingClosingBracketsSet;
}
#pragma mark Action Messages
// ------------------------------------------------------
/// scale up
- (IBAction)biggerFont:(nullable id)sender
// ------------------------------------------------------
{
[self setScaleKeepingVisibleArea:[self scale] * 1.1];
}
// ------------------------------------------------------
/// scale down
- (IBAction)smallerFont:(nullable id)sender
// ------------------------------------------------------
{
[self setScaleKeepingVisibleArea:[self scale] / 1.1];
}
// ------------------------------------------------------
/// reset scale and font to default
- (IBAction)resetFont:(nullable id)sender
// ------------------------------------------------------
{
NSString *name = [[NSUserDefaults standardUserDefaults] stringForKey:CEDefaultFontNameKey];
CGFloat size = (CGFloat)[[NSUserDefaults standardUserDefaults] doubleForKey:CEDefaultFontSizeKey];
[self setFont:[NSFont fontWithName:name size:size] ? : [NSFont userFontOfSize:size]];
[self setScaleKeepingVisibleArea:1.0];
}
#pragma mark Private Methods
@ -2000,6 +2018,18 @@ static NSCharacterSet *kMatchingClosingBracketsSet;
}
}
// ------------------------------------------------------
/// zoom to the scale keeping current visible rect position in scroll view
- (void)setScaleKeepingVisibleArea:(CGFloat)scale
// ------------------------------------------------------
{
NSPoint center = NSMakePoint(NSMidX([self visibleRect]),
NSMidY([self visibleRect]));
[self setScale:scale centeredAtPoint:center];
}
@end