Skip to content

Commit

Permalink
Tidy up the various help dialogs
Browse files Browse the repository at this point in the history
I'm now using gowid's paragraph widget for a better formatting
experience. However I still want a specific alignment on some lines, so
I employ a hack where I use an underscore to represent a space I want
preserved. Now the dialogs look reasonable across a range of terminal
widths.
  • Loading branch information
gcla committed Sep 2, 2021
1 parent d36325c commit 608235e
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 56 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/blang/semver v3.5.1+incompatible
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/gcla/deep v1.0.2
github.com/gcla/gowid v1.2.1-0.20210902022514-507cfa6ef3ed
github.com/gcla/gowid v1.2.1-0.20210902230020-c4910818c6b3
github.com/gcla/tail v1.0.1-0.20190505190527-650e90873359
github.com/gdamore/tcell v1.3.1-0.20200115030318-bff4943f9a29
github.com/go-test/deep v1.0.2 // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWo
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/gcla/deep v1.0.2 h1:qBOx6eepcOSRYnHJ+f2ih4hP4Vca1YnLtXxp73n5KWI=
github.com/gcla/deep v1.0.2/go.mod h1:evE9pbpSGhItmFoBIk8hPOIC/keKTGYhFl6Le1Av+GE=
github.com/gcla/gowid v1.2.1-0.20210821221812-8682c44dd77f h1:Yoj7Qn6+Ms9i+8t5/m+P6aywYaw7HsFqFaaoj71oOrc=
github.com/gcla/gowid v1.2.1-0.20210821221812-8682c44dd77f/go.mod h1:GL9KUFwKHjWS80G7N4hkA++mpOleVQpNvKIHyW9n0i4=
github.com/gcla/gowid v1.2.1-0.20210902022514-507cfa6ef3ed h1:BQp9rokK2GVxViqKTdJhZVDwytBwbT2KtsYdnq5rWmo=
github.com/gcla/gowid v1.2.1-0.20210902022514-507cfa6ef3ed/go.mod h1:GL9KUFwKHjWS80G7N4hkA++mpOleVQpNvKIHyW9n0i4=
github.com/gcla/gowid v1.2.1-0.20210902230020-c4910818c6b3 h1:qX1KC1l+mSNQztbs95vvM28RVdOHn7nVicAbjejcj7E=
github.com/gcla/gowid v1.2.1-0.20210902230020-c4910818c6b3/go.mod h1:GL9KUFwKHjWS80G7N4hkA++mpOleVQpNvKIHyW9n0i4=
github.com/gcla/tail v1.0.1-0.20190505190527-650e90873359 h1:3xEhacR7pIJV8daurdBygptxhzTJeYFqJp1V6SDl+pE=
github.com/gcla/tail v1.0.1-0.20190505190527-650e90873359/go.mod h1:Wn+pZpM98JHSOYkPDtmdvlqmc0OzQGHWOsHB2d28WtQ=
github.com/gcla/tcell v1.1.2-0.20200927150251-decc2045f510 h1:TlEZ0DHOvn0P79nHtkfemw7XFn2h8Lacd6AZpXrPU/o=
Expand Down
23 changes: 20 additions & 3 deletions ui/dialog.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"github.com/gcla/gowid/widgets/dialog"
"github.com/gcla/gowid/widgets/framed"
"github.com/gcla/gowid/widgets/hpadding"
"github.com/gcla/gowid/widgets/paragraph"
"github.com/gcla/gowid/widgets/pile"
"github.com/gcla/gowid/widgets/selectable"
"github.com/gcla/gowid/widgets/styled"
"github.com/gcla/gowid/widgets/text"
Expand Down Expand Up @@ -131,10 +133,25 @@ func openMessage(msgt string, openOver gowid.ISettableComposite, focusOnWidget b
}

