-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoverage.html
More file actions
4576 lines (3865 loc) · 182 KB
/
Copy pathcoverage.html
File metadata and controls
4576 lines (3865 loc) · 182 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>cheat-go: Go Coverage Report</title>
<style>
body {
background: black;
color: rgb(80, 80, 80);
}
body, pre, #legend span {
font-family: Menlo, monospace;
font-weight: bold;
}
#topbar {
background: black;
position: fixed;
top: 0; left: 0; right: 0;
height: 42px;
border-bottom: 1px solid rgb(80, 80, 80);
}
#content {
margin-top: 50px;
}
#nav, #legend {
float: left;
margin-left: 10px;
}
#legend {
margin-top: 12px;
}
#nav {
margin-top: 10px;
}
#legend span {
margin: 0 5px;
}
.cov0 { color: rgb(192, 0, 0) }
.cov1 { color: rgb(128, 128, 128) }
.cov2 { color: rgb(116, 140, 131) }
.cov3 { color: rgb(104, 152, 134) }
.cov4 { color: rgb(92, 164, 137) }
.cov5 { color: rgb(80, 176, 140) }
.cov6 { color: rgb(68, 188, 143) }
.cov7 { color: rgb(56, 200, 146) }
.cov8 { color: rgb(44, 212, 149) }
.cov9 { color: rgb(32, 224, 152) }
.cov10 { color: rgb(20, 236, 155) }
</style>
</head>
<body>
<div id="topbar">
<div id="nav">
<select id="files">
<option value="file0">cheat-go/main.go (60.4%)</option>
<option value="file1">cheat-go/pkg/apps/registry.go (73.0%)</option>
<option value="file2">cheat-go/pkg/apps/types.go (100.0%)</option>
<option value="file3">cheat-go/pkg/cache/cache.go (46.1%)</option>
<option value="file4">cheat-go/pkg/config/loader.go (90.4%)</option>
<option value="file5">cheat-go/pkg/config/types.go (72.5%)</option>
<option value="file6">cheat-go/pkg/notes/manager.go (83.9%)</option>
<option value="file7">cheat-go/pkg/online/client.go (73.2%)</option>
<option value="file8">cheat-go/pkg/plugins/builtin.go (27.3%)</option>
<option value="file9">cheat-go/pkg/plugins/loader.go (75.0%)</option>
<option value="file10">cheat-go/pkg/plugins/types.go (100.0%)</option>
<option value="file11">cheat-go/pkg/sync/sync.go (43.7%)</option>
<option value="file12">cheat-go/pkg/ui/table.go (95.1%)</option>
<option value="file13">cheat-go/pkg/ui/theme.go (50.0%)</option>
</select>
</div>
<div id="legend">
<span>not tracked</span>
<span class="cov0">not covered</span>
<span class="cov8">covered</span>
</div>
</div>
<div id="content">
<pre class="file" id="file0" style="display: none">package main
import (
"flag"
"fmt"
"os"
"strings"
"time"
tea "github.com/charmbracelet/bubbletea"
"cheat-go/pkg/apps"
"cheat-go/pkg/cache"
"cheat-go/pkg/config"
"cheat-go/pkg/notes"
"cheat-go/pkg/online"
"cheat-go/pkg/plugins"
"cheat-go/pkg/sync"
"cheat-go/pkg/ui"
)
const (
version = "v1.0.0-phase4"
appName = "cheat-go"
)
// View modes for Phase 4 features
type viewMode int
const (
viewMain viewMode = iota
viewNotes
viewPlugins
viewOnline
viewSync
viewHelp
)
type model struct {
// Original fields
registry *apps.Registry
config *config.Config
renderer *ui.TableRenderer
rows [][]string
filteredRows [][]string
cursorX int
cursorY int
searchMode bool
searchQuery string
lastSearch string
allRows [][]string
filterMode bool
filteredApps []string
allApps []string
helpMode bool
// Phase 4 fields
viewMode viewMode
cache cache.Cache
notesManager notes.Manager
pluginLoader *plugins.Loader
onlineClient online.Client
syncManager *sync.Manager
// View-specific state
notesList []*notes.Note
pluginsList []*plugins.LoadedPlugin
reposList []online.Repository
cheatSheets []online.CheatSheet
syncStatus sync.SyncStatus
// UI state for Phase 4 views
noteCursor int
pluginCursor int
repoCursor int
sheetCursor int
statusMessage string
loading bool
}
type cliOptions struct {
showHelp bool
showVersion bool
theme string
tableStyle string
configFile string
}
func printHelp() <span class="cov8" title="1">{
fmt.Printf(`%s %s - Interactive terminal cheat sheet viewer with cloud features
USAGE:
%s [OPTIONS]
DESCRIPTION:
A fast, interactive terminal application for displaying keyboard shortcuts
and command cheat sheets. Navigate through shortcuts for popular applications
with plugin support, personal notes, online repositories, and cloud sync.
OPTIONS:
-h, --help Show this help message and exit
-v, --version Show version information and exit
-t, --theme THEME Set the display theme
Options: default, dark, light, minimal
Default: default
-s, --style STYLE Set the table style
Options: simple, rounded, bold, minimal
Default: simple
-c, --config FILE Use custom configuration file
Default: ~/.config/cheat-go/config.yaml
NAVIGATION:
Arrow Keys / hjkl Navigate through the table
/ Search mode
f Filter apps
n Open notes manager
p Open plugin manager
o Browse online repositories
s Show sync status
Ctrl+S Force sync
? Show help
q / Ctrl+C Quit the application
PHASE 4 FEATURES:
Notes Manager (n) Create and manage personal notes
Plugin Manager (p) Load and manage plugins
Online Browser (o) Browse community cheat sheets
Sync Status (s) View and manage cloud sync
THEMES:
default Balanced colors for general use
dark High-contrast for dark terminals
light Clean appearance for light terminals
minimal Reduced visual elements
TABLE STYLES:
simple Clean borders with lines
rounded Elegant rounded corners
bold Thick borders for visibility
minimal Spacing-based separation
EXAMPLES:
%s # Start with default settings
%s --theme dark # Use dark theme
%s --style rounded # Use rounded table borders
%s -t dark -s bold # Dark theme with bold borders
%s --config my.yaml # Use custom config file
For more information, visit: https://github.com/remuscazacu/cheat-go
`, appName, version, appName, appName, appName, appName, appName, appName)
}</span>
func printVersion() <span class="cov8" title="1">{
fmt.Printf("%s %s\n", appName, version)
}</span>
func parseFlags() cliOptions <span class="cov0" title="0">{
var opts cliOptions
flag.BoolVar(&opts.showHelp, "h", false, "Show help message")
flag.BoolVar(&opts.showHelp, "help", false, "Show help message")
flag.BoolVar(&opts.showVersion, "v", false, "Show version")
flag.BoolVar(&opts.showVersion, "version", false, "Show version")
flag.StringVar(&opts.theme, "t", "", "Theme")
flag.StringVar(&opts.theme, "theme", "", "Theme")
flag.StringVar(&opts.tableStyle, "s", "", "Table style")
flag.StringVar(&opts.tableStyle, "style", "", "Table style")
flag.StringVar(&opts.configFile, "c", "", "Configuration file path")
flag.StringVar(&opts.configFile, "config", "", "Configuration file path")
flag.Parse()
// Validate theme option
if opts.theme != "" </span><span class="cov0" title="0">{
validThemes := []string{"default", "dark", "light", "minimal"}
valid := false
for _, t := range validThemes </span><span class="cov0" title="0">{
if opts.theme == t </span><span class="cov0" title="0">{
valid = true
break</span>
}
}
<span class="cov0" title="0">if !valid </span><span class="cov0" title="0">{
fmt.Printf("Error: Invalid theme '%s'. Valid options: %s\n",
opts.theme, strings.Join(validThemes, ", "))
os.Exit(1)
}</span>
}
// Validate table style option
<span class="cov0" title="0">if opts.tableStyle != "" </span><span class="cov0" title="0">{
validStyles := []string{"simple", "rounded", "bold", "minimal"}
valid := false
for _, s := range validStyles </span><span class="cov0" title="0">{
if opts.tableStyle == s </span><span class="cov0" title="0">{
valid = true
break</span>
}
}
<span class="cov0" title="0">if !valid </span><span class="cov0" title="0">{
fmt.Printf("Error: Invalid table style '%s'. Valid options: %s\n",
opts.tableStyle, strings.Join(validStyles, ", "))
os.Exit(1)
}</span>
}
<span class="cov0" title="0">return opts</span>
}
func initialModel(opts cliOptions) model <span class="cov8" title="1">{
// Load configuration
loader := config.NewLoader(opts.configFile)
cfg, err := loader.Load()
if err != nil </span><span class="cov0" title="0">{
fmt.Printf("Warning: Could not load config (%v), using defaults\n", err)
cfg = config.DefaultConfig()
}</span>
// Override config with CLI options
<span class="cov8" title="1">if opts.theme != "" </span><span class="cov0" title="0">{
cfg.Theme = opts.theme
}</span>
<span class="cov8" title="1">if opts.tableStyle != "" </span><span class="cov0" title="0">{
cfg.Layout.TableStyle = opts.tableStyle
}</span>
// Initialize app registry
<span class="cov8" title="1">registry := apps.NewRegistry(cfg.DataDir)
if err := registry.LoadApps(cfg.Apps); err != nil </span><span class="cov0" title="0">{
fmt.Printf("Warning: Could not load some apps (%v), using defaults\n", err)
}</span>
// Create theme and renderer
<span class="cov8" title="1">theme := ui.GetTheme(cfg.Theme)
renderer := ui.NewTableRenderer(theme)
renderer.SetTableStyle(cfg.Layout.TableStyle)
renderer.SetMaxWidth(cfg.Layout.MaxWidth)
// Generate table data
rows := registry.GetTableData(cfg.Apps)
// Initialize Phase 4 components
m := model{
registry: registry,
config: cfg,
renderer: renderer,
rows: rows,
filteredRows: rows,
cursorX: 0,
cursorY: 1,
searchMode: false,
searchQuery: "",
lastSearch: "",
allRows: rows,
filterMode: false,
filteredApps: make([]string, 0),
allApps: cfg.Apps,
helpMode: false,
viewMode: viewMain,
}
// Initialize cache
m.cache = cache.NewLRUCache(10*1024*1024, 1000) // 10MB, 1000 items
// Initialize notes manager
notesDir := os.ExpandEnv("$HOME/.config/cheat-go/notes")
if cfg.DataDir != "" </span><span class="cov8" title="1">{
notesDir = cfg.DataDir + "/notes"
}</span>
<span class="cov8" title="1">m.notesManager, _ = notes.NewFileManager(notesDir)
// Initialize plugin loader
pluginDirs := []string{
os.ExpandEnv("$HOME/.config/cheat-go/plugins"),
"/usr/local/share/cheat-go/plugins",
}
if cfg.DataDir != "" </span><span class="cov8" title="1">{
pluginDirs = append([]string{cfg.DataDir + "/plugins"}, pluginDirs...)
}</span>
<span class="cov8" title="1">m.pluginLoader = plugins.NewLoader(pluginDirs...)
m.pluginLoader.LoadAll()
// Initialize online client (mock for now)
m.onlineClient = online.NewMockClient()
// Initialize sync manager (disabled by default)
// m.syncManager would be initialized if sync is enabled in config
return m</span>
}
func (m model) Init() tea.Cmd <span class="cov8" title="1">{
return nil
}</span>
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) <span class="cov8" title="1">{
switch msg := msg.(type) </span>{
case tea.KeyMsg:<span class="cov8" title="1">
// Handle different view modes
switch m.viewMode </span>{
case viewMain:<span class="cov8" title="1">
if m.searchMode </span><span class="cov8" title="1">{
return m.handleSearchInput(msg)
}</span>
<span class="cov8" title="1">if m.filterMode </span><span class="cov8" title="1">{
return m.handleFilterInput(msg)
}</span>
<span class="cov8" title="1">if m.helpMode </span><span class="cov0" title="0">{
return m.handleHelpInput(msg)
}</span>
<span class="cov8" title="1">return m.handleMainInput(msg)</span>
case viewNotes:<span class="cov8" title="1">
return m.handleNotesInput(msg)</span>
case viewPlugins:<span class="cov8" title="1">
return m.handlePluginsInput(msg)</span>
case viewOnline:<span class="cov8" title="1">
return m.handleOnlineInput(msg)</span>
case viewSync:<span class="cov8" title="1">
return m.handleSyncInput(msg)</span>
case viewHelp:<span class="cov0" title="0">
return m.handleHelpInput(msg)</span>
}
}
<span class="cov0" title="0">return m, nil</span>
}
func (m model) handleMainInput(msg tea.KeyMsg) (tea.Model, tea.Cmd) <span class="cov8" title="1">{
switch msg.String() </span>{
case "ctrl+c", "q":<span class="cov8" title="1">
return m, tea.Quit</span>
case "?":<span class="cov8" title="1">
m.helpMode = true
m.viewMode = viewHelp
return m, nil</span>
case "/":<span class="cov8" title="1">
m.searchMode = true
return m, nil</span>
case "f", "ctrl+f":<span class="cov8" title="1">
m.filterMode = true
return m, nil</span>
case "n":<span class="cov8" title="1">
// Open notes manager
m.viewMode = viewNotes
m.loadNotes()
return m, nil</span>
case "p":<span class="cov8" title="1">
// Open plugin manager
m.viewMode = viewPlugins
m.loadPlugins()
return m, nil</span>
case "o":<span class="cov8" title="1">
// Browse online repositories
m.viewMode = viewOnline
m.loadRepositories()
return m, nil</span>
case "s":<span class="cov8" title="1">
// Show sync status
m.viewMode = viewSync
m.loadSyncStatus()
return m, nil</span>
case "ctrl+s":<span class="cov8" title="1">
// Force sync
m.statusMessage = "Syncing..."
// Trigger sync in background
return m, nil</span>
case "up", "k":<span class="cov8" title="1">
if m.cursorY > 1 </span><span class="cov8" title="1">{
m.cursorY--
}</span>
<span class="cov8" title="1">return m, nil</span>
case "down", "j":<span class="cov8" title="1">
if m.cursorY < len(m.rows)-1 </span><span class="cov8" title="1">{
m.cursorY++
}</span>
<span class="cov8" title="1">return m, nil</span>
case "left", "h":<span class="cov8" title="1">
if m.cursorX > 0 </span><span class="cov8" title="1">{
m.cursorX--
}</span>
<span class="cov8" title="1">return m, nil</span>
case "right", "l":<span class="cov8" title="1">
if m.cursorX < len(m.rows[0])-1 </span><span class="cov8" title="1">{
m.cursorX++
}</span>
<span class="cov8" title="1">return m, nil</span>
case "ctrl+a", "home":<span class="cov8" title="1">
m.cursorY = 1
return m, nil</span>
case "ctrl+e", "end":<span class="cov8" title="1">
m.cursorY = len(m.rows) - 1
return m, nil</span>
case "ctrl+r":<span class="cov8" title="1">
// Refresh data
m.rows = m.registry.GetTableData(m.config.Apps)
m.allRows = m.rows
return m, nil</span>
case "esc", "ctrl+[":<span class="cov8" title="1">
// Clear search/filter
m.searchMode = false
m.searchQuery = ""
m.lastSearch = ""
m.rows = m.allRows
m.cursorY = 1
return m, nil</span>
}
<span class="cov8" title="1">return m, nil</span>
}
func (m model) handleNotesInput(msg tea.KeyMsg) (tea.Model, tea.Cmd) <span class="cov8" title="1">{
switch msg.String() </span>{
case "esc", "q":<span class="cov8" title="1">
m.viewMode = viewMain
return m, nil</span>
case "up", "k":<span class="cov0" title="0">
if m.noteCursor > 0 </span><span class="cov0" title="0">{
m.noteCursor--
}</span>
<span class="cov0" title="0">return m, nil</span>
case "down", "j":<span class="cov8" title="1">
if m.noteCursor < len(m.notesList)-1 </span><span class="cov0" title="0">{
m.noteCursor++
}</span>
<span class="cov8" title="1">return m, nil</span>
case "n":<span class="cov8" title="1">
// Create new note with simple hardcoded example
newNote := &notes.Note{
Title: fmt.Sprintf("New Note %d", time.Now().Unix()),
Content: "Enter your note content here",
Category: "general",
Tags: []string{"new"},
}
err := m.notesManager.CreateNote(newNote)
if err != nil </span><span class="cov0" title="0">{
m.statusMessage = fmt.Sprintf("Error creating note: %v", err)
}</span> else<span class="cov8" title="1"> {
m.loadNotes()
m.statusMessage = "Note created successfully"
}</span>
<span class="cov8" title="1">return m, nil</span>
case "e":<span class="cov0" title="0">
// Edit selected note - for now just update the timestamp
if m.noteCursor < len(m.notesList) </span><span class="cov0" title="0">{
note := m.notesList[m.noteCursor]
note.Content = note.Content + "\n[Edited at " + time.Now().Format("15:04:05") + "]"
err := m.notesManager.UpdateNote(note.ID, note)
if err != nil </span><span class="cov0" title="0">{
m.statusMessage = fmt.Sprintf("Error updating note: %v", err)
}</span> else<span class="cov0" title="0"> {
m.loadNotes()
m.statusMessage = fmt.Sprintf("Note '%s' updated", note.Title)
}</span>
}
<span class="cov0" title="0">return m, nil</span>
case "d":<span class="cov0" title="0">
// Delete selected note
if m.noteCursor < len(m.notesList) </span><span class="cov0" title="0">{
noteID := m.notesList[m.noteCursor].ID
m.notesManager.DeleteNote(noteID)
m.loadNotes()
m.statusMessage = "Note deleted"
}</span>
<span class="cov0" title="0">return m, nil</span>
case "f":<span class="cov0" title="0">
// Toggle favorite
if m.noteCursor < len(m.notesList) </span><span class="cov0" title="0">{
noteID := m.notesList[m.noteCursor].ID
m.notesManager.ToggleFavorite(noteID)
m.loadNotes()
}</span>
<span class="cov0" title="0">return m, nil</span>
}
<span class="cov0" title="0">return m, nil</span>
}
func (m model) handlePluginsInput(msg tea.KeyMsg) (tea.Model, tea.Cmd) <span class="cov8" title="1">{
switch msg.String() </span>{
case "esc", "q":<span class="cov8" title="1">
m.viewMode = viewMain
return m, nil</span>
case "up", "k":<span class="cov0" title="0">
if m.pluginCursor > 0 </span><span class="cov0" title="0">{
m.pluginCursor--
}</span>
<span class="cov0" title="0">return m, nil</span>
case "down", "j":<span class="cov8" title="1">
if m.pluginCursor < len(m.pluginsList)-1 </span><span class="cov0" title="0">{
m.pluginCursor++
}</span>
<span class="cov8" title="1">return m, nil</span>
case "l":<span class="cov0" title="0">
// Load plugin
if m.pluginCursor < len(m.pluginsList) </span><span class="cov0" title="0">{
plugin := m.pluginsList[m.pluginCursor]
m.statusMessage = fmt.Sprintf("Loading plugin: %s", plugin.Metadata.Name)
}</span>
<span class="cov0" title="0">return m, nil</span>
case "u":<span class="cov0" title="0">
// Unload plugin
if m.pluginCursor < len(m.pluginsList) </span><span class="cov0" title="0">{
plugin := m.pluginsList[m.pluginCursor]
m.pluginLoader.UnloadPlugin(plugin.Metadata.Name)
m.loadPlugins()
m.statusMessage = fmt.Sprintf("Unloaded plugin: %s", plugin.Metadata.Name)
}</span>
<span class="cov0" title="0">return m, nil</span>
case "r":<span class="cov8" title="1">
// Reload plugins
m.pluginLoader.LoadAll()
m.loadPlugins()
m.statusMessage = "Plugins reloaded"
return m, nil</span>
}
<span class="cov0" title="0">return m, nil</span>
}
func (m model) handleOnlineInput(msg tea.KeyMsg) (tea.Model, tea.Cmd) <span class="cov8" title="1">{
switch msg.String() </span>{
case "esc", "q":<span class="cov8" title="1">
m.viewMode = viewMain
return m, nil</span>
case "up", "k":<span class="cov8" title="1">
if m.repoCursor > 0 </span><span class="cov0" title="0">{
m.repoCursor--
}</span>
<span class="cov8" title="1">return m, nil</span>
case "down", "j":<span class="cov0" title="0">
if m.repoCursor < len(m.reposList)-1 </span><span class="cov0" title="0">{
m.repoCursor++
}</span>
<span class="cov0" title="0">return m, nil</span>
case "enter":<span class="cov0" title="0">
// Browse selected repository
if m.repoCursor < len(m.reposList) </span><span class="cov0" title="0">{
repo := m.reposList[m.repoCursor]
m.loadCheatSheets(repo.URL)
}</span>
<span class="cov0" title="0">return m, nil</span>
case "d":<span class="cov0" title="0">
// Download selected cheat sheet
if m.sheetCursor < len(m.cheatSheets) </span><span class="cov0" title="0">{
sheet := m.cheatSheets[m.sheetCursor]
m.statusMessage = fmt.Sprintf("Downloading: %s", sheet.Name)
// Download logic here
}</span>
<span class="cov0" title="0">return m, nil</span>
case "/":<span class="cov8" title="1">
// Search online
m.searchMode = true
return m, nil</span>
}
<span class="cov0" title="0">return m, nil</span>
}
func (m model) handleSyncInput(msg tea.KeyMsg) (tea.Model, tea.Cmd) <span class="cov8" title="1">{
switch msg.String() </span>{
case "esc", "q":<span class="cov8" title="1">
m.viewMode = viewMain
return m, nil</span>
case "s":<span class="cov8" title="1">
// Trigger sync
m.statusMessage = "Syncing..."
if m.syncManager != nil </span><span class="cov0" title="0">{
go m.syncManager.Sync()
}</span>
<span class="cov8" title="1">return m, nil</span>
case "r":<span class="cov8" title="1">
// Resolve conflicts
m.statusMessage = "Resolving conflicts..."
return m, nil</span>
case "a":<span class="cov8" title="1">
// Toggle auto-sync
if m.syncManager != nil </span><span class="cov0" title="0">{
// Toggle auto-sync setting
m.statusMessage = "Auto-sync toggled"
}</span>
<span class="cov8" title="1">return m, nil</span>
}
<span class="cov0" title="0">return m, nil</span>
}
func (m model) handleSearchInput(msg tea.KeyMsg) (tea.Model, tea.Cmd) <span class="cov8" title="1">{
switch msg.String() </span>{
case "ctrl+c":<span class="cov0" title="0">
return m, tea.Quit</span>
case "esc", "ctrl+[":<span class="cov8" title="1">
m.searchMode = false
m.searchQuery = ""
m.rows = m.allRows
m.lastSearch = ""
m.cursorY = 1
return m, nil</span>
case "ctrl+u":<span class="cov8" title="1">
m.searchQuery = ""
return m, nil</span>
case "enter":<span class="cov8" title="1">
m.searchMode = false
if m.searchQuery == "" </span><span class="cov0" title="0">{
m.rows = m.allRows
m.lastSearch = ""
}</span> else<span class="cov8" title="1"> {
m.rows = m.registry.SearchTableData(m.config.Apps, m.searchQuery)
m.lastSearch = m.searchQuery
}</span>
<span class="cov8" title="1">m.cursorY = 1
return m, nil</span>
case "backspace":<span class="cov8" title="1">
if len(m.searchQuery) > 0 </span><span class="cov8" title="1">{
m.searchQuery = m.searchQuery[:len(m.searchQuery)-1]
}</span>
<span class="cov8" title="1">return m, nil</span>
default:<span class="cov8" title="1">
if len(msg.String()) == 1 </span><span class="cov8" title="1">{
m.searchQuery += msg.String()
}</span>
<span class="cov8" title="1">return m, nil</span>
}
}
func (m model) handleFilterInput(msg tea.KeyMsg) (tea.Model, tea.Cmd) <span class="cov8" title="1">{
switch msg.String() </span>{
case "ctrl+c":<span class="cov0" title="0">
return m, tea.Quit</span>
case "esc", "ctrl+[":<span class="cov0" title="0">
// Exit filter mode
m.filterMode = false
return m, nil</span>
case "ctrl+u":<span class="cov0" title="0">
// Clear all selections
m.filteredApps = make([]string, 0)
return m, nil</span>
case "enter":<span class="cov0" title="0">
// Apply filter and exit filter mode
m.filterMode = false
if len(m.filteredApps) == 0 </span><span class="cov0" title="0">{
// If no apps selected, show all
m.rows = m.registry.GetTableData(m.allApps)
}</span> else<span class="cov0" title="0"> {
// Show only selected apps
m.rows = m.registry.GetTableData(m.filteredApps)
}</span>
<span class="cov0" title="0">m.cursorY = 1
return m, nil</span>
case "1", "2", "3", "4", "5", "6", "7", "8", "9":<span class="cov8" title="1">
// Toggle app selection by number
appIndex := int(msg.String()[0] - '1') // Convert '1' to 0, '2' to 1, etc.
if appIndex < len(m.allApps) </span><span class="cov8" title="1">{
appName := m.allApps[appIndex]
// Toggle app in filteredApps
found := false
for i, name := range m.filteredApps </span><span class="cov8" title="1">{
if name == appName </span><span class="cov8" title="1">{
// Remove app
m.filteredApps = append(m.filteredApps[:i], m.filteredApps[i+1:]...)
found = true
break</span>
}
}
<span class="cov8" title="1">if !found </span><span class="cov8" title="1">{
// Add app
m.filteredApps = append(m.filteredApps, appName)
}</span>
}
<span class="cov8" title="1">return m, nil</span>
case "c":<span class="cov8" title="1">
// Clear all filters
m.filteredApps = make([]string, 0)
return m, nil</span>
case "a":<span class="cov8" title="1">
// Select all apps
m.filteredApps = make([]string, len(m.allApps))
copy(m.filteredApps, m.allApps)
return m, nil</span>
}
<span class="cov0" title="0">return m, nil</span>
}
func (m model) handleHelpInput(msg tea.KeyMsg) (tea.Model, tea.Cmd) <span class="cov0" title="0">{
switch msg.String() </span>{
case "?", "esc", "q":<span class="cov0" title="0">
m.helpMode = false
m.viewMode = viewMain
return m, nil</span>
}
<span class="cov0" title="0">return m, nil</span>
}
// Helper methods for loading data
func (m *model) loadNotes() <span class="cov8" title="1">{
notes, _ := m.notesManager.ListNotes()
m.notesList = notes
m.noteCursor = 0
}</span>
func (m *model) loadPlugins() <span class="cov8" title="1">{
m.pluginsList = m.pluginLoader.ListPlugins()
m.pluginCursor = 0
}</span>
func (m *model) loadRepositories() <span class="cov8" title="1">{
repos, _ := m.onlineClient.GetRepositories()
m.reposList = repos
m.repoCursor = 0
}</span>
func (m *model) loadCheatSheets(repoURL string) <span class="cov0" title="0">{
sheets, _ := m.onlineClient.SearchCheatSheets(online.SearchOptions{
Repository: repoURL,
Limit: 50,
})
m.cheatSheets = sheets
m.sheetCursor = 0
}</span>
func (m *model) loadSyncStatus() <span class="cov8" title="1">{
if m.syncManager != nil </span><span class="cov0" title="0">{
m.syncStatus = m.syncManager.GetSyncStatus()
}</span> else<span class="cov8" title="1"> {
m.syncStatus = sync.SyncStatus{
LastSync: time.Time{},
IsSyncing: false,
DeviceID: "not-configured",
}
}</span>
}
func (m model) View() string <span class="cov8" title="1">{
switch m.viewMode </span>{
case viewNotes:<span class="cov8" title="1">
return m.viewNotes()</span>
case viewPlugins:<span class="cov8" title="1">
return m.viewPlugins()</span>
case viewOnline:<span class="cov8" title="1">
return m.viewOnline()</span>
case viewSync:<span class="cov8" title="1">
return m.viewSync()</span>
case viewHelp:<span class="cov8" title="1">
return m.viewHelp()</span>
default:<span class="cov8" title="1">
return m.viewMain()</span>
}
}
func (m model) viewMain() string <span class="cov8" title="1">{
// Original main view implementation
var output strings.Builder
// Render the table with cursor position
tableStr := m.renderer.RenderWithHighlighting(
m.rows,
m.cursorX,
m.cursorY,
m.lastSearch,
)
output.WriteString(tableStr)
output.WriteString("\n")
// Show status bar
if m.searchMode </span><span class="cov8" title="1">{
output.WriteString(fmt.Sprintf("\nSearch: %s_\nType to search, Enter to confirm, Esc to cancel\n", m.searchQuery))
}</span> else<span class="cov8" title="1"> if m.filterMode </span><span class="cov8" title="1">{
output.WriteString("\nFilter Apps: ")
for i, app := range m.allApps </span><span class="cov8" title="1">{
isSelected := false
for _, selected := range m.filteredApps </span><span class="cov8" title="1">{
if app == selected </span><span class="cov8" title="1">{
isSelected = true
break</span>
}
}
<span class="cov8" title="1">if isSelected </span><span class="cov8" title="1">{
output.WriteString(fmt.Sprintf(" [%d] ✓%s", i+1, app))
}</span> else<span class="cov8" title="1"> {
output.WriteString(fmt.Sprintf(" [%d] %s", i+1, app))
}</span>
}
<span class="cov8" title="1">output.WriteString("\n1-9: toggle apps, a: all, c: clear, Enter: apply, Esc: cancel\n")</span>
} else<span class="cov8" title="1"> {
output.WriteString("\nArrow keys/hjkl: move • /: search • f: filter • n: notes • p: plugins • o: online • s: sync • ?: help • q: quit\n")
}</span>
<span class="cov8" title="1">if m.statusMessage != "" </span><span class="cov0" title="0">{
output.WriteString(fmt.Sprintf("\nStatus: %s\n", m.statusMessage))
}</span>
<span class="cov8" title="1">return output.String()</span>
}
func (m model) viewNotes() string <span class="cov8" title="1">{
var output strings.Builder
output.WriteString("╭─ Personal Notes ─────────────────────────────────────────╮\n")
if len(m.notesList) == 0 </span><span class="cov0" title="0">{
output.WriteString("│ No notes found. Press 'n' to create a new note. │\n")
}</span> else<span class="cov8" title="1"> {
for i, note := range m.notesList </span><span class="cov8" title="1">{
if i > 10 </span><span class="cov0" title="0">{
output.WriteString(fmt.Sprintf("│ ... and %d more notes │\n", len(m.notesList)-10))
break</span>
}
<span class="cov8" title="1">cursor := " "
if i == m.noteCursor </span><span class="cov8" title="1">{
cursor = "▶ "
}</span>
<span class="cov8" title="1">favorite := " "
if note.IsFavorite </span><span class="cov0" title="0">{
favorite = "⭐"
}</span>
<span class="cov8" title="1">line := fmt.Sprintf("%s%s %-30s %s", cursor, favorite, note.Title, note.AppName)
if len(line) > 58 </span><span class="cov0" title="0">{
line = line[:58]
}</span>
<span class="cov8" title="1">output.WriteString(fmt.Sprintf("│%-58s│\n", line))</span>
}
}
<span class="cov8" title="1">output.WriteString("╰──────────────────────────────────────────────────────────╯\n")
output.WriteString("\nKeys: n: new • e: edit • d: delete • f: favorite • esc: back\n")
if m.statusMessage != "" </span><span class="cov0" title="0">{
output.WriteString(fmt.Sprintf("\nStatus: %s\n", m.statusMessage))
}</span>
<span class="cov8" title="1">return output.String()</span>
}
func (m model) viewPlugins() string <span class="cov8" title="1">{
var output strings.Builder
output.WriteString("╭─ Plugin Manager ─────────────────────────────────────────╮\n")
if len(m.pluginsList) == 0 </span><span class="cov8" title="1">{
output.WriteString("│ No plugins loaded. Place plugins in plugins directory. │\n")
}</span> else<span class="cov0" title="0"> {
for i, plugin := range m.pluginsList </span><span class="cov0" title="0">{
if i > 10 </span><span class="cov0" title="0">{
output.WriteString(fmt.Sprintf("│ ... and %d more plugins │\n", len(m.pluginsList)-10))
break</span>
}
<span class="cov0" title="0">cursor := " "
if i == m.pluginCursor </span><span class="cov0" title="0">{
cursor = "▶ "
}</span>
<span class="cov0" title="0">line := fmt.Sprintf("%s%-20s v%-8s %s", cursor, plugin.Metadata.Name, plugin.Metadata.Version, plugin.Metadata.Author)
if len(line) > 58 </span><span class="cov0" title="0">{
line = line[:58]
}</span>
<span class="cov0" title="0">output.WriteString(fmt.Sprintf("│%-58s│\n", line))</span>
}
}
<span class="cov8" title="1">output.WriteString("╰──────────────────────────────────────────────────────────╯\n")
output.WriteString("\nKeys: l: load • u: unload • r: reload all • esc: back\n")
if m.statusMessage != "" </span><span class="cov0" title="0">{
output.WriteString(fmt.Sprintf("\nStatus: %s\n", m.statusMessage))
}</span>
<span class="cov8" title="1">return output.String()</span>
}
func (m model) viewOnline() string <span class="cov8" title="1">{
var output strings.Builder
output.WriteString("╭─ Online Repositories ────────────────────────────────────╮\n")
if len(m.reposList) == 0 </span><span class="cov0" title="0">{
output.WriteString("│ Loading repositories... │\n")
}</span> else<span class="cov8" title="1"> {
for i, repo := range m.reposList </span><span class="cov8" title="1">{
cursor := " "
if i == m.repoCursor </span><span class="cov8" title="1">{
cursor = "▶ "
}</span>
<span class="cov8" title="1">line := fmt.Sprintf("%s%-30s ⭐%d", cursor, repo.Name, repo.Stars)
if len(line) > 58 </span><span class="cov0" title="0">{
line = line[:58]
}</span>
<span class="cov8" title="1">output.WriteString(fmt.Sprintf("│%-58s│\n", line))</span>
}
}
<span class="cov8" title="1">if len(m.cheatSheets) > 0 </span><span class="cov0" title="0">{
output.WriteString("│──────────────────────────────────────────────────────────│\n")
output.WriteString("│ Cheat Sheets: │\n")
for i, sheet := range m.cheatSheets </span><span class="cov0" title="0">{
if i > 5 </span><span class="cov0" title="0">{
break</span>
}
<span class="cov0" title="0">line := fmt.Sprintf(" %-25s ⬇%d ★%.1f", sheet.Name, sheet.Downloads, sheet.Rating)
if len(line) > 58 </span><span class="cov0" title="0">{
line = line[:58]
}</span>
<span class="cov0" title="0">output.WriteString(fmt.Sprintf("│%-58s│\n", line))</span>
}
}