repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
2b9a0ab
parent
fc0f9fe
author
Eric Bower
date
2024-05-13 17:04:32 +0000 UTC
chore: tui fixes
5 files changed,  +25, -32
M tui/cms.go
+3, -3
 1@@ -32,8 +32,8 @@ const (
 2 	statusNoAccount
 3 	statusBrowsingKeys
 4 	statusBrowsingTokens
 5-	statusChat
 6 	statusBrowsingPlus
 7+	statusChat
 8 	statusQuitting
 9 )
10 
11@@ -54,8 +54,8 @@ type menuChoice int
12 const (
13 	keysChoice menuChoice = iota
14 	tokensChoice
15-	chatChoice
16 	plusChoice
17+	chatChoice
18 	exitChoice
19 	unsetChoice // set when no choice has been made
20 )
21@@ -64,8 +64,8 @@ const (
22 var menuChoices = map[menuChoice]string{
23 	keysChoice:   "manage keys",
24 	tokensChoice: "manage tokens",
25-	chatChoice:   "chat",
26 	plusChoice:   "pico+",
27+	chatChoice:   "chat",
28 	exitChoice:   "exit",
29 }
30 
M tui/keys/keyview.go
+2, -2
 1@@ -136,9 +136,9 @@ func (k styledKey) render(state keyState) string {
 2 		k.deleting()
 3 	}
 4 	return fmt.Sprintf(
 5-		"%s %s %s\n%s %s %s\n%s %s %s %s\n\n",
 6+		"%s %s %s %s\n%s %s %s\n%s %s %s\n\n",
 7+		k.gutter, k.commentLabel, k.commentVal, k.note,
 8 		k.gutter, k.keyLabel, k.fingerprint.state(state, k.styles),
 9 		k.gutter, k.dateLabel, k.dateVal,
10-		k.gutter, k.commentLabel, k.commentVal, k.note,
11 	)
12 }
M tui/plus/plus.go
+4, -2
 1@@ -112,12 +112,14 @@ func Update(msg tea.Msg, m Model) (Model, tea.Cmd) {
 2 	switch msg := msg.(type) {
 3 	case tea.KeyMsg:
 4 		switch msg.Type {
 5-		case tea.KeyCtrlC, tea.KeyEscape:
 6+		case tea.KeyCtrlC:
 7 			m.Quit = true
 8+		case tea.KeyEscape:
 9+			m.Done = true
10 
11 		default:
12 			switch msg.String() {
13-			case "q", "esc":
14+			case "q":
15 				m.Done = true
16 			}
17 		}
M tui/tokens/tokens.go
+1, -1
1@@ -264,7 +264,7 @@ func (m Model) View() string {
2 		s = m.createKey.View()
3 	default:
4 		s = "Here are the tokens linked to your account.\n\n"
5-		s += "A token can be used for connecting to our IRC bouncer from your client.\n\n"
6+		s += "A token can be used for connecting to our\nIRC bouncer from your client.\n\n"
7 
8 		// Keys
9 		s += keysView(m)
M tui/tokens/tokenview.go
+15, -24
 1@@ -8,32 +8,27 @@ import (
 2 )
 3 
 4 type styledKey struct {
 5-	styles       common.Styles
 6-	nameLabel    string
 7-	name         string
 8-	date         string
 9-	gutter       string
10-	dateLabel    string
11-	dateVal      string
12-	expiresLabel string
13-	expiresVal   string
14+	styles    common.Styles
15+	nameLabel string
16+	name      string
17+	date      string
18+	gutter    string
19+	dateLabel string
20+	dateVal   string
21 }
22 
23 func (m Model) newStyledKey(styles common.Styles, token *db.Token, active bool) styledKey {
24 	date := token.CreatedAt.Format("02 Jan 2006 15:04:05 MST")
25-	expires := token.ExpiresAt.Format("02 Jan 2006 15:04:05 MST")
26 
27 	// Default state
28 	return styledKey{
29-		styles:       styles,
30-		date:         date,
31-		name:         token.Name,
32-		gutter:       " ",
33-		nameLabel:    "Name:",
34-		dateLabel:    "Added:",
35-		dateVal:      styles.LabelDim.Render(date),
36-		expiresLabel: "Expires:",
37-		expiresVal:   styles.LabelDim.Render(expires),
38+		styles:    styles,
39+		date:      date,
40+		name:      token.Name,
41+		gutter:    " ",
42+		nameLabel: "Name:",
43+		dateLabel: "Added:",
44+		dateVal:   styles.LabelDim.Render(date),
45 	}
46 }
47 
48@@ -42,7 +37,6 @@ func (k *styledKey) selected() {
49 	k.gutter = common.VerticalLine(k.styles.Renderer, common.StateSelected)
50 	k.nameLabel = k.styles.Label.Render("Name:")
51 	k.dateLabel = k.styles.Label.Render("Added:")
52-	k.expiresLabel = k.styles.Label.Render("Expires:")
53 }
54 
55 // Deleting state.
56@@ -51,8 +45,6 @@ func (k *styledKey) deleting() {
57 	k.nameLabel = k.styles.Delete.Render("Name:")
58 	k.dateLabel = k.styles.Delete.Render("Added:")
59 	k.dateVal = k.styles.DeleteDim.Render(k.date)
60-	k.expiresLabel = k.styles.Delete.Render("Expires:")
61-	k.expiresVal = k.styles.DeleteDim.Render(k.expiresVal)
62 }
63 
64 func (k styledKey) render(state keyState) string {
65@@ -63,9 +55,8 @@ func (k styledKey) render(state keyState) string {
66 		k.deleting()
67 	}
68 	return fmt.Sprintf(
69-		"%s %s %s\n%s %s %s\n%s %s %s\n",
70+		"%s %s %s\n%s %s %s\n\n",
71 		k.gutter, k.nameLabel, k.name,
72 		k.gutter, k.dateLabel, k.dateVal,
73-		k.gutter, k.expiresLabel, k.expiresVal,
74 	)
75 }