-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.go
More file actions
103 lines (88 loc) · 1.92 KB
/
init.go
File metadata and controls
103 lines (88 loc) · 1.92 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package main
import (
"log"
tea "github.com/charmbracelet/bubbletea"
)
// Minimum terminal dimensions
const (
// MinWidth = 80
// MinHeight = 24
// Currently need 88x27 just to display 15u x 5u keyboard
MinWidth = 88
MinHeight = 27+11
)
// Screen types
type Screen int
const (
StartScreen Screen = iota
MainScreen
ConfigScreen
ExtrasScreen
)
// Messages
type ScreenChangeMsg struct {
screen Screen
}
// Command mode state
type CommandMode int
const (
NormalMode CommandMode = iota
CommandModeActive
SearchModeActive
)
// Main application model
type Model struct {
currentScreen Screen
termWidth int
termHeight int
ready bool
err error
menuSelection int // For navigating menu items
commandMode CommandMode
commandInput string
commandError string
config Config
keyboard Keyboard
prompt string
userInput string
currentChar int
prompts []string
promptIndex int
pressedKeys map[string]bool
}
// Initialize the application
func InitialModel(config string) Model {
log.Println("init.InitialModel()")
var prompts = []string{
"Pack my box with five dozen liquor jugs.",
"The quick brown fox jumps over the lazy dog.",
"Waltz, bad nymph, for quick jigs vex.",
"How vexingly quick daft zebras jump!",
"Bright vixens jump; dozy fowl quack.",
}
kb, err := loadKeyboard(config)
if err != nil {
log.Fatalf("Failed to load keyboard: %v", err)
}
return Model{
currentScreen: StartScreen,
ready: false,
menuSelection: 0,
commandMode: NormalMode,
commandInput: "",
commandError: "",
config: DefaultConfig(),
keyboard: kb,
prompts: prompts,
promptIndex: 0,
prompt: prompts[0],
userInput: "",
currentChar: 0,
pressedKeys: make(map[string]bool),
}
}
// Init method (required by tea.Model interface)
func (m Model) Init() tea.Cmd {
log.Println("init.Init()")
return nil
}