mirror of
https://github.com/Eugeny/tabby.git
synced 2025-09-24 00:56:06 +00:00
make ctrl-f select the search query
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { Injectable, Inject, NgZone, EventEmitter } from '@angular/core'
|
import { Injectable, Inject, NgZone, EventEmitter } from '@angular/core'
|
||||||
import { Observable, Subject } from 'rxjs'
|
import { Observable, Subject, filter } from 'rxjs'
|
||||||
import { HotkeyDescription, HotkeyProvider } from '../api/hotkeyProvider'
|
import { HotkeyDescription, HotkeyProvider } from '../api/hotkeyProvider'
|
||||||
import { KeyEventData, getKeyName, Keystroke, KeyName, getKeystrokeName, metaKeyName, altKeyName } from './hotkeys.util'
|
import { KeyEventData, getKeyName, Keystroke, KeyName, getKeystrokeName, metaKeyName, altKeyName } from './hotkeys.util'
|
||||||
import { ConfigService } from './config.service'
|
import { ConfigService } from './config.service'
|
||||||
@@ -28,7 +28,16 @@ export class HotkeysService {
|
|||||||
/**
|
/**
|
||||||
* Fired for each recognized hotkey
|
* Fired for each recognized hotkey
|
||||||
*/
|
*/
|
||||||
get hotkey$ (): Observable<string> { return this._hotkey }
|
get unfilteredHotkey$ (): Observable<string> { return this._hotkey }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fired for each recognized hotkey
|
||||||
|
*/
|
||||||
|
get hotkey$ (): Observable<string> {
|
||||||
|
return this._hotkey.pipe(filter(() => {
|
||||||
|
return document.querySelectorAll('input:focus').length === 0
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired for once hotkey is released
|
* Fired for once hotkey is released
|
||||||
@@ -292,11 +301,9 @@ export class HotkeysService {
|
|||||||
this.emitHotkeyOff(this.pressedHotkey)
|
this.emitHotkeyOff(this.pressedHotkey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (document.querySelectorAll('input:focus').length === 0) {
|
console.debug('Matched hotkey', hotkey)
|
||||||
console.debug('Matched hotkey', hotkey)
|
this._hotkey.next(hotkey)
|
||||||
this._hotkey.next(hotkey)
|
this.pressedHotkey = hotkey
|
||||||
this.pressedHotkey = hotkey
|
|
||||||
}
|
|
||||||
this.recognitionPhase = false
|
this.recognitionPhase = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -191,6 +191,20 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
|||||||
this.logger = this.log.create('baseTerminalTab')
|
this.logger = this.log.create('baseTerminalTab')
|
||||||
this.setTitle(this.translate.instant('Terminal'))
|
this.setTitle(this.translate.instant('Terminal'))
|
||||||
|
|
||||||
|
this.subscribeUntilDestroyed(this.hotkeys.unfilteredHotkey$, async hotkey => {
|
||||||
|
if (!this.hasFocus) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (hotkey === 'search') {
|
||||||
|
this.showSearchPanel = true
|
||||||
|
setImmediate(() => {
|
||||||
|
const input = this.element.nativeElement.querySelector('.search-input')
|
||||||
|
input?.focus()
|
||||||
|
input?.select()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
this.subscribeUntilDestroyed(this.hotkeys.hotkey$, async hotkey => {
|
this.subscribeUntilDestroyed(this.hotkeys.hotkey$, async hotkey => {
|
||||||
if (!this.hasFocus) {
|
if (!this.hasFocus) {
|
||||||
return
|
return
|
||||||
@@ -265,14 +279,6 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
|||||||
}[this.hostApp.platform])
|
}[this.hostApp.platform])
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
case 'search':
|
|
||||||
this.showSearchPanel = true
|
|
||||||
setImmediate(() => {
|
|
||||||
const input = this.element.nativeElement.querySelector('.search-input')
|
|
||||||
input?.focus()
|
|
||||||
input?.select()
|
|
||||||
})
|
|
||||||
break
|
|
||||||
case 'pane-focus-all':
|
case 'pane-focus-all':
|
||||||
this.focusAllPanes()
|
this.focusAllPanes()
|
||||||
break
|
break
|
||||||
|
Reference in New Issue
Block a user