Add Strong text shortcut
This commit is contained in:
parent
14ec2eb2a5
commit
c949b0b316
@ -85,6 +85,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
UserDefaults.standard.set(String(sender.state), forKey: "night_mode_state")
|
UserDefaults.standard.set(String(sender.state), forKey: "night_mode_state")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@IBAction func formatStrong(_ sender: Any) {
|
||||||
|
let wc = NSApplication.shared().mainWindow?.windowController as? WindowController
|
||||||
|
wc?.embolden()
|
||||||
|
}
|
||||||
|
|
||||||
@IBAction func setFontSerif(_ sender: NSMenuItem) {
|
@IBAction func setFontSerif(_ sender: NSMenuItem) {
|
||||||
deselectAllFonts()
|
deselectAllFonts()
|
||||||
sender.state = NSOnState
|
sender.state = NSOnState
|
||||||
|
@ -322,6 +322,12 @@ DQ
|
|||||||
</items>
|
</items>
|
||||||
</menu>
|
</menu>
|
||||||
</menuItem>
|
</menuItem>
|
||||||
|
<menuItem isSeparatorItem="YES" id="A2K-0R-RPV"/>
|
||||||
|
<menuItem title="Strong" keyEquivalent="b" id="iGK-Hg-zxc">
|
||||||
|
<connections>
|
||||||
|
<action selector="formatStrong:" target="Voe-Tx-rLC" id="Cpe-8G-6Yo"/>
|
||||||
|
</connections>
|
||||||
|
</menuItem>
|
||||||
</items>
|
</items>
|
||||||
</menu>
|
</menu>
|
||||||
</menuItem>
|
</menuItem>
|
||||||
|
@ -86,6 +86,19 @@ class ViewController: NSViewController, NSTextViewDelegate, NSUserNotificationCe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func embolden() {
|
||||||
|
let selectedRange = writerText.selectedRange()
|
||||||
|
let selString = (self.writerText.textStorage?.string as! NSString).substring(with: selectedRange)
|
||||||
|
let repString = "**\(selString)**"
|
||||||
|
if self.writerText.shouldChangeText(in: selectedRange, replacementString: repString) {
|
||||||
|
self.writerText.replaceCharacters(in: NSRange(location: selectedRange.location, length: selectedRange.length), with: repString)
|
||||||
|
self.writerText.didChangeText()
|
||||||
|
if selString == "" {
|
||||||
|
writerText.setSelectedRange(NSRange(location: selectedRange.location + 2, length: 0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func publish() {
|
func publish() {
|
||||||
saveDocument()
|
saveDocument()
|
||||||
|
|
||||||
|
@ -27,4 +27,8 @@ class WindowController: NSWindowController {
|
|||||||
func toggle(isNight: Bool) {
|
func toggle(isNight: Bool) {
|
||||||
vc?.toggle(isNight: isNight)
|
vc?.toggle(isNight: isNight)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func embolden() {
|
||||||
|
vc?.embolden()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user