func OpenTemplatedDialog(container gowid.ISettableComposite, tmplName string, app gowid.IApp) *dialog.Widget {
msg := termshark.TemplateToString(Templates, tmplName, TemplateData)
lines := strings.Split(msg, "\n")

ws := make([]interface{}, 0, len(lines))
for _, line := range lines {
if line == "" {
ws = append(ws, text.New(line))
} else {
words := strings.Fields(line)
for i := 0; i < len(words); i++ {
words[i] = strings.ReplaceAll(words[i], "_", " ")
}
ws = append(ws, paragraph.NewWithWords(words...))
}
}
body := pile.NewFlow(ws...)

YesNo = dialog.New(
framed.NewSpace(
text.New(termshark.TemplateToString(Templates, tmplName, TemplateData)),
),
framed.NewSpace(body),
dialog.Options{
Buttons: dialog.CloseOnly,
NoShadow: true,
Expand Down
96 changes: 48 additions & 48 deletions ui/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,18 @@ $ termshark -r file.pcap -T psml -n | less{{end}}
A wireshark-inspired tui for tshark. Analyze network traffic interactively from your terminal.
/ - Go to display filter/stream search
q - Quit
/__ - Go to display filter/stream search
q__ - Quit
tab - Switch panes
c - Switch to copy-mode
| - Cycle through pane layouts
\ - Toggle pane zoom
c__ - Switch to copy-mode
|__ - Cycle through pane layouts
\__ - Toggle pane zoom
esc - Activate menu
+/- - Adjust horizontal split
</> - Adjust vertical split
: - Activate cmdline mode (see help cmdline)
z - Maximize/restore any modal dialog
? - Display help
:__ - Activate cmdline mode (see help cmdline)
z__ - Maximize/restore any modal dialog
?__ - Display help
In the filter, type a wireshark display filter expression.
Expand All @@ -90,18 +90,18 @@ Use shift-left-mouse to copy and shift-right-mouse to paste.{{end}}
Navigate the UI using vim-style keys.
hjkl - Move left/down/up/right in various views
gg - Go to the top of the current table
G - Go to the bottom of the current table
5gg - Go to the 5th row of the table
hjkl___ - Move left/down/up/right in various views
gg_____ - Go to the top of the current table
G______ - Go to the bottom of the current table
5gg____ - Go to the 5th row of the table
C-w C-w - Switch panes (same as tab)
C-w = - Equalize pane spacing
ma - Mark current packet (use a through z)
'a - Jump to packet marked 'a'
mA - Mark current packet + pcap (use A through Z)
'A - Jump to packet + pcap marked 'A'
'' - After a jump; jump back to prior packet
ZZ - Quit without confirmation
C-w_=__ - Equalize pane spacing
ma_____ - Mark current packet (use a through z)
'a_____ - Jump to packet marked 'a'
mA_____ - Mark current packet + pcap (use A through Z)
'A_____ - Jump to packet + pcap marked 'A'
''_____ - After a jump; jump back to prior packet
ZZ_____ - Quit without confirmation
See also help cmdline.{{end}}
Expand All @@ -111,38 +111,38 @@ Activate cmdline mode with the : key.
Hit tab to see and choose possible completions.
capinfo - Capture file properties
clear - Clear current pcap
convs - Open conversations view
filter - Choose a display filter from recently-used
help - Various help dialogs
load - Load a pcap from the filesystem
logs - Show termshark's log file (Unix-only)
map - Map a keypress to a key sequence (see help map)
marks - Show file-local and global packet marks
no-theme - Clear theme for the current terminal color mode
quit - Quit termshark
recents - Load a pcap from those recently-used
set - Set various config properties (see help set)
streams - Open stream reassembly view
theme - Choose a theme for the current terminal color mode
unmap - Remove a keypress mapping{{end}}
capinfo_ - Capture file properties
clear___ - Clear current pcap
convs___ - Open conversations view
filter__ - Choose a display filter from recently-used
help____ - Various help dialogs
load____ - Load a pcap from the filesystem
logs____ - Show termshark's log file (Unix-only)
map_____ - Map a keypress to a key sequence (see help map)
marks___ - Show file-local and global packet marks
no-theme - Clear theme for the current terminal color mode
quit____ - Quit termshark
recents_ - Load a pcap from those recently-used
set_____ - Set various config properties (see help set)
streams_ - Open stream reassembly view
theme___ - Choose a theme for the current terminal color mode
unmap___ - Remove a keypress mapping{{end}}
{{define "SetHelp"}}{{template "NameVer" .}}
Use the cmdline set command to change configuration.
Type :set and hit tab for options.
auto-scroll - scroll during live captures
copy-timeout - wait this long before failing a copy
dark-mode - enable or disable dark-mode
disable-shark-fin - switch off the secret shark fin
packet-colors - use colors in the packet list view
pager - pager (used for termshark's log file)
nopager - disable the pager (use PAGER instead)
term - make termshark assume this terminal type
noterm - disable the terminal type (use TERM){{end}}
auto-scroll________ - scroll during live captures
copy-timeout_______ - wait this long before failing a copy
dark-mode__________ - enable or disable dark-mode
disable-shark-fin__ - switch off the secret shark fin
packet-colors______ - use colors in the packet list view
pager______________ - pager (used for termshark's log file)
nopager____________ - disable the pager (use PAGER instead)
term_______________ - make termshark assume this terminal type
noterm_____________ - disable the terminal type (use TERM){{end}}
{{define "MapHelp"}}{{template "NameVer" .}}
Expand All @@ -169,10 +169,10 @@ Use the unmap command to remove a mapping.{{end}}
termshark is in copy-mode. You can press:
'q', 'c' - Exit copy-mode
ctrl-c - Copy from selected widget
left - Widen selection
right - Narrow selection
'?' - Display copy-mode help
ctrl-c__ - Copy from selected widget
left____ - Widen selection
right___ - Narrow selection
'?'_____ - Display copy-mode help
{{end}}
{{define "Marks"}}{{if not .Marks}}No local marks are set{{else}}Mark Packet Summary{{range $key, $value := .Marks }}
Expand Down

0 comments on commit 608235e

Please sign in to comment.