@@ -105,7 +105,7 @@ func (m *model) View() string {
105
105
keyboard = ""
106
106
}
107
107
108
- game := lipgloss .JoinVertical (lipgloss .Center , status , grid , keyboard )
108
+ game := lipgloss .JoinVertical (lipgloss .Center , status , grid , keyboard , _controls )
109
109
return lipgloss .Place (m .width , m .height , lipgloss .Center , lipgloss .Center , game )
110
110
}
111
111
@@ -256,7 +256,7 @@ func (m *model) doLoss() tea.Cmd {
256
256
257
257
// viewStatus renders the status line.
258
258
func (m * model ) viewStatus () string {
259
- return m .status
259
+ return lipgloss . NewStyle (). Foreground ( colorPrimary ). Render ( m .status )
260
260
}
261
261
262
262
// viewGrid renders the grid.
@@ -325,7 +325,7 @@ func (m *model) viewGridRowCurrent(row [numChars]byte, rowIdx int) string {
325
325
} else {
326
326
key = " "
327
327
}
328
- keys [i ] = m .viewKey (key , keyStateUnselected . color () )
328
+ keys [i ] = m .viewKey (key , colorPrimary )
329
329
}
330
330
return lipgloss .JoinHorizontal (lipgloss .Bottom , keys [:]... )
331
331
}
@@ -409,6 +409,14 @@ func (m *model) reportError(err error, msg string) tea.Cmd {
409
409
// msgResetStatus is sent when the status line should be reset.
410
410
type msgResetStatus struct {}
411
411
412
+ const (
413
+ colorPrimary = lipgloss .Color ("#d7dadc" )
414
+ colorSecondary = lipgloss .Color ("#626262" )
415
+ colorSeparator = lipgloss .Color ("#9c9c9c" )
416
+ colorYellow = lipgloss .Color ("#b59f3b" )
417
+ colorGreen = lipgloss .Color ("#538d4e" )
418
+ )
419
+
412
420
// keyState represents the state of a key.
413
421
type keyState int
414
422
@@ -421,27 +429,28 @@ const (
421
429
422
430
// color returns the appropriate dark mode color for the given key state.
423
431
func (s keyState ) color () lipgloss.Color {
424
- const (
425
- colorPrimary = lipgloss .Color ("#d7dadc" )
426
- colorAbsent = lipgloss .Color ("#3a3a3c" )
427
- colorPresent = lipgloss .Color ("#b59f3b" )
428
- colorCorrect = lipgloss .Color ("#538d4e" )
429
- )
430
-
431
432
switch s {
432
433
case keyStateUnselected :
433
434
return colorPrimary
434
435
case keyStateAbsent :
435
- return colorAbsent
436
+ return colorSecondary
436
437
case keyStatePresent :
437
- return colorPresent
438
+ return colorYellow
438
439
case keyStateCorrect :
439
- return colorCorrect
440
+ return colorGreen
440
441
default :
441
442
panic ("invalid key status" )
442
443
}
443
444
}
444
445
446
+ var _controls = fmt .Sprintf ("%s %s %s %s %s" ,
447
+ lipgloss .NewStyle ().Foreground (colorPrimary ).Render ("ctrl+c" ),
448
+ lipgloss .NewStyle ().Foreground (colorSecondary ).Render ("quit" ),
449
+ lipgloss .NewStyle ().Foreground (colorSeparator ).Render ("//" ),
450
+ lipgloss .NewStyle ().Foreground (colorPrimary ).Render ("ctrl+r" ),
451
+ lipgloss .NewStyle ().Foreground (colorSecondary ).Render ("restart" ),
452
+ )
453
+
445
454
// isAsciiUpper checks if a rune is between A-Z.
446
455
func isAsciiUpper (r rune ) bool {
447
456
return 'A' <= r && r <= 'Z'
0 commit comments