mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-21 04:17:45 +02:00
Add support for control-A and control-E shortcuts similar to GNU readline
This commit is contained in:
parent
0787840a10
commit
199307f74a
@ -2089,6 +2089,14 @@ func testTui_general(t *testing.T, onlineStatus OnlineStatus) {
|
|||||||
out = strings.Split(stripTuiCommandPrefix(t, out), "\n")[0]
|
out = strings.Split(stripTuiCommandPrefix(t, out), "\n")[0]
|
||||||
testutils.CompareGoldens(t, out, "TestTui-SelectAndCd")
|
testutils.CompareGoldens(t, out, "TestTui-SelectAndCd")
|
||||||
|
|
||||||
|
// Test jumping around the cursor via shortcuts
|
||||||
|
out = captureTerminalOutput(t, tester, []string{
|
||||||
|
"hishtory SPACE tquery ENTER",
|
||||||
|
"foo C-a AAA C-e ZZZ",
|
||||||
|
})
|
||||||
|
out = strings.Split(stripTuiCommandPrefix(t, out), "\n")[0]
|
||||||
|
testutils.CompareGoldens(t, out, "TestTui-JumpCursor")
|
||||||
|
|
||||||
// Test the User column
|
// Test the User column
|
||||||
tester.RunInteractiveShell(t, `hishtory config-add displayed-columns User`)
|
tester.RunInteractiveShell(t, `hishtory config-add displayed-columns User`)
|
||||||
out = captureTerminalOutput(t, tester, []string{
|
out = captureTerminalOutput(t, tester, []string{
|
||||||
|
1
client/testdata/TestTui-JumpCursor
vendored
Normal file
1
client/testdata/TestTui-JumpCursor
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
Search Query: > AAAfooZZZ
|
@ -56,6 +56,8 @@ type keyMap struct {
|
|||||||
DeleteEntry key.Binding
|
DeleteEntry key.Binding
|
||||||
Help key.Binding
|
Help key.Binding
|
||||||
Quit key.Binding
|
Quit key.Binding
|
||||||
|
JumpStartOfInput key.Binding
|
||||||
|
JumpEndOfInput key.Binding
|
||||||
}
|
}
|
||||||
|
|
||||||
var fakeTitleKeyBinding key.Binding = key.NewBinding(
|
var fakeTitleKeyBinding key.Binding = key.NewBinding(
|
||||||
@ -134,6 +136,14 @@ var keys = keyMap{
|
|||||||
key.WithKeys("esc", "ctrl+c", "ctrl+d"),
|
key.WithKeys("esc", "ctrl+c", "ctrl+d"),
|
||||||
key.WithHelp("esc", "exit hiSHtory "),
|
key.WithHelp("esc", "exit hiSHtory "),
|
||||||
),
|
),
|
||||||
|
JumpStartOfInput: key.NewBinding(
|
||||||
|
key.WithKeys("ctrl+a"),
|
||||||
|
key.WithHelp("ctrl+a", "jump to the start of the input "),
|
||||||
|
),
|
||||||
|
JumpEndOfInput: key.NewBinding(
|
||||||
|
key.WithKeys("ctrl+e"),
|
||||||
|
key.WithHelp("ctrl+e", "jump to the end of the input "),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
type SelectStatus int64
|
type SelectStatus int64
|
||||||
@ -341,6 +351,12 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
case key.Matches(msg, keys.Help):
|
case key.Matches(msg, keys.Help):
|
||||||
m.help.ShowAll = !m.help.ShowAll
|
m.help.ShowAll = !m.help.ShowAll
|
||||||
return m, nil
|
return m, nil
|
||||||
|
case key.Matches(msg, keys.JumpStartOfInput):
|
||||||
|
m.queryInput.SetCursor(0)
|
||||||
|
return m, nil
|
||||||
|
case key.Matches(msg, keys.JumpEndOfInput):
|
||||||
|
m.queryInput.SetCursor(len(m.queryInput.Value()))
|
||||||
|
return m, nil
|
||||||
default:
|
default:
|
||||||
pendingCommands := tea.Batch()
|
pendingCommands := tea.Batch()
|
||||||
if m.table != nil {
|
if m.table != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user