Add quick-win features: copy-on-select, middle-click paste, visual bell, zoom pane, clickable URLs, draggable dividers
- Copy on select: Auto-copy selected text to clipboard - Middle-click paste: Quick paste with middle mouse button - Visual bell: Subtle flash when commands complete - Zoom pane: Cmd+Shift+Enter to maximize/restore split pane - Clickable URLs: Cmd+click to open URLs in browser - Draggable dividers: Resize split panes by dragging divider - Updated help and keyboard shortcuts documentation
This commit is contained in:
@@ -45,6 +45,32 @@ class TerminalSession: NSObject, NSTextViewDelegate, NSMenuDelegate {
|
||||
|
||||
// Setup suggestion label
|
||||
setupSuggestionLabel()
|
||||
|
||||
// Setup middle-click paste
|
||||
setupMiddleClickPaste()
|
||||
|
||||
// Setup clickable URLs
|
||||
setupClickableURLs()
|
||||
}
|
||||
|
||||
private func setupMiddleClickPaste() {
|
||||
let clickGesture = NSClickGestureRecognizer(target: self, action: #selector(handleMiddleClick(_:)))
|
||||
clickGesture.buttonMask = 0x4 // Middle button
|
||||
textView.addGestureRecognizer(clickGesture)
|
||||
}
|
||||
|
||||
@objc private func handleMiddleClick(_ gesture: NSClickGestureRecognizer) {
|
||||
if let pasteString = NSPasteboard.general.string(forType: .string) {
|
||||
textView.insertText(pasteString, replacementRange: textView.selectedRange())
|
||||
}
|
||||
}
|
||||
|
||||
private func setupClickableURLs() {
|
||||
textView.isAutomaticLinkDetectionEnabled = true
|
||||
textView.linkTextAttributes = [
|
||||
.foregroundColor: NSColor.systemBlue,
|
||||
.underlineStyle: NSUnderlineStyle.single.rawValue
|
||||
]
|
||||
}
|
||||
|
||||
private func setupContextMenu() {
|
||||
@@ -362,6 +388,13 @@ class TerminalSession: NSObject, NSTextViewDelegate, NSMenuDelegate {
|
||||
if selectedRange.location < promptPosition && selectedRange.length == 0 {
|
||||
textView.setSelectedRange(NSRange(location: promptPosition, length: 0))
|
||||
}
|
||||
|
||||
// Copy on select
|
||||
if TerminalSettings.shared.copyOnSelect && selectedRange.length > 0 {
|
||||
let selectedText = (textView.string as NSString).substring(with: selectedRange)
|
||||
NSPasteboard.general.clearContents()
|
||||
NSPasteboard.general.setString(selectedText, forType: .string)
|
||||
}
|
||||
}
|
||||
|
||||
private func getCurrentCommand() -> String {
|
||||
@@ -555,12 +588,34 @@ class TerminalSession: NSObject, NSTextViewDelegate, NSMenuDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
// Visual bell on command completion
|
||||
if TerminalSettings.shared.visualBell {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in
|
||||
self?.flashVisualBell()
|
||||
}
|
||||
}
|
||||
|
||||
// Show prompt after a delay
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in
|
||||
self?.showPrompt()
|
||||
}
|
||||
}
|
||||
|
||||
private func flashVisualBell() {
|
||||
guard let layer = textView.layer else { return }
|
||||
let originalBg = layer.backgroundColor
|
||||
|
||||
NSAnimationContext.runAnimationGroup({ context in
|
||||
context.duration = 0.1
|
||||
layer.backgroundColor = NSColor.white.withAlphaComponent(0.1).cgColor
|
||||
}, completionHandler: {
|
||||
NSAnimationContext.runAnimationGroup({ context in
|
||||
context.duration = 0.2
|
||||
layer.backgroundColor = originalBg
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
private func showHelp() {
|
||||
appendText("""
|
||||
Enhanced Terminal Commands:
|
||||
|
||||
Reference in New Issue
Block a user