summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-05-21 16:31:04 -0400
committerDrew DeVault <sir@cmpwn.com>2019-05-21 16:53:50 -0400
commit6811143925384ba1cfda8b3e1b338b0cfb9ac6e3 (patch)
tree584ce88b40ab87828d6adbfdb6bef7a5d3046600 /lib
parent176245208d40a9ca2ec324be7863a22819de29bc (diff)
downloadaerc-6811143925384ba1cfda8b3e1b338b0cfb9ac6e3.tar.gz
New account wizard, part one
Diffstat (limited to 'lib')
-rw-r--r--lib/ui/text.go2
-rw-r--r--lib/ui/textinput.go31
2 files changed, 23 insertions, 10 deletions
diff --git a/lib/ui/text.go b/lib/ui/text.go
index 8aea8eb..2b82598 100644
--- a/lib/ui/text.go
+++ b/lib/ui/text.go
@@ -77,7 +77,7 @@ func (t *Text) Draw(ctx *Context) {
 		style = style.Reverse(true)
 	}
 	ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', style)
-	ctx.Printf(x, 0, style, t.text)
+	ctx.Printf(x, 0, style, "%s", t.text)
 }
 
 func (t *Text) Invalidate() {
diff --git a/lib/ui/textinput.go b/lib/ui/textinput.go
index 4a5308e..ce443c3 100644
--- a/lib/ui/textinput.go
+++ b/lib/ui/textinput.go
@@ -10,14 +10,15 @@ import (
 
 type TextInput struct {
 	Invalidatable
-	cells  int
-	ctx    *Context
-	focus  bool
-	index  int
-	prompt string
-	scroll int
-	text   []rune
-	change []func(ti *TextInput)
+	cells    int
+	ctx      *Context
+	focus    bool
+	index    int
+	password bool
+	prompt   string
+	scroll   int
+	text     []rune
+	change   []func(ti *TextInput)
 }
 
 // Creates a new TextInput. TextInputs will render a "textbox" in the entire
@@ -31,6 +32,11 @@ func NewTextInput(text string) *TextInput {
 	}
 }
 
+func (ti *TextInput) Password(password bool) *TextInput {
+	ti.password = password
+	return ti
+}
+
 func (ti *TextInput) Prompt(prompt string) *TextInput {
 	ti.prompt = prompt
 	return ti
@@ -42,6 +48,7 @@ func (ti *TextInput) String() string {
 
 func (ti *TextInput) Set(value string) {
 	ti.text = []rune(value)
+	ti.index = len(ti.text)
 }
 
 func (ti *TextInput) Invalidate() {
@@ -51,7 +58,13 @@ func (ti *TextInput) Invalidate() {
 func (ti *TextInput) Draw(ctx *Context) {
 	ti.ctx = ctx // gross
 	ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault)
-	ctx.Printf(0, 0, tcell.StyleDefault, "%s%s", ti.prompt, string(ti.text))
+	if ti.password {
+		x := ctx.Printf(0, 0, tcell.StyleDefault, "%s", ti.prompt)
+		cells := runewidth.StringWidth(string(ti.text))
+		ctx.Fill(x, 0, cells, 1, '*', tcell.StyleDefault)
+	} else {
+		ctx.Printf(0, 0, tcell.StyleDefault, "%s%s", ti.prompt, string(ti.text))
+	}
 	cells := runewidth.StringWidth(string(ti.text[:ti.index]) + ti.prompt)
 	if cells != ti.cells && ti.focus {
 		ctx.SetCursor(cells, 0)
stract list, update dirlist accordingly"' href='/akspecs/aerc/commit/widgets/directories.go?h=0.4.0&id=257affcd4841b8f595a4a13cdb0fd2a1a2dd0faa'>257affc ^
2349b7d ^
257affc ^

a782b70 ^
257affc ^
cf66462 ^


2349b7d ^



cf66462 ^

2750f99 ^
cf66462 ^


2349b7d ^
257affc ^
2349b7d ^


257affc ^


2349b7d ^


24196d2 ^
a782b70 ^





257affc ^




cf66462 ^
257affc ^





cf66462 ^






257affc ^

2349b7d ^
b60999c ^




































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