X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=cmd%2Fmicro%2Fstatusline.go;h=19e409d7edf5b83420590f2ad8b02cbe1f22cceb;hb=c32f5a48598c3399c0661caa2185da8ad9531627;hp=c2af51badcb5b47d282a9eb4d5e7fbe0c1f1f66c;hpb=59251ee5d02f0320051a7df32f7220a3d3de442c;p=micro.git diff --git a/cmd/micro/statusline.go b/cmd/micro/statusline.go index c2af51ba..19e409d7 100644 --- a/cmd/micro/statusline.go +++ b/cmd/micro/statusline.go @@ -1,6 +1,7 @@ package main import ( + "path" "strconv" ) @@ -14,13 +15,20 @@ type Statusline struct { // Display draws the statusline to the screen func (sline *Statusline) Display() { + if messenger.hasPrompt && !GetGlobalOption("infobar").(bool) { + return + } + // We'll draw the line at the lowest line in the view - y := sline.view.height + sline.view.y + y := sline.view.Height + sline.view.y file := sline.view.Buf.GetName() + if sline.view.Buf.Settings["basename"].(bool) { + file = path.Base(file) + } // If the buffer is dirty (has been modified) write a little '+' - if sline.view.Buf.IsModified { + if sline.view.Buf.Modified() { file += " +" } @@ -36,10 +44,27 @@ func (sline *Statusline) Display() { // Add the filetype file += " " + sline.view.Buf.FileType() - rightText := helpBinding + " for help " - if sline.view.Type == vtHelp { - rightText = helpBinding + " to close help " + file += " " + sline.view.Buf.Settings["fileformat"].(string) + + rightText := "" + if len(kmenuBinding) > 0 { + if globalSettings["keymenu"].(bool) { + rightText += kmenuBinding + ": hide bindings" + } else { + rightText += kmenuBinding + ": show bindings" + } + } + if len(helpBinding) > 0 { + if len(kmenuBinding) > 0 { + rightText += ", " + } + if sline.view.Type == vtHelp { + rightText += helpBinding + ": close help" + } else { + rightText += helpBinding + ": open help" + } } + rightText += " " statusLineStyle := defStyle.Reverse(true) if style, ok := colorscheme["statusline"]; ok { @@ -53,11 +78,11 @@ func (sline *Statusline) Display() { screen.SetContent(viewX, y, ' ', nil, statusLineStyle) viewX++ } - for x := 0; x < sline.view.width; x++ { + for x := 0; x < sline.view.Width; x++ { if x < len(fileRunes) { screen.SetContent(viewX+x, y, fileRunes[x], nil, statusLineStyle) - } else if x >= sline.view.width-len(rightText) && x < len(rightText)+sline.view.width-len(rightText) { - screen.SetContent(viewX+x, y, []rune(rightText)[x-sline.view.width+len(rightText)], nil, statusLineStyle) + } else if x >= sline.view.Width-len(rightText) && x < len(rightText)+sline.view.Width-len(rightText) { + screen.SetContent(viewX+x, y, []rune(rightText)[x-sline.view.Width+len(rightText)], nil, statusLineStyle) } else { screen.SetContent(viewX+x, y, ' ', nil, statusLineStyle) }