mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Add Touch Bar item to toggle indent guides
This commit is contained in:
parent
4d0b209973
commit
826573eb9b
@ -7,7 +7,7 @@ Change Log
|
||||
|
||||
### Improvements
|
||||
|
||||
- [beta] Add menu item and toolbar item to toggle visibility of indent guides in the current document.
|
||||
- [beta] Add menu item, toolbar item, and Touch Bar item to toggle visibility of indent guides in the current document.
|
||||
- [beta] Adjust the vertical position of the line ending symbol.
|
||||
- [beta] Make the indent guide drawing pixel-perfect.
|
||||
|
||||
|
15
CotEditor/Assets.xcassets/Touchbar Icons/IndentGuidesTemplate.imageset/Contents.json
vendored
Normal file
15
CotEditor/Assets.xcassets/Touchbar Icons/IndentGuidesTemplate.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "IndentGuidesTemplate.pdf",
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
BIN
CotEditor/Assets.xcassets/Touchbar Icons/IndentGuidesTemplate.imageset/IndentGuidesTemplate.pdf
vendored
Normal file
BIN
CotEditor/Assets.xcassets/Touchbar Icons/IndentGuidesTemplate.imageset/IndentGuidesTemplate.pdf
vendored
Normal file
Binary file not shown.
@ -34,6 +34,7 @@ private extension NSTouchBar.CustomizationIdentifier {
|
||||
extension NSTouchBarItem.Identifier {
|
||||
|
||||
static let invisibles = NSTouchBarItem.Identifier("com.coteditor.CotEditor.TouchBarItem.invisibles")
|
||||
static let indentGuides = NSTouchBarItem.Identifier("com.coteditor.CotEditor.TouchBarItem.indentGuides")
|
||||
static let wrapLines = NSTouchBarItem.Identifier("com.coteditor.CotEditor.TouchBarItem.wrapLines")
|
||||
static let share = NSTouchBarItem.Identifier("com.coteditor.CotEditor.TouchBarItem.share")
|
||||
}
|
||||
@ -52,8 +53,8 @@ extension DocumentViewController: NSTouchBarDelegate {
|
||||
|
||||
touchBar.delegate = self
|
||||
touchBar.customizationIdentifier = .documentView
|
||||
touchBar.defaultItemIdentifiers = [.otherItemsProxy, .fixedSpaceSmall, .invisibles, .wrapLines]
|
||||
touchBar.customizationAllowedItemIdentifiers = [.share, .invisibles, .wrapLines]
|
||||
touchBar.defaultItemIdentifiers = [.otherItemsProxy, .fixedSpaceSmall, .invisibles, .wrapLines, .share]
|
||||
touchBar.customizationAllowedItemIdentifiers = [.share, .invisibles, .indentGuides, .wrapLines]
|
||||
|
||||
return touchBar
|
||||
}
|
||||
@ -71,6 +72,12 @@ extension DocumentViewController: NSTouchBarDelegate {
|
||||
item.view = NSButton(image: #imageLiteral(resourceName: "InvisiblesTemplate"), target: self, action: #selector(toggleInvisibleCharsViaTouchBar))
|
||||
return item
|
||||
|
||||
case .indentGuides:
|
||||
let item = NSCustomTouchBarItem(identifier: identifier)
|
||||
item.customizationLabel = "Indent Guides".localized(comment: "touch bar item")
|
||||
item.view = NSButton(image: #imageLiteral(resourceName: "IndentGuidesTemplate"), target: self, action: #selector(toggleIndentGuidesViaTouchBar))
|
||||
return item
|
||||
|
||||
case .wrapLines:
|
||||
let item = NSCustomTouchBarItem(identifier: identifier)
|
||||
item.customizationLabel = "Wrap Lines".localized(comment: "touch bar item")
|
||||
@ -93,11 +100,15 @@ extension DocumentViewController: NSTouchBarDelegate {
|
||||
@IBAction private func toggleInvisibleCharsViaTouchBar(_ sender: NSButton) {
|
||||
|
||||
self.toggleInvisibleChars(sender)
|
||||
self.validateUserInterfaceForTouchBarEvent()
|
||||
}
|
||||
|
||||
|
||||
/// toggle visibility of invisible characters in text view
|
||||
@IBAction private func toggleIndentGuidesViaTouchBar(_ sender: NSButton) {
|
||||
|
||||
// update UI manually
|
||||
// -> Workaround for the issue where UI doesn't update on a touch bar event. (2017-01 macOS 10.12.2 SDK)
|
||||
self.view.window?.toolbar?.validateVisibleItems()
|
||||
self.touchBar?.validateVisibleItems()
|
||||
self.toggleIndentGuides(sender)
|
||||
self.validateUserInterfaceForTouchBarEvent()
|
||||
}
|
||||
|
||||
|
||||
@ -105,9 +116,18 @@ extension DocumentViewController: NSTouchBarDelegate {
|
||||
@IBAction private func toggleLineWrapViaTouchBar(_ sender: NSButton) {
|
||||
|
||||
self.toggleLineWrap(sender)
|
||||
self.validateUserInterfaceForTouchBarEvent()
|
||||
}
|
||||
|
||||
|
||||
|
||||
// MARK: Private Methods
|
||||
|
||||
/// Update UI manually.
|
||||
///
|
||||
/// Workaround for the issue where UI doesn't update on a touch bar event. (2017-01 macOS 10.12.2 SDK)
|
||||
private func validateUserInterfaceForTouchBarEvent() {
|
||||
|
||||
// update UI manually
|
||||
// -> Workaround for the issue where UI doesn't update on a touch bar event. (2017-01 macOS 10.12.2 SDK)
|
||||
self.view.window?.toolbar?.validateVisibleItems()
|
||||
self.touchBar?.validateVisibleItems()
|
||||
}
|
||||
@ -127,6 +147,9 @@ extension DocumentViewController: TouchBarItemValidations {
|
||||
case .invisibles:
|
||||
return self.showsInvisibles
|
||||
|
||||
case .indentGuides:
|
||||
return self.showsIndentGuides
|
||||
|
||||
case .wrapLines:
|
||||
return self.wrapsLines
|
||||
|
||||
|
@ -176,6 +176,7 @@
|
||||
/* MARK: Touch Bar */
|
||||
// Touch bar item labels -Document View
|
||||
"Invisibles" = "Steuerzeichen";
|
||||
"Indent Guides" = "Einzugshilfslinien";
|
||||
"Wrap Lines" = "Zeilen umbrechen";
|
||||
|
||||
// Touch bar item labels -Text View
|
||||
|
@ -175,6 +175,7 @@
|
||||
/* MARK: Touch Bar */
|
||||
// Touch bar item labels -Document View
|
||||
"Invisibles" = "Caractères invisibles";
|
||||
"Indent Guides" = "Indent Guides"; // FIXME: added
|
||||
"Wrap Lines" = "Renvoyer à la ligne";
|
||||
|
||||
// Touch bar item labels -Text View
|
||||
|
@ -177,6 +177,7 @@
|
||||
/* MARK: Touch Bar */
|
||||
// Touch bar item labels -Document View
|
||||
"Invisibles" = "Invisibili";
|
||||
"Indent Guides" = "Indent Guides"; // FIXME: added
|
||||
"Wrap Lines" = "Aapo automatico";
|
||||
|
||||
// Touch bar item labels -Text View
|
||||
|
@ -177,6 +177,7 @@
|
||||
/* MARK: Touch Bar */
|
||||
// Touch bar item labels -Document View
|
||||
"Invisibles" = "不可視文字";
|
||||
"Indent Guides" = "インデントガイド";
|
||||
"Wrap Lines" = "行を折り返す";
|
||||
|
||||
// Touch bar item labels -Text View
|
||||
|
@ -177,6 +177,7 @@
|
||||
/* MARK: Touch Bar */
|
||||
// Touch bar item labels -Document View
|
||||
"Invisibles" = "Invisíveis";
|
||||
"Indent Guides" = "Indent Guides"; // FIXME: added
|
||||
"Wrap Lines" = "Ajustar Linhas";
|
||||
|
||||
// Touch bar item labels -Text View
|
||||
|
@ -177,6 +177,7 @@
|
||||
/* MARK: Touch Bar */
|
||||
// Touch bar item labels -Document View
|
||||
"Invisibles" = "不可见元素";
|
||||
"Indent Guides" = "Indent Guides"; // FIXME: added
|
||||
"Wrap Lines" = "换行";
|
||||
|
||||
// Touch bar item labels -Text View
|
||||
|
Loading…
Reference in New Issue
Block a user