Add menu to Split Editor button

This commit is contained in:
1024jp 2020-08-08 19:08:31 +09:00
parent 40494372dc
commit 148b17fd61
10 changed files with 52 additions and 14 deletions

View File

@ -15,6 +15,8 @@ Change Log
- Change default settings of items to display in toolbar/status bar.
- Move line endings/file encoding menus from the toolbar to the status bar.
- Change the UI of the Unicode code point input to display the input field just above the insertion point.
- Show a menu about editor split by right-clicking the editor split button.
- Enable action to toggle editor split orientation even when no split editor is opened.
- Remove feature to import the legacy syntax style file format that was used in CotEditor 1.x.
- [trivial] Optimize the line number calculation in vertical text orientation.
- [dev] Update the build environment to Xcode 12 (Swift 5.3, macOS 11 SDK).

View File

@ -71,6 +71,7 @@
</buttonCell>
<connections>
<action selector="openSplitTextView:" target="OuY-Pd-2q9" id="gJ1-uN-P5E"/>
<outlet property="menu" destination="yKS-mO-j45" id="9an-zp-n21"/>
</connections>
</button>
<button hidden="YES" toolTip="Jump to next outline item" verticalHuggingPriority="750" verticalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="MlW-Dz-FOk">
@ -161,6 +162,7 @@
</visualEffectView>
<connections>
<outlet property="closeSplitButton" destination="Bmo-XE-CCn" id="l36-HV-WaO"/>
<outlet property="editorSplitMenu" destination="yKS-mO-j45" id="XVz-tF-UbW"/>
<outlet property="leftButton" destination="BUj-TD-scp" id="UPE-Vg-sYz"/>
<outlet property="openSplitButton" destination="syK-XU-x2I" id="rpx-m0-Ia5"/>
<outlet property="outlineIndicator" destination="htM-ug-ofP" id="U7C-1C-d8L"/>
@ -170,6 +172,22 @@
</connections>
</viewController>
<customObject id="OuY-Pd-2q9" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
<menu id="yKS-mO-j45">
<items>
<menuItem title="Split Editor" id="uXy-HK-1H7">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="openSplitTextView:" target="OuY-Pd-2q9" id="w4l-1p-ffW"/>
</connections>
</menuItem>
<menuItem title="Stack Editors Vertically" id="IhS-iT-L1i">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleSplitOrientation:" target="OuY-Pd-2q9" id="7kY-DS-tf5"/>
</connections>
</menuItem>
</items>
</menu>
</objects>
<point key="canvasLocation" x="1469" y="-388"/>
</scene>

View File

