wit-debian-gui/window-xterm.go

61 lines
1.4 KiB
Go
Raw Normal View History

2021-11-02 23:44:28 -05:00
package main
import "log"
// import "strconv"
import "io/ioutil"
import "git.wit.org/wit/gui"
var fontNode *gui.Node
var fontsize string = ""
2021-11-02 23:44:28 -05:00
func xtermSettings(w *gui.Node) {
if (w == nil) {
gui.Config.Title = "Configure xterm"
2021-11-02 23:44:28 -05:00
gui.Config.Width = 105
gui.Config.Height = 105
gui.Config.Exit = normalWindowClose
2021-11-02 23:44:28 -05:00
w = gui.NewWindow()
}
tab := w.AddTab("xtermSettings()", nil)
// Select your fontsize
gNode := tab.AddGroup("fontsize")
fontsize = "16"
fontNode = gNode.AddComboBox("fontsize", "8", "12", "16", "24", "32")
fontNode.OnChanged = func () {
fontsize = fontNode.GetText()
2021-11-02 23:44:28 -05:00
}
fontNode.SetText(fontsize)
2021-11-02 23:44:28 -05:00
////////////// connect /////////////////////////
gNode = tab.AddGroup("Update")
gNode.AddButton("setup .Xresources", func (*gui.Node) {
log.Println("fontsize =", fontsize)
// write out .Xresources file
foo := []byte("xterm*faceName: Monospace\nxterm*faceSize: ")
// bar := []byte(strconv.Itoa(fontsize) + "\n")
bar := []byte(fontsize + "\n")
foo = append(foo, bar...)
ioutil.WriteFile("/home/jcarr/.Xresources", foo, 0644)
cmd := "xrdb -merge ~/.Xresources; cat ~/.Xresources"
xterm(cmd)
log.Println("button click end")
})
gNode.AddButton("test xterm", func (*gui.Node) {
cmd := "xterm"
xterm(cmd)
})
gNode.AddButton("fontNode.GetText()", func (*gui.Node) {
if (fontNode != nil) {
fontsize = fontNode.GetText()
log.Println("set fontsize =", fontsize)
}
})
2021-11-02 23:44:28 -05:00
}