Skip to content

Commit

Permalink
feat: alternate AM keys
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelBelsanti committed Mar 23, 2024
1 parent 0a8071f commit e1d461f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions config/config.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"show_initial_entries": true,
"fullscreen": false,
"disable_activation_mode": false,
"am_key": "control",
"search": {
"delay": 0,
"hide_icons": false
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Config struct {
DisableActivationMode bool `json:"disable_activation_mode,omitempty"`
Clipboard Clipboard `json:"clipboard,omitempty"`
Runner Runner `json:"runner,omitempty"`
AMKey string `json:"am_key,omitempty"`
}

type Clipboard struct {
Expand Down
18 changes: 16 additions & 2 deletions ui/interactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
var (
keys map[uint]uint
activationEnabled bool
amKey uint
amModifier gdk.ModifierType
)

func setupInteractions(appstate *state.AppState) {
Expand Down Expand Up @@ -87,6 +89,18 @@ func setupInteractions(appstate *state.AppState) {

ui.list.AddController(listkc)
}

switch cfg.AMKey {
case "control":
amKey = gdk.KEY_Control_L
amModifier = gdk.ControlMask
case "alt":
amKey = gdk.KEY_Alt_L
amModifier = gdk.AltMask
default:
amKey = gdk.KEY_Control_L
amModifier = gdk.ControlMask
}
}

func selectNext() {
Expand Down Expand Up @@ -151,7 +165,7 @@ func handleListKeysPressed(val uint, code uint, modifier gdk.ModifierType) bool
disabledAM()
case gdk.KEY_j, gdk.KEY_k, gdk.KEY_l, gdk.KEY_semicolon, gdk.KEY_a, gdk.KEY_s, gdk.KEY_d, gdk.KEY_f:
if !cfg.DisableActivationMode {
if modifier == gdk.ControlMask {
if modifier == amModifier {
selectActivationMode(val, true)
} else {
selectActivationMode(val, false)
Expand All @@ -166,7 +180,7 @@ func handleListKeysPressed(val uint, code uint, modifier gdk.ModifierType) bool

func handleSearchKeysPressed(val uint, code uint, modifier gdk.ModifierType) bool {
if !cfg.DisableActivationMode && ui.selection.NItems() != 0 {
if val == gdk.KEY_Control_L {
if val == amKey {
c := ui.appwin.CSSClasses()
c = append(c, "activation")
ui.appwin.SetCSSClasses(c)
Expand Down

0 comments on commit e1d461f

Please sign in to comment.