DEVELOPMENT ENVIRONMENT

~liljamo/tamma

ref: b6eee0eb2d241b747c16e18ca4da4a1c145c3485 tamma/types/keymaps.go -rw-r--r-- 1.8 KiB
b6eee0ebJonni Liljamo feat: add a way to view output 30 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
 * Copyright (C) 2025 Jonni Liljamo <jonni@liljamo.com>
 *
 * This file is licensed under GPL-3.0-only, see NOTICE and LICENSE for
 * more information.
 */

package types

import (
	"github.com/charmbracelet/bubbles/key"
)

// TargetListKeyMap defines key bindings for the target list.
type TargetListKeyMap struct {
	Quit key.Binding
}

// NewTargetListKeyMap returns a new TargetListKeyMap.
func NewTargetListKeyMap() *TargetListKeyMap {
	return &TargetListKeyMap{
		Quit: key.NewBinding(
			key.WithKeys("q"),
			key.WithHelp("q", "quit"),
		),
	}
}

// ActionListKeyMap defines key bindings for the action list.
type ActionListKeyMap struct {
	Back        key.Binding
	CopyCommand key.Binding
	ViewOutput  key.Binding
}

// NewActionListKeyMap returns a new ActionListKeyMap.
func NewActionListKeyMap() *ActionListKeyMap {
	return &ActionListKeyMap{
		Back: key.NewBinding(
			key.WithKeys("q"),
			key.WithHelp("q", "back"),
		),
		CopyCommand: key.NewBinding(
			key.WithKeys("c"),
			key.WithHelp("c", "copy cmd"),
		),
		ViewOutput: key.NewBinding(
			key.WithKeys("o"),
			key.WithHelp("o", "view output"),
		),
	}
}

// OutputViewportKeyMap defines key bindings for the output viewport.
type OutputViewportKeyMap struct {
	Back key.Binding
}

// NewOutputViewportKeyMap returns a new OutputViewportKeyMap.
func NewOutputViewportKeyMap() *OutputViewportKeyMap {
	return &OutputViewportKeyMap{
		Back: key.NewBinding(
			key.WithKeys("q"),
			key.WithHelp("q", "back"),
		),
	}
}

// ShortHelp returns keybindings to be shown in the mini help view. It's part
// of the key.Map interface.
func (k OutputViewportKeyMap) ShortHelp() []key.Binding {
	return []key.Binding{k.Back}
}

// FullHelp returns keybindings for the expanded help view. It's part of the
// key.Map interface.
func (k OutputViewportKeyMap) FullHelp() [][]key.Binding {
	return [][]key.Binding{
		{k.Back},
	}
}