~emersion/drmdb

09fb82de3ecc5a42a61fbb6bf71029d6a45c8e8a — Simon Ser 3 months ago bf6e1d9
Fix format/modifier pretty-printing
5 files changed, 14 insertions(+), 7 deletions(-)

M drmtree/drmtree.go
M go.mod
M go.sum
M public/formats.html
M template.go
M drmtree/drmtree.go => drmtree/drmtree.go +2 -2
@@ 459,10 459,10 @@ func (m *PropertyMap) FormatTree(tf treefmt.Formatter) {
			tf.Printf("%v", s)
			tfc := tf.NewChild()
			for _, mod := range val {
				tfc.Printf("%v (0x%X)", mod.Modifier, mod.Modifier)
				tfc.Printf("%v", mod.Modifier)
				tfcc := tfc.NewChild()
				for _, fmt := range mod.Formats {
					tfcc.Printf("%v (0x%X)", fmt, fmt)
					tfcc.Printf("%v", fmt)
				}
			}
		case []drm.Format:

M go.mod => go.mod +1 -1
@@ 3,7 3,7 @@ module git.sr.ht/~emersion/drmdb
go 1.12

require (
	git.sr.ht/~emersion/go-drm v0.0.0-20210112202656-a6c0a22a347c
	git.sr.ht/~emersion/go-drm v0.0.0-20210112225854-c0c2450906d9
	git.sr.ht/~emersion/go-hwids v0.0.0-20190518090256-f59e5efa82bd
	github.com/davecgh/go-spew v1.1.1 // indirect
	github.com/labstack/echo/v4 v4.1.17

M go.sum => go.sum +2 -2
@@ 1,5 1,5 @@
git.sr.ht/~emersion/go-drm v0.0.0-20210112202656-a6c0a22a347c h1:5NEZIsiIobKGVaHEjYiTwOq0oMSAkbbGJIWPQgWKytw=
git.sr.ht/~emersion/go-drm v0.0.0-20210112202656-a6c0a22a347c/go.mod h1:zEYzVXwxcVK/GyMUXkivzLZYeO/1PUIp7//W9gwbvlc=
git.sr.ht/~emersion/go-drm v0.0.0-20210112225854-c0c2450906d9 h1:Wem316QOS4WvFjWYokeEnQ6XyPMaDgd00hePsBxnzTI=
git.sr.ht/~emersion/go-drm v0.0.0-20210112225854-c0c2450906d9/go.mod h1:zEYzVXwxcVK/GyMUXkivzLZYeO/1PUIp7//W9gwbvlc=
git.sr.ht/~emersion/go-hwids v0.0.0-20190518090256-f59e5efa82bd h1:oNlwNNmZsVAB9ucZwP9FR9sa9N0NRMruE7bCxHudyqI=
git.sr.ht/~emersion/go-hwids v0.0.0-20190518090256-f59e5efa82bd/go.mod h1:jHwpYaHgpEBE1rOTTLurgzObr9WvtH6DZXtrERSorI8=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=

M public/formats.html => public/formats.html +2 -2
@@ 32,8 32,8 @@
          {{range .Formats}}
          <tr>
              {{$row := .}}
              <td class="pre" title="{{printf "0x%X" .Modifier}}">{{.Modifier}}</td>
              <td class="pre" title="{{printf "0x%X" .Format}}">{{.Format}}</td>
              <td class="pre" title="{{drmModifierHex .Modifier}}">{{.Modifier.Name}}</td>
              <td class="pre" title="{{drmFormatHex .Format}}">{{.Format.Name}}</td>
              {{range $plane, $total := $.Planes}}
              {{template "pct-cell" (pct (index $row.Planes $plane) $total)}}
              {{end}}

M template.go => template.go +7 -0
@@ 7,6 7,7 @@ import (
	"strings"

	"github.com/labstack/echo/v4"
	"git.sr.ht/~emersion/go-drm"
)

type tmpl struct {


@@ 30,6 31,12 @@ func loadTemplates() (*tmpl, error) {
			hue := int(f * 120)
			return template.CSS(fmt.Sprintf("hsl(%d, 100%%, 30%%)", hue))
		},
		"drmFormatHex": func(f drm.Format) string {
			return fmt.Sprintf("0x%X", uint32(f))
		},
		"drmModifierHex": func(mod drm.Modifier) string {
			return fmt.Sprintf("0x%X", uint64(mod))
		},
	}).ParseGlob("public/*.html")

	return &tmpl{t}, err