@ -82,6 +82,7 @@ final class NavigationBarController: NSViewController {
@IBOutlet private weak var openSplitButton: NSButton?
@IBOutlet private weak var closeSplitButton: NSButton?
@IBOutlet private var editorSplitMenu: NSMenu?
@ -113,9 +114,7 @@ final class NavigationBarController: NSViewController {
guard let textView = self.textView else { return assertionFailure() }
self.orientationObserver = textView.publisher(for: \.layoutOrientation, options: .initial)
.sink { [weak self] (orientation) in
self?.updateTextOrientation(to: orientation)
}
.sink { [weak self] in self?.updateTextOrientation(to: $0) }
self.selectionObserver = NotificationCenter.default.publisher(for: NSTextView.didChangeSelectionNotification, object: textView)
.map { $0.object as! NSTextView }
@ -208,7 +207,7 @@ final class NavigationBarController: NSViewController {
guard let popUp = self.outlineMenu, self.canSelectPrevItem else { return }
let index = popUp.itemArray[..<popUp.indexOfSelectedItem]
.lastIndex { $0.representedObject != nil } ?? 0
.lastIndex { $0.representedObject is NSRange } ?? 0
popUp.menu!.performActionForItem(at: index)
}
@ -220,7 +219,7 @@ final class NavigationBarController: NSViewController {
guard let popUp = self.outlineMenu, self.canSelectNextItem else { return }
let index = popUp.itemArray[(popUp.indexOfSelectedItem + 1)...]
.firstIndex { $0.representedObject != nil }
.firstIndex { $0.representedObject is NSRange }
if let index = index {
popUp.menu!.performActionForItem(at: index)
@ -258,7 +257,9 @@ final class NavigationBarController: NSViewController {
/// Build outline menu from `outlineItems`.
private func updateOutlineMenu() {
self.outlineMenu!.removeAllItems()
guard let outlineMenu = self.outlineMenu else { return assertionFailure() }
outlineMenu.removeAllItems()
self.leftButton!.isHidden = self.outlineItems.isEmpty
self.rightButton!.isHidden = self.outlineItems.isEmpty
@ -266,7 +267,7 @@ final class NavigationBarController: NSViewController {
guard !self.outlineItems.isEmpty else { return }
let menu = self.outlineMenu!.menu!
let menu = outlineMenu.menu!
// add headding item
let headdingItem = NSMenuItem()

View File

@ -91,7 +91,6 @@ final class SplitViewController: NSSplitViewController {
let title = self.splitView.isVertical ? "Stack Editors Horizontally" : "Stack Editors Vertically"
item.title = title.localized
}
return self.splitViewItems.count > 1
case #selector(focusNextSplitTextView), #selector(focusPrevSplitTextView):
return self.splitViewItems.count > 1

View File

@ -9,7 +9,7 @@
------------------------------------------------------------------------------
© 2015-2016 1024jp
© 2015-2020 1024jp
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -41,3 +41,6 @@
/* Class = "NSButton"; ibShadowedToolTip = "Split editor"; ObjectID = "syK-XU-x2I"; */
"syK-XU-x2I.ibShadowedToolTip" = "Editor teilen";
/* Class = "NSMenuItem"; title = "Split Editor"; ObjectID = "uXy-HK-1H7"; */
"uXy-HK-1H7.title" = "Editor teilen";

View File

@ -9,7 +9,7 @@
Localized by Aurélien Roy
------------------------------------------------------------------------------
© 2015-2019 CotEditor Project
© 2015-2020 CotEditor Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -41,3 +41,6 @@
/* Class = "NSButton"; ibShadowedToolTip = "Split editor"; ObjectID = "syK-XU-x2I"; */
"syK-XU-x2I.ibShadowedToolTip" = "Diviser l'éditeur";
/* Class = "NSMenuItem"; title = "Split Editor"; ObjectID = "uXy-HK-1H7"; */
"uXy-HK-1H7.title" = "Diviser l'éditeur";

View File

@ -10,7 +10,7 @@
------------------------------------------------------------------------------
© 2016 CotEditor Project
© 2016-2020 CotEditor Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -42,3 +42,6 @@
/* Class = "NSButton"; ibShadowedToolTip = "Split editor"; ObjectID = "syK-XU-x2I"; */
"syK-XU-x2I.ibShadowedToolTip" = "Dividi Editor";
/* Class = "NSMenuItem"; title = "Split Editor"; ObjectID = "uXy-HK-1H7"; */
"uXy-HK-1H7.title" = "Dividi Editor";

View File

@ -9,7 +9,7 @@
------------------------------------------------------------------------------
© 2014-2016 CotEditor Project
© 2014-2020 CotEditor Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -41,3 +41,6 @@
/* Class = "NSButton"; ibShadowedToolTip = "Split editor"; ObjectID = "syK-XU-x2I"; */
"syK-XU-x2I.ibShadowedToolTip" = "エディタを分割";
/* Class = "NSMenuItem"; title = "Split Editor"; ObjectID = "uXy-HK-1H7"; */
"uXy-HK-1H7.title" = "エディタを分割";

View File

@ -9,7 +9,7 @@
//
// ------------------------------------------------------------------------------
//
// © 2018 CotEditor Project
// © 2018-2020 CotEditor Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -39,3 +39,6 @@
/* Class = "NSButton"; ibShadowedToolTip = "Split editor"; ObjectID = "syK-XU-x2I"; */
"syK-XU-x2I.ibShadowedToolTip" = "Editor dividido";
/* Class = "NSMenuItem"; title = "Split Editor"; ObjectID = "uXy-HK-1H7"; */
"uXy-HK-1H7.title" = "Editor dividido";

View File

@ -10,7 +10,7 @@
------------------------------------------------------------------------------
© 2014-2016 CotEditor Project
© 2014-2020 CotEditor Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -42,3 +42,6 @@
/* Class = "NSButton"; ibShadowedToolTip = "Split editor"; ObjectID = "syK-XU-x2I"; */
"syK-XU-x2I.ibShadowedToolTip" = "分栏编辑器";
/* Class = "NSMenuItem"; title = "Split Editor"; ObjectID = "uXy-HK-1H7"; */
"uXy-HK-1H7.title" = "分栏编辑器";