summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-02-21 14:57:21 -0500
committerPietro Gagliardi <[email protected]>2015-02-21 14:58:07 -0500
commit23e6739dfabd61fd732d9b78e13a55aeaa7c2c2d (patch)
tree5bc6593de7d538e75ba470d80a02c3bab9f6e9f3
parentd855f5df3f084f57ada2add87e3d5a59a8ccbd0a (diff)
Added provisions for giving Table columns custom titles. Will now implement.
-rw-r--r--table.go3
-rw-r--r--zz_test.go10
2 files changed, 11 insertions, 2 deletions
diff --git a/table.go b/table.go
index 0f0552f..c9f7511 100644
--- a/table.go
+++ b/table.go
@@ -18,7 +18,8 @@ import (
// Tables are read-only by default, except for checkboxes, which are user-settable.
//
// Tables have headers on top of all columns.
-// Currently the name of the header is the same as the name of the field.
+// By default, the name of the header is the same as the name of the field.
+// If the struct field has a tag "uicolumn", its value is used as the header string instead.
//
// Tables maintain their own storage behind a sync.RWMutex-compatible sync.Locker; use Table.Lock()/Table.Unlock() to make changes and Table.RLock()/Table.RUnlock() to merely read values.
type Table interface {
diff --git a/zz_test.go b/zz_test.go
index 6fa36c8..3597ccb 100644
--- a/zz_test.go
+++ b/zz_test.go
@@ -38,6 +38,12 @@ func newSimpleGrid(n int, c ...Control) SimpleGrid {
return g
}
+type colnametest struct {
+ IncorrectColumnName string `uicolumn:"Correct Column Name"`
+ IncorrectColumnName2 string `uicolumn:"正解なコラムネーム"` // thanks GlitterBerri in irc.badnik.net/#zelda
+ AlreadyCorrect string
+}
+
type dtype struct {
Name string
Address string
@@ -183,7 +189,9 @@ func (tw *testwin) make(done chan struct{}) {
tw.roenter.OnChanged(func() {
tw.roro.SetText(tw.roenter.Text())
})
- tw.t.Append("Read-Only", newVerticalStack(tw.roenter, tw.roro))
+ s := newVerticalStack(tw.roenter, tw.roro, NewTable(reflect.TypeOf(colnametest{})))
+ s.SetStretchy(2)
+ tw.t.Append("Read-Only", s)
tw.icons = readIcons() // repainter uses these
tw.repainter = newRepainter(15)
tw.t.Append("Repaint", tw.repainter.grid)