Skip to content

Commit

Permalink
Fixes an off-by-one error
Browse files Browse the repository at this point in the history
The new marks dialog shows packet numbers that start counting at 0, but
the UI shows them starting at 1, to follow Wireshark. This change keeps
the marks dialog consistent with the way packets are numbered in the UI.
  • Loading branch information
gcla committed Jul 27, 2020
1 parent 51d4b12 commit 7238bfc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ui/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ import (

//======================================================================

// For fixing off-by-one errors in packet marks
var funcMap = template.FuncMap{
"inc": func(i int) int {
return i + 1
},
}

var TemplateData map[string]interface{}

var Templates = template.Must(template.New("Help").Parse(`
var Templates = template.Must(template.New("Help").Funcs(funcMap).Parse(`
{{define "NameVer"}}termshark {{.Version}}{{end}}
{{define "TsharkVer"}}using tshark {{.TsharkVersion}} (from {{.TsharkAbsolutePath}}){{end}}
Expand Down Expand Up @@ -88,10 +95,10 @@ left - Widen selection
right - Narrow selection{{end}}
'?' - Display copy-mode help
{{define "Marks"}}{{if not .Marks}}No local marks are set{{else}}Mark Packet Summary{{range $key, $value := .Marks }}
{{printf " %c" $key}}{{printf "%6d" $value.Pos}} {{printf "%s" $value.Summary}}{{end}}{{end}}
{{printf " %c" $key}}{{printf "%6d" (inc $value.Pos)}} {{printf "%s" $value.Summary}}{{end}}{{end}}
{{if not .GlobalMarks}}No cross-file marks are set{{else}}Mark Packet File Summary{{range $key, $value := .GlobalMarks }}
{{printf " %-4c" $key}} {{printf "%-7d" $value.Pos}}{{printf "%-18s" $value.Base}}{{printf "%s" $value.Summary}}{{end}}{{end}}{{end}}
{{printf " %-4c" $key}} {{printf "%-7d" (inc $value.Pos)}}{{printf "%-18s" $value.Base}}{{printf "%s" $value.Summary}}{{end}}{{end}}{{end}}
{{define "Key Mappings"}}{{if .Maps.None}}No key mappings are set{{else}} From To {{range $mapping := .Maps.Get }}
{{printf " %-14v" $mapping.From}}{{printf "%v" $mapping.To}} {{end}}{{end}}
{{end}}
Expand Down

0 comments on commit 7238bfc

Please sign in to comment.