Skip to content

Commit 8510d03

Browse files
authored
fix: make action hints style configurable to be visually difference (#22)
1 parent 5f8e29e commit 8510d03

3 files changed

Lines changed: 82 additions & 5 deletions

File tree

cmd/govim/main.go

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,23 @@ func (a *App) activateHintMode(withActions bool) {
348348
a.currentHints = hints.NewHintCollection(hintList)
349349

350350
// Draw hints
351-
if err := a.hintOverlay.DrawHints(hintList); err != nil {
352-
a.logger.Error("Failed to draw hints", zap.Error(err))
353-
return
351+
// Use distinct colors when entering hint mode with actions
352+
if withActions {
353+
style := a.config.Hints
354+
style.BackgroundColor = a.config.Hints.ActionBackgroundColor
355+
style.TextColor = a.config.Hints.ActionTextColor
356+
style.MatchedTextColor = a.config.Hints.ActionMatchedTextColor
357+
style.BorderColor = a.config.Hints.ActionBorderColor
358+
style.Opacity = a.config.Hints.ActionOpacity
359+
if err := a.hintOverlay.DrawHintsWithStyle(hintList, style); err != nil {
360+
a.logger.Error("Failed to draw hints", zap.Error(err))
361+
return
362+
}
363+
} else {
364+
if err := a.hintOverlay.DrawHints(hintList); err != nil {
365+
a.logger.Error("Failed to draw hints", zap.Error(err))
366+
return
367+
}
354368
}
355369

356370
a.hintOverlay.Show()
@@ -456,8 +470,20 @@ func (a *App) handleHintKey(key string) {
456470
hint.MatchedPrefix = a.hintInput
457471
}
458472
a.hintOverlay.Clear()
459-
if err := a.hintOverlay.DrawHints(filtered); err != nil {
460-
a.logger.Error("Failed to redraw hints", zap.Error(err))
473+
if a.currentMode == ModeHintWithActions {
474+
style := a.config.Hints
475+
style.BackgroundColor = a.config.Hints.ActionBackgroundColor
476+
style.TextColor = a.config.Hints.ActionTextColor
477+
style.MatchedTextColor = a.config.Hints.ActionMatchedTextColor
478+
style.BorderColor = a.config.Hints.ActionBorderColor
479+
style.Opacity = a.config.Hints.ActionOpacity
480+
if err := a.hintOverlay.DrawHintsWithStyle(filtered, style); err != nil {
481+
a.logger.Error("Failed to redraw hints", zap.Error(err))
482+
}
483+
} else {
484+
if err := a.hintOverlay.DrawHints(filtered); err != nil {
485+
a.logger.Error("Failed to redraw hints", zap.Error(err))
486+
}
461487
}
462488

463489
// If exactly one match and input matches the full label
@@ -534,6 +560,13 @@ func (a *App) showActionMenu(hint *hints.Hint) {
534560

535561
// Create smaller style for action hints
536562
actionStyle := a.config.Hints
563+
// Apply distinct colors for action overlay from config
564+
actionStyle.BackgroundColor = a.config.Hints.ActionBackgroundColor
565+
actionStyle.TextColor = a.config.Hints.ActionTextColor
566+
actionStyle.MatchedTextColor = a.config.Hints.ActionMatchedTextColor
567+
actionStyle.BorderColor = a.config.Hints.ActionBorderColor
568+
actionStyle.Opacity = a.config.Hints.ActionOpacity
569+
// Use smaller sizing for action hints
537570
actionStyle.FontSize = 11 // Smaller font
538571
actionStyle.Padding = 3 // Less padding
539572
actionStyle.BorderRadius = 3 // Smaller border radius

configs/default-config.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,22 @@ border_color = "#000000"
9292
# Opacity (0.0 to 1.0)
9393
opacity = 0.95
9494

95+
# Action overlay colors (used when selecting click type)
96+
# Background color (hex format)
97+
action_background_color = "#66CCFF"
98+
99+
# Text color (hex format)
100+
action_text_color = "#000000"
101+
102+
# Matched text color (hex format)
103+
action_matched_text_color = "#003366"
104+
105+
# Border color (hex format)
106+
action_border_color = "#000000"
107+
108+
# Opacity (0.0 to 1.0)
109+
action_opacity = 0.95
110+
95111
# Action keys for hint mode with actions (hardcoded):
96112
# l = left click, r = right click, d = double click, m = middle click
97113

internal/config/config.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ type HintsConfig struct {
7171
Opacity float64 `toml:"opacity"`
7272
Menubar bool `toml:"menubar"`
7373
Dock bool `toml:"dock"`
74+
// Action overlay specific colors and opacity
75+
ActionBackgroundColor string `toml:"action_background_color"`
76+
ActionTextColor string `toml:"action_text_color"`
77+
ActionMatchedTextColor string `toml:"action_matched_text_color"`
78+
ActionBorderColor string `toml:"action_border_color"`
79+
ActionOpacity float64 `toml:"action_opacity"`
7480
}
7581

7682
type PerformanceConfig struct {
@@ -150,6 +156,12 @@ func DefaultConfig() *Config {
150156
Opacity: 0.95,
151157
Menubar: false,
152158
Dock: false,
159+
// Defaults for action overlay colors to visually differentiate
160+
ActionBackgroundColor: "#66CCFF",
161+
ActionTextColor: "#000000",
162+
ActionMatchedTextColor: "#003366",
163+
ActionBorderColor: "#000000",
164+
ActionOpacity: 0.95,
153165
},
154166
Performance: PerformanceConfig{
155167
MaxHintsDisplayed: 200,
@@ -255,6 +267,9 @@ func (c *Config) Validate() error {
255267
if c.Hints.Opacity < 0 || c.Hints.Opacity > 1 {
256268
return fmt.Errorf("hints.opacity must be between 0 and 1")
257269
}
270+
if c.Hints.ActionOpacity < 0 || c.Hints.ActionOpacity > 1 {
271+
return fmt.Errorf("hints.action_opacity must be between 0 and 1")
272+
}
258273

259274
// Validate performance settings
260275
if c.Performance.MaxHintsDisplayed < 1 {
@@ -288,6 +303,19 @@ func (c *Config) Validate() error {
288303
if err := validateColor(c.Hints.BorderColor, "hints.border_color"); err != nil {
289304
return err
290305
}
306+
// Validate action overlay colors
307+
if err := validateColor(c.Hints.ActionBackgroundColor, "hints.action_background_color"); err != nil {
308+
return err
309+
}
310+
if err := validateColor(c.Hints.ActionTextColor, "hints.action_text_color"); err != nil {
311+
return err
312+
}
313+
if err := validateColor(c.Hints.ActionMatchedTextColor, "hints.action_matched_text_color"); err != nil {
314+
return err
315+
}
316+
if err := validateColor(c.Hints.ActionBorderColor, "hints.action_border_color"); err != nil {
317+
return err
318+
}
291319
if err := validateColor(c.Scroll.HighlightColor, "scroll.highlight_color"); err != nil {
292320
return err
293321
}

0 commit comments

Comments
 (0)