Skip to content

Commit

Permalink
Have space send dash for recv codes
Browse files Browse the repository at this point in the history
This makes it easier to type a wormhole code since you don't need to
switch to the symbols keyboard layer to get a dash.

Fixes #20

Closes: #22 [via git-merge-pr]
  • Loading branch information
psanford committed Jan 17, 2022
1 parent 8f70757 commit 07a623f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ func (ui *UI) loop(w *app.Window) error {
codeLenEditor.SetText(strconv.Itoa(conf.CodeLen))
}

recvCodeEditor.SingleLine = true

var (
pickResult <-chan picker.PickResult
qrCodeResult <-chan string
Expand Down Expand Up @@ -436,6 +438,20 @@ func (ui *UI) loop(w *app.Window) error {
}()
}

for _, e := range recvCodeEditor.Events() {
if _, ok := e.(widget.ChangeEvent); ok {
orig := recvCodeEditor.Text()
new := strings.ReplaceAll(orig, " ", "-")
new = strings.ReplaceAll(new, "\n", "")

if new != orig {
_, col := recvCodeEditor.CaretPos()
recvCodeEditor.SetText(new)
recvCodeEditor.MoveCaret(col, col)
}
}
}

drawTabs(gtx, th)
e.Frame(gtx.Ops)

Expand Down

0 comments on commit 07a623f

Please sign in to comment.