mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Upate menu heading style
This commit is contained in:
parent
95f8734584
commit
2e59b0005c
@ -10,6 +10,7 @@ Change Log
|
||||
- Optimize large find/replace task performance.
|
||||
- Display the concrete progress of the find/replace task in the progress dialog.
|
||||
- Update the Unicode block name list for the character inspector from Unicode 14.0.0 to Unicode 15.0.0.
|
||||
- [trivial] Tweak the style of headings in menus.
|
||||
- [trivial] Tweak the setting summary display in the print dialog.
|
||||
|
||||
|
||||
|
@ -76,6 +76,8 @@
|
||||
2A12C8001D1843B50069C60B /* SeparatorTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A12C7FE1D1843B50069C60B /* SeparatorTextField.swift */; };
|
||||
2A1311D62127DCE1001D52C5 /* NSTextView+CurrentLineHighlighting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A1311D52127DCE1001D52C5 /* NSTextView+CurrentLineHighlighting.swift */; };
|
||||
2A1311D72127DCE1001D52C5 /* NSTextView+CurrentLineHighlighting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A1311D52127DCE1001D52C5 /* NSTextView+CurrentLineHighlighting.swift */; };
|
||||
2A158C1C2945A6B1000A4EC1 /* HeadingMenuItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A158C1B2945A6B1000A4EC1 /* HeadingMenuItem.swift */; };
|
||||
2A158C1D2945A6B1000A4EC1 /* HeadingMenuItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A158C1B2945A6B1000A4EC1 /* HeadingMenuItem.swift */; };
|
||||
2A1679E61D3CE07100E8261D /* Document.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A1679E51D3CE07100E8261D /* Document.swift */; };
|
||||
2A1679E71D3CE07100E8261D /* Document.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A1679E51D3CE07100E8261D /* Document.swift */; };
|
||||
2A17A3131D2D16F1001DD717 /* WindowContentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A17A3121D2D16F1001DD717 /* WindowContentViewController.swift */; };
|
||||
@ -945,6 +947,7 @@
|
||||
2A156890245C10840055CD85 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/CharacterPopover.strings; sourceTree = "<group>"; };
|
||||
2A156892245C10860055CD85 /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/CharacterPopover.strings; sourceTree = "<group>"; };
|
||||
2A156894245C10880055CD85 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/CharacterPopover.strings; sourceTree = "<group>"; };
|
||||
2A158C1B2945A6B1000A4EC1 /* HeadingMenuItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadingMenuItem.swift; sourceTree = "<group>"; };
|
||||
2A1679E51D3CE07100E8261D /* Document.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Document.swift; sourceTree = "<group>"; };
|
||||
2A17A3121D2D16F1001DD717 /* WindowContentViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WindowContentViewController.swift; sourceTree = "<group>"; };
|
||||
2A17A3151D2D4319001DD717 /* DocumentWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DocumentWindow.swift; sourceTree = "<group>"; };
|
||||
@ -1755,6 +1758,7 @@
|
||||
2ACDC0961D172B2A009B72D6 /* PaddingTextFieldCell.swift */,
|
||||
2A0AEA052124A83B00E4EC3D /* SelectionColorWell.swift */,
|
||||
2AA3C7A7251EBB810060D6DB /* SeparatorGuideView.swift */,
|
||||
2A158C1B2945A6B1000A4EC1 /* HeadingMenuItem.swift */,
|
||||
2A62F3752699C2EA00AB3510 /* ShareMenuItem.swift */,
|
||||
2A3E61BE27C3795B00C6E5B6 /* OptionalMenu.swift */,
|
||||
2A39F15626F74C2500B52876 /* AccessibleStepper.swift */,
|
||||
@ -3058,6 +3062,7 @@
|
||||
2A78BFA81D1B05FB00A583D2 /* GeneralPaneController.swift in Sources */,
|
||||
2A9082E61D324D9A00228F50 /* Geometry.swift in Sources */,
|
||||
2A5D13171D1EF5AA00D38E6A /* GoToLineView.swift in Sources */,
|
||||
2A158C1C2945A6B1000A4EC1 /* HeadingMenuItem.swift in Sources */,
|
||||
2A4A7D132856FF340085D2E7 /* HelpButton.swift in Sources */,
|
||||
2AEAA8242096380C001A175C /* HighlightExtractors.swift in Sources */,
|
||||
2AAD61F91D2BA3F5008FE772 /* HighlightParser.swift in Sources */,
|
||||
@ -3396,6 +3401,7 @@
|
||||
2A78BFA71D1B05FB00A583D2 /* GeneralPaneController.swift in Sources */,
|
||||
2A9082E51D324D9A00228F50 /* Geometry.swift in Sources */,
|
||||
2A5D13161D1EF5AA00D38E6A /* GoToLineView.swift in Sources */,
|
||||
2A158C1D2945A6B1000A4EC1 /* HeadingMenuItem.swift in Sources */,
|
||||
2A4A7D142856FF340085D2E7 /* HelpButton.swift in Sources */,
|
||||
2AEAA8232096380C001A175C /* HighlightExtractors.swift in Sources */,
|
||||
2AAD61F81D2BA3F5008FE772 /* HighlightParser.swift in Sources */,
|
||||
|
@ -218,7 +218,7 @@
|
||||
<menuItem title="DUMMY" image="magnifyingglass" catalog="system" hidden="YES" id="oXp-Kg-hET">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem title="Recent Searches" enabled="NO" id="cdV-rY-hCN">
|
||||
<menuItem title="Recent Searches" enabled="NO" id="cdV-rY-hCN" customClass="HeadingMenuItem" customModule="CotEditor" customModuleProvider="target">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" tag="-1" id="9ex-ep-oaq"/>
|
||||
@ -242,7 +242,7 @@
|
||||
<menuItem title="DUMMY" image="pencil" catalog="system" hidden="YES" id="pDj-vD-VPN">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem title="Recent Replacements" enabled="NO" id="7cw-iQ-0LM">
|
||||
<menuItem title="Recent Replacements" enabled="NO" id="7cw-iQ-0LM" customClass="HeadingMenuItem" customModule="CotEditor" customModuleProvider="target">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" tag="-1" id="dFE-4K-Okr"/>
|
||||
|
@ -948,16 +948,16 @@ CA
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="evb-xT-L0u"/>
|
||||
<menuItem title="Japanese Text" enabled="NO" id="XWV-by-mnw">
|
||||
<menuItem title="Japanese Text" enabled="NO" id="XWV-by-mnw" customClass="HeadingMenuItem" customModule="CotEditor" customModuleProvider="target">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem title="Hiragana to Katakana" indentationLevel="1" id="592">
|
||||
<menuItem title="Hiragana to Katakana" id="592">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="exchangeKatakana:" target="Ady-hI-5gd" id="pfD-db-6kI"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Katakana to Hiragana" indentationLevel="1" id="594">
|
||||
<menuItem title="Katakana to Hiragana" id="594">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="exchangeHiragana:" target="Ady-hI-5gd" id="cKm-Ib-McK"/>
|
||||
|
@ -204,10 +204,8 @@ final class DocumentWindowController: NSWindowController, NSWindowDelegate {
|
||||
menu.addItem(.separator())
|
||||
|
||||
if !recentStyleNames.isEmpty {
|
||||
let labelItem = NSMenuItem()
|
||||
labelItem.title = String(localized: "Recently Used", comment: "menu heading in syntax style list on toolbar popup")
|
||||
labelItem.isEnabled = false
|
||||
menu.addItem(labelItem)
|
||||
let title = String(localized: "Recently Used", comment: "menu heading in syntax style list on toolbar popup")
|
||||
menu.addItem(HeadingMenuItem(title: title))
|
||||
|
||||
menu.items += recentStyleNames.map { NSMenuItem(title: $0, action: action, keyEquivalent: "") }
|
||||
menu.addItem(.separator())
|
||||
@ -474,16 +472,14 @@ extension DocumentWindowController: NSToolbarDelegate {
|
||||
|
||||
case .tabStyle:
|
||||
let menu = NSMenu()
|
||||
menu.addItem(withTitle: "Tab Width".localized, action: nil, keyEquivalent: "")
|
||||
menu.addItem(HeadingMenuItem(title: "Tab Width".localized))
|
||||
menu.items += [2, 3, 4, 8]
|
||||
.map { (width) in
|
||||
let item = NSMenuItem(title: width.formatted(), action: #selector(DocumentViewController.changeTabWidth), keyEquivalent: "")
|
||||
item.tag = width
|
||||
item.indentationLevel = 1
|
||||
return item
|
||||
}
|
||||
menu.addItem(withTitle: "Custom…".localized, action: #selector(DocumentViewController.customizeTabWidth), keyEquivalent: "")
|
||||
menu.items.last?.indentationLevel = 1
|
||||
menu.addItem(.separator())
|
||||
menu.addItem(withTitle: "Expand to Spaces Automatically".localized, action: #selector(DocumentViewController.toggleAutoTabExpand), keyEquivalent: "")
|
||||
|
||||
|
60
CotEditor/Sources/HeadingMenuItem.swift
Normal file
60
CotEditor/Sources/HeadingMenuItem.swift
Normal file
@ -0,0 +1,60 @@
|
||||
//
|
||||
// HeadingMenuItem.swift
|
||||
//
|
||||
// CotEditor
|
||||
// https://coteditor.com
|
||||
//
|
||||
// Created by 1024jp on 2022-12-11.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// © 2022 1024jp
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import AppKit
|
||||
|
||||
final class HeadingMenuItem: NSMenuItem {
|
||||
|
||||
// MARK: Lifecycle
|
||||
|
||||
convenience init(title: String) {
|
||||
|
||||
self.init(title: title, action: nil, keyEquivalent: "")
|
||||
self.isEnabled = false
|
||||
|
||||
self.updateAttributedTitle()
|
||||
}
|
||||
|
||||
|
||||
override func awakeFromNib() {
|
||||
|
||||
super.awakeFromNib()
|
||||
|
||||
self.updateAttributedTitle()
|
||||
}
|
||||
|
||||
|
||||
// MARK: Private Methods
|
||||
|
||||
/// Make the menu item label heading style.
|
||||
private func updateAttributedTitle() {
|
||||
|
||||
self.attributedTitle = NSAttributedString(string: self.title, attributes: [
|
||||
.font: NSFont.systemFont(ofSize: NSFont.smallSystemFontSize, weight: .medium),
|
||||
.foregroundColor: NSColor.disabledControlTextColor,
|
||||
])
|
||||
}
|
||||
|
||||
}
|
@ -250,8 +250,7 @@ final class RegularExpressionSortPatternViewController: SortPatternViewControlle
|
||||
|
||||
menu.items.removeAll()
|
||||
menu.addItem(.init()) // dummy item
|
||||
menu.addItem(withTitle: "Recents".localized, action: nil, keyEquivalent: "")
|
||||
.isEnabled = false
|
||||
menu.addItem(HeadingMenuItem(title: "Recents".localized))
|
||||
|
||||
guard !UserDefaults.standard[.regexPatternSortHistory].isEmpty else { return }
|
||||
|
||||
|
@ -94,14 +94,12 @@ final class PrintPaneController: NSViewController {
|
||||
// build popup button
|
||||
popupButton.addItem(withTitle: ThemeName.blackAndWhite)
|
||||
popupButton.addItem(withTitle: "Same as Document’s Setting".localized)
|
||||
popupButton.menu?.addItem(.separator())
|
||||
|
||||
popupButton.addItem(withTitle: "Theme".localized)
|
||||
popupButton.lastItem?.isEnabled = false
|
||||
popupButton.menu?.addItem(.separator())
|
||||
popupButton.menu?.addItem(HeadingMenuItem(title: "Theme".localized))
|
||||
|
||||
for name in themeNames {
|
||||
popupButton.addItem(withTitle: name)
|
||||
popupButton.lastItem?.indentationLevel = 1
|
||||
}
|
||||
|
||||
// select menu
|
||||
|
@ -261,10 +261,9 @@ final class PrintPanelAccessoryController: NSViewController, NSPrintPanelAccesso
|
||||
popupButton.removeAllItems()
|
||||
|
||||
popupButton.addItem(withTitle: ThemeName.blackAndWhite)
|
||||
popupButton.menu?.addItem(.separator())
|
||||
|
||||
popupButton.addItem(withTitle: "Theme".localized)
|
||||
popupButton.lastItem?.isEnabled = false
|
||||
popupButton.menu?.addItem(.separator())
|
||||
popupButton.menu?.addItem(HeadingMenuItem(title: "Theme".localized))
|
||||
|
||||
for themeName in themeNames {
|
||||
popupButton.addItem(withTitle: themeName)
|
||||
|
@ -64,6 +64,7 @@ struct UnicodeInputView: View {
|
||||
|
||||
Menu("") {
|
||||
Text("Recents")
|
||||
.font(.system(size: NSFont.smallSystemFontSize, weight: .medium))
|
||||
let scalars = UserDefaults.standard[.unicodeHistory]
|
||||
.compactMap(UTF32.CodeUnit.init(codePoint:))
|
||||
.compactMap(UnicodeScalar.init)
|
||||
|
Loading…
Reference in New Issue
Block a user