wit-debian-gui/window-xterm.go

67 lines
1.4 KiB
Go

package main
import (
"io/ioutil"
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
"go.wit.com/log"
)
var fontNode *gui.Node
var fontsize string = ""
var xtermWin *gadgets.BasicWindow
func xtermSettings(w *gui.Node) {
if xtermWin != nil {
xtermWin.Toggle()
return
}
xtermWin = gadgets.NewBasicWindow(myGui, "Configure xterm")
// Select your fontsize
gNode := xtermWin.Box().NewGroup("fontsize")
fontsize = "16"
fontNode = gNode.NewCombobox("fontsize")
fontNode.AddText("8")
fontNode.AddText("12")
fontNode.AddText("16")
fontNode.AddText("24")
fontNode.AddText("32")
fontNode.Custom = func() {
fontsize = fontNode.GetText()
}
fontNode.SetText(fontsize)
////////////// connect /////////////////////////
gNode = xtermWin.Box().NewGroup("Update")
gNode.NewButton("setup .Xresources", func() {
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.NewButton("test xterm", func() {
cmd := "xterm"
xterm(cmd)
})
gNode.NewButton("fontNode.GetText()", func() {
if fontNode != nil {
fontsize = fontNode.GetText()
log.Println("set fontsize =", fontsize)
}
})
}