feat: Add pane sync and prefix key status indicators

The indicators used can be customized:

- For the prefix key indicator, set `@themepack-prefix-key-on-format`
and `@themepack-prefix-key-off-format` options. The off format must be
the same length as the on format to avoid weird behavior.
- For the pane sync indicator, set `@themepack-pane-sync-on-format` and
`@themepack-pane-sync-off-format` options. The off format must be the
same length as the on format to avoid weird behavior.
This commit is contained in:
2019-12-22 23:01:51 +00:00
parent 7c59902f64
commit 06a63f4118
38 changed files with 78 additions and 77 deletions

View File

@@ -30,16 +30,20 @@ func TestBasicTheme(t *testing.T) {
})
tmuxHasOptions(t, theme, tmux.GlobalSession, tmux.Options{
"@themepack-prefix-key-on": " #[fg=black]#[bg=cyan] ^b #[default] ",
"@themepack-prefix-key-off": " ",
"@themepack-pane-sync-on": " #[fg=black]#[bg=yellow] SYNC #[default] ",
"@themepack-pane-sync-off": " ",
"display-panes-active-colour": "default",
"display-panes-colour": "default",
"message-command-style": "default",
"message-style": "default",
"status-interval": "1",
"status-justify": "centre",
"status-left": "#S #[fg=white]» #[fg=yellow]#I #[fg=cyan]#P",
"status-left": "#S #[fg=white]» #[fg=yellow]#I #[fg=cyan]#P" + powerlinePrefixKeyStatus,
"status-left-length": "40",
"status-left-style": "fg=green,bg=black",
"status-right": "#H #[fg=white]« #[fg=yellow]%H:%M:%S #[fg=green]%d-%b-%y",
"status-right": powerlinePaneSyncStatus + "#H #[fg=white]« #[fg=yellow]%H:%M:%S #[fg=green]%d-%b-%y",
"status-right-length": "40",
"status-right-style": "fg=cyan,bg=black",
"status-style": "fg=cyan,bg=black",
@@ -91,8 +95,8 @@ func TestBasicThemeOverrides(t *testing.T) {
assert.NoError(t, err)
assertHasPrefix(t, opts["status-left"], "SLP=")
assertHasSuffix(t, opts["status-left"], "=SLS")
assertHasPrefix(t, opts["status-right"], "SRP=")
assertHasSuffix(t, opts["status-left"], "=SLS"+powerlinePrefixKeyStatus)
assertHasPrefix(t, opts["status-right"], powerlinePaneSyncStatus+"SRP=")
assertHasSuffix(t, opts["status-right"], "=SRS")
opts, err = tm.GetOptions(tmux.GlobalWindow)

View File

@@ -1,5 +1,8 @@
package test
var powerlinePrefixKeyStatus = `#{?client_prefix,#{@themepack-prefix-key-on},#{@themepack-prefix-key-off}}`
var powerlinePaneSyncStatus = `#{?pane_synchronized,#{@themepack-pane-sync-on},#{@themepack-pane-sync-off}}`
var powerlineColors = map[string]struct {
filename string
color1 string

View File

@@ -47,16 +47,20 @@ func TestPowerlineBlockThemes(t *testing.T) {
})
tmuxHasOptions(t, filename, tmux.GlobalSession, tmux.Options{
"@themepack-pane-sync-off": " #[fg=colour235]#[bg=colour233]",
"@themepack-pane-sync-on": " #[fg=" + c.color2 + "]#[bg=colour233]#[fg=black]#[bg=" + c.color2 + "] SYNC #[fg=colour235]#[bg=" + c.color2 + "]",
"@themepack-prefix-key-off": "#[fg=colour235]#[bg=colour233] ",
"@themepack-prefix-key-on": "#[fg=colour235]#[bg=black]#[fg=" + c.color2 + "]#[bg=black] . #[fg=colour233]#[bg=black]",
"display-panes-active-colour": "colour245",
"display-panes-colour": "colour233",
"message-command-style": "fg=black,bg=" + c.color1,
"message-style": "fg=black,bg=" + c.color1,
"status-interval": "1",
"status-justify": "centre",
"status-left": "#[fg=colour233,bg=" + c.color1 + ",bold] #S #[fg=" + c.color1 + ",bg=colour240,nobold]\ue0b0#[fg=colour233,bg=colour240] #(whoami) #[fg=colour240,bg=colour235]\ue0b0#[fg=colour240,bg=colour235] #I:#P #[fg=colour235,bg=colour233,nobold]\ue0b0",
"status-left": "#[fg=colour233,bg=" + c.color1 + ",bold] #S #[fg=" + c.color1 + ",bg=colour240,nobold]#[fg=colour233,bg=colour240] #(whoami) #[fg=colour240,bg=colour235]#[fg=colour240,bg=colour235] #I:#P " + powerlinePrefixKeyStatus,
"status-left-length": "40",
"status-left-style": "fg=colour243,bg=colour233",
"status-right": "#[fg=colour235,bg=colour233]\ue0b2#[fg=colour240,bg=colour235] %H:%M:%S #[fg=colour240,bg=colour235]\ue0b2#[fg=colour233,bg=colour240] %d-%b-%y #[fg=colour245,bg=colour240]\ue0b2#[fg=colour233,bg=colour245,bold] #H ",
"status-right": powerlinePaneSyncStatus + "#[fg=colour240,bg=colour235] %H:%M:%S #[fg=colour240,bg=colour235]#[fg=colour233,bg=colour240] %d-%b-%y #[fg=colour245,bg=colour240]#[fg=colour233,bg=colour245,bold] #H ",
"status-right-length": "150",
"status-right-style": "fg=colour243,bg=colour233",
"status-style": "fg=colour240,bg=colour233",
@@ -113,8 +117,8 @@ func TestPowerlineBlockThemeOverrides(t *testing.T) {
assert.NoError(t, err)
assertHasPrefix(t, opts["status-left"], "SLP=")
assertHasSuffix(t, opts["status-left"], "=SLS")
assertHasPrefix(t, opts["status-right"], "SRP=")
assertHasSuffix(t, opts["status-left"], "=SLS"+powerlinePrefixKeyStatus)
assertHasPrefix(t, opts["status-right"], powerlinePaneSyncStatus+"SRP=")
assertHasSuffix(t, opts["status-right"], "=SRS")
opts, err = tm.GetOptions(tmux.GlobalWindow)

View File

@@ -40,23 +40,27 @@ func TestPowerlineDefaultThemes(t *testing.T) {
"pane-active-border-style": "fg=" + c.color1,
"pane-border-style": "fg=colour238",
"window-status-activity-style": "fg=colour245,bg=colour233",
"window-status-current-format": "#[fg=colour233,bg=black]\ue0b0#[fg=" + c.color2 + ",nobold] #I:#W#F #[fg=colour233,bg=black,nobold]\ue0b2",
"window-status-current-format": "#[fg=colour233,bg=black]#[fg=" + c.color2 + ",nobold] #I:#W#F #[fg=colour233,bg=black,nobold]",
"window-status-current-style": "fg=" + c.color2 + ",bg=black",
"window-status-format": " #I:#W#F ",
"window-status-separator": "",
})
tmuxHasOptions(t, name, tmux.GlobalSession, tmux.Options{
"@themepack-pane-sync-off": " #[fg=colour235]#[bg=colour233]",
"@themepack-pane-sync-on": " #[fg=" + c.color2 + "]#[bg=colour233]#[fg=black]#[bg=" + c.color2 + "] SYNC #[fg=colour235]#[bg=" + c.color2 + "]",
"@themepack-prefix-key-off": "#[fg=colour235]#[bg=colour233] ",
"@themepack-prefix-key-on": "#[fg=colour235]#[bg=black]#[fg=" + c.color2 + "]#[bg=black] . #[fg=colour233]#[bg=black]",
"display-panes-active-colour": "colour245",
"display-panes-colour": "colour233",
"message-command-style": "fg=black,bg=" + c.color1,
"message-style": "fg=black,bg=" + c.color1,
"status-interval": "1",
"status-justify": "centre",
"status-left": "#[fg=colour233,bg=" + c.color1 + ",bold] #S #[fg=" + c.color1 + ",bg=colour240,nobold]\ue0b0#[fg=colour233,bg=colour240] #(whoami) #[fg=colour240,bg=colour235]\ue0b0#[fg=colour240,bg=colour235] #I:#P #[fg=colour235,bg=colour233,nobold]\ue0b0",
"status-left": "#[fg=colour233,bg=" + c.color1 + ",bold] #S #[fg=" + c.color1 + ",bg=colour240,nobold]#[fg=colour233,bg=colour240] #(whoami) #[fg=colour240,bg=colour235]#[fg=colour240,bg=colour235] #I:#P " + powerlinePrefixKeyStatus,
"status-left-length": "40",
"status-left-style": "fg=colour243,bg=colour233",
"status-right": "#[fg=colour235,bg=colour233]\ue0b2#[fg=colour240,bg=colour235] %H:%M:%S #[fg=colour240,bg=colour235]\ue0b2#[fg=colour233,bg=colour240] %d-%b-%y #[fg=colour245,bg=colour240]\ue0b2#[fg=colour233,bg=colour245,bold] #H ",
"status-right": powerlinePaneSyncStatus + "#[fg=colour240,bg=colour235] %H:%M:%S #[fg=colour240,bg=colour235]#[fg=colour233,bg=colour240] %d-%b-%y #[fg=colour245,bg=colour240]#[fg=colour233,bg=colour245,bold] #H ",
"status-right-length": "150",
"status-right-style": "fg=colour243,bg=colour233",
"status-style": "fg=colour240,bg=colour233",
@@ -113,8 +117,8 @@ func TestPowerlineDefaultThemeOverrides(t *testing.T) {
assert.NoError(t, err)
assertHasPrefix(t, opts["status-left"], "SLP=")
assertHasSuffix(t, opts["status-left"], "=SLS")
assertHasPrefix(t, opts["status-right"], "SRP=")
assertHasSuffix(t, opts["status-left"], "=SLS"+powerlinePrefixKeyStatus)
assertHasPrefix(t, opts["status-right"], powerlinePaneSyncStatus+"SRP=")
assertHasSuffix(t, opts["status-right"], "=SRS")
opts, err = tm.GetOptions(tmux.GlobalWindow)

View File

@@ -39,23 +39,27 @@ func TestPowerlineDoubleThemes(t *testing.T) {
"pane-active-border-style": "fg=" + c.color1,
"pane-border-style": "fg=colour238",
"window-status-activity-style": "fg=colour245,bg=colour233",
"window-status-current-format": "#[fg=colour233,bg=black]\ue0b0#[fg=" + c.color2 + ",nobold] #I:#W#F #[fg=colour233,bg=black,nobold]\ue0b2",
"window-status-current-format": "#[fg=colour233,bg=black]#[fg=" + c.color2 + ",nobold] #I:#W#F #[fg=colour233,bg=black,nobold]",
"window-status-current-style": "fg=" + c.color2 + ",bg=black",
"window-status-format": " #I:#W#F ",
"window-status-separator": "",
})
tmuxHasOptions(t, filename, tmux.GlobalSession, tmux.Options{
"@themepack-pane-sync-off": " #[fg=colour235]#[bg=colour233]",
"@themepack-pane-sync-on": " #[fg=" + c.color2 + "]#[bg=colour233]#[fg=black]#[bg=" + c.color2 + "] SYNC #[fg=colour235]#[bg=" + c.color2 + "]",
"@themepack-prefix-key-off": "#[fg=colour235]#[bg=colour233] ",
"@themepack-prefix-key-on": "#[fg=colour235]#[bg=black]#[fg=" + c.color2 + "]#[bg=black] . #[fg=colour233]#[bg=black]",
"display-panes-active-colour": "colour245",
"display-panes-colour": "colour233",
"message-command-style": "fg=black,bg=" + c.color1,
"message-style": "fg=black,bg=" + c.color1,
"status-interval": "1",
"status-justify": "centre",
"status-left": "#[fg=colour233,bg=" + c.color1 + ",bold] #S #[fg=" + c.color1 + ",bg=colour240,nobold]\ue0b0#[fg=colour233,bg=colour240] #(whoami) #[fg=colour240,bg=colour235]\ue0b0#[fg=colour240,bg=colour235] #I:#P #[fg=colour235,bg=colour233,nobold]\ue0b0",
"status-left": "#[fg=colour233,bg=" + c.color1 + ",bold] #S #[fg=" + c.color1 + ",bg=colour240,nobold]#[fg=colour233,bg=colour240] #(whoami) #[fg=colour240,bg=colour235]#[fg=colour240,bg=colour235] #I:#P " + powerlinePrefixKeyStatus,
"status-left-length": "40",
"status-left-style": "fg=colour243,bg=colour233",
"status-right": "#[fg=colour235,bg=colour233]\ue0b2#[fg=colour240,bg=colour235] %H:%M:%S #[fg=colour240,bg=colour235]\ue0b2#[fg=colour233,bg=colour240] %d-%b-%y #[fg=" + c.color1 + ",bg=colour240]\ue0b2#[fg=colour233,bg=" + c.color1 + ",bold] #H ",
"status-right": powerlinePaneSyncStatus + "#[fg=colour240,bg=colour235] %H:%M:%S #[fg=colour240,bg=colour235]#[fg=colour233,bg=colour240] %d-%b-%y #[fg=" + c.color1 + ",bg=colour240]#[fg=colour233,bg=" + c.color1 + ",bold] #H ",
"status-right-length": "150",
"status-right-style": "fg=colour243,bg=colour233",
"status-style": "fg=colour240,bg=colour233",
@@ -112,8 +116,8 @@ func TestPowerlineDoubleThemeOverrides(t *testing.T) {
assert.NoError(t, err)
assertHasPrefix(t, opts["status-left"], "SLP=")
assertHasSuffix(t, opts["status-left"], "=SLS")
assertHasPrefix(t, opts["status-right"], "SRP=")
assertHasSuffix(t, opts["status-left"], "=SLS"+powerlinePrefixKeyStatus)
assertHasPrefix(t, opts["status-right"], powerlinePaneSyncStatus+"SRP=")
assertHasSuffix(t, opts["status-right"], "=SRS")
opts, err = tm.GetOptions(tmux.GlobalWindow)