From 42fcf63eca8335cf4ba7eb3652d5eca9bf270ead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AE=A1=E5=AE=9C=E5=B0=A7?= Date: Fri, 12 Jan 2018 11:03:29 +0800 Subject: [PATCH] create unicode(chinese) support demo --- demos/unicode/main.go | 49 +++++++++++++++++++++++++++++++++++ demos/unicode/screenshot.png | Bin 0 -> 11608 bytes 2 files changed, 49 insertions(+) create mode 100644 demos/unicode/main.go create mode 100644 demos/unicode/screenshot.png diff --git a/demos/unicode/main.go b/demos/unicode/main.go new file mode 100644 index 0000000..bd6431b --- /dev/null +++ b/demos/unicode/main.go @@ -0,0 +1,49 @@ +// Demo code for unicode(chinese) support. +package main + +import ( + "fmt" + + "github.com/rivo/tview" +) + +func main() { + app := tview.NewApplication() + pages := tview.NewPages() + + form := tview.NewForm() + form.AddDropDown("称谓", []string{"先生", "女士", "博士", "老师", "师傅"}, 0, nil). + AddInputField("姓名", "", 20, nil, nil). + AddCheckbox("年龄 18+", false, nil). + AddPasswordField("密码", "", 10, '*', nil). + AddButton("保存", func() { + _, title := form.GetElement(0).(*tview.DropDown).GetCurrentOption() + userName := form.GetElement(1).(*tview.InputField).GetText() + + alert(pages, "alert-dialog", fmt.Sprintf("保存成功,%s %s!", userName, title)) + }). + AddButton("退出", func() { + app.Stop() + }) + form.SetBorder(true).SetTitle("输入一些内容").SetTitleAlign(tview.AlignLeft) + pages.AddPage("base", form, true, true) + + if err := app.SetRoot(pages, true).SetFocus(pages).Run(); err != nil { + panic(err) + } +} + +// alert show a message dialog +func alert(pages *tview.Pages, id string, message string) *tview.Pages { + return pages.AddPage( + id, + tview.NewModal(). + SetText(message). + AddButtons([]string{"确定"}). + SetDoneFunc(func(buttonIndex int, buttonLabel string) { + pages.HidePage(id).RemovePage(id) + }), + false, + true, + ) +} diff --git a/demos/unicode/screenshot.png b/demos/unicode/screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..5d0d974f59e16020433ec7a08d532d9f8598101c GIT binary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