1
0
mirror of https://github.com/mum4k/termdash.git synced 2025-04-25 13:48:50 +08:00

Formdemo now displays default text in the input boxes.

This commit is contained in:
Jakub Sobon 2020-12-28 03:54:36 -05:00
parent db2fcdcffc
commit b91eac380d
No known key found for this signature in database
GPG Key ID: F2451A77FB05D3B7

View File

@ -17,6 +17,8 @@ package main
import (
"context"
"fmt"
"os/user"
"time"
"github.com/mum4k/termdash"
@ -73,23 +75,35 @@ func main() {
ctx, cancel := context.WithCancel(context.Background())
var username string
u, err := user.Current()
if err != nil {
username = "mum4k"
} else {
username = u.Username
}
userInput, err := textinput.New(
textinput.Label("Username: ", cell.FgColor(cell.ColorNumber(33))),
textinput.DefaultText(username),
textinput.MaxWidthCells(20),
textinput.ExclusiveKeyboardOnFocus(),
)
uidInput, err := textinput.New(
textinput.Label("UID: ", cell.FgColor(cell.ColorNumber(33))),
textinput.DefaultText("1000"),
textinput.MaxWidthCells(20),
textinput.ExclusiveKeyboardOnFocus(),
)
gidInput, err := textinput.New(
textinput.Label("GID: ", cell.FgColor(cell.ColorNumber(33))),
textinput.DefaultText("1000"),
textinput.MaxWidthCells(20),
textinput.ExclusiveKeyboardOnFocus(),
)
homeInput, err := textinput.New(
textinput.Label("Home: ", cell.FgColor(cell.ColorNumber(33))),
textinput.DefaultText(fmt.Sprintf("/home/%s", username)),
textinput.MaxWidthCells(20),
textinput.ExclusiveKeyboardOnFocus(),
)