Add hidehelp support
This commit is contained in:
parent
995e1dc704
commit
c93d7a1b35
4 changed files with 26 additions and 16 deletions
|
@ -365,13 +365,9 @@ func SetGlobalOption(option, value string) error {
|
|||
for _, b := range buffer.OpenBuffers {
|
||||
b.UpdateRules()
|
||||
}
|
||||
}
|
||||
|
||||
if option == "infobar" || option == "keymenu" {
|
||||
} else if option == "infobar" || option == "keymenu" {
|
||||
Tabs.Resize()
|
||||
}
|
||||
|
||||
if option == "mouse" {
|
||||
} else if option == "mouse" {
|
||||
if !nativeValue.(bool) {
|
||||
screen.Screen.DisableMouse()
|
||||
} else {
|
||||
|
|
|
@ -107,6 +107,9 @@ type Buffer struct {
|
|||
CurSuggestion int
|
||||
|
||||
Messages []*Message
|
||||
|
||||
StatusFormatLeft string
|
||||
StatusFormatRight string
|
||||
}
|
||||
|
||||
// NewBufferFromFile opens a new buffer using the given path
|
||||
|
@ -236,11 +239,25 @@ func NewBuffer(r io.Reader, size int64, path string, cursorPosition []string, bt
|
|||
screen.TermMessage(err)
|
||||
}
|
||||
|
||||
b.SetStatusFormat()
|
||||
|
||||
OpenBuffers = append(OpenBuffers, b)
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
// SetStatusFormat will correctly set the format string for the
|
||||
// status line
|
||||
func (b *Buffer) SetStatusFormat() {
|
||||
if b.Settings["hidehelp"].(bool) {
|
||||
b.StatusFormatLeft = "$(filename) $(modified)($(line),$(col)) $(opt:filetype) $(opt:fileformat) $(opt:encoding)"
|
||||
b.StatusFormatRight = ""
|
||||
} else {
|
||||
b.StatusFormatLeft = "$(filename) $(modified)($(line),$(col)) $(opt:filetype) $(opt:fileformat) $(opt:encoding)"
|
||||
b.StatusFormatRight = "$(bind:ToggleKeyMenu): show bindings, $(bind:ToggleHelp): toggle help"
|
||||
}
|
||||
}
|
||||
|
||||
// Close removes this buffer from the list of open buffers
|
||||
func (b *Buffer) Close() {
|
||||
for i, buf := range OpenBuffers {
|
||||
|
|
|
@ -45,6 +45,8 @@ func (b *Buffer) SetOption(option, value string) error {
|
|||
}
|
||||
} else if option == "encoding" {
|
||||
b.isModified = true
|
||||
} else if option == "hidehelp" {
|
||||
b.SetStatusFormat()
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -18,9 +18,7 @@ import (
|
|||
// It gives information such as filename, whether the file has been
|
||||
// modified, filetype, cursor location
|
||||
type StatusLine struct {
|
||||
FormatLeft string
|
||||
FormatRight string
|
||||
Info map[string]func(*buffer.Buffer) string
|
||||
Info map[string]func(*buffer.Buffer) string
|
||||
|
||||
win *BufWindow
|
||||
}
|
||||
|
@ -30,9 +28,6 @@ type StatusLine struct {
|
|||
// NewStatusLine returns a statusline bound to a window
|
||||
func NewStatusLine(win *BufWindow) *StatusLine {
|
||||
s := new(StatusLine)
|
||||
s.FormatLeft = "$(filename) $(modified)($(line),$(col)) $(opt:filetype) $(opt:fileformat) $(opt:encoding)"
|
||||
// s.FormatLeft = "$(filename) $(modified)(line,col) $(opt:filetype) $(opt:fileformat)"
|
||||
s.FormatRight = "$(bind:ToggleKeyMenu): show bindings, $(bind:ToggleHelp): toggle help"
|
||||
s.Info = map[string]func(*buffer.Buffer) string{
|
||||
"filename": func(b *buffer.Buffer) string {
|
||||
if b.Settings["basename"].(bool) {
|
||||
|
@ -90,10 +85,10 @@ func (s *StatusLine) Display() {
|
|||
}
|
||||
}
|
||||
|
||||
leftText := []byte(s.FormatLeft)
|
||||
leftText = formatParser.ReplaceAllFunc([]byte(s.FormatLeft), formatter)
|
||||
rightText := []byte(s.FormatRight)
|
||||
rightText = formatParser.ReplaceAllFunc([]byte(s.FormatRight), formatter)
|
||||
leftText := []byte(s.win.Buf.StatusFormatLeft)
|
||||
leftText = formatParser.ReplaceAllFunc(leftText, formatter)
|
||||
rightText := []byte(s.win.Buf.StatusFormatRight)
|
||||
rightText = formatParser.ReplaceAllFunc(rightText, formatter)
|
||||
|
||||
statusLineStyle := config.DefStyle.Reverse(true)
|
||||
if style, ok := config.Colorscheme["statusline"]; ok {
|
||||
|
|
Loading…
Reference in a new issue