X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=cmd%2Fmicro%2Fstatusline.go;h=d346a033852e0fd4a370896fa2b6fdf0f61038aa;hb=41a24e61d6b9017dbe010ae36295cb3c1dd701fc;hp=b9cd0af5536c64c2f29bb2245151399661ab3896;hpb=eba820a9c775de67e85da1da1ba35e58a1928c77;p=micro.git diff --git a/cmd/micro/statusline.go b/cmd/micro/statusline.go index b9cd0af5..d346a033 100644 --- a/cmd/micro/statusline.go +++ b/cmd/micro/statusline.go @@ -1,6 +1,7 @@ package main import ( + "path" "strconv" ) @@ -14,17 +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 + y := sline.view.Height + sline.view.y - file := sline.view.Buf.Name - // If the name is empty, use 'No name' - if file == "" { - file = "No name" + 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.IsDirty() { + if sline.view.Buf.Modified() { file += " +" } @@ -33,16 +37,35 @@ func (sline *Statusline) Display() { // We use GetVisualX() here because otherwise we get the column number in runes // so a '\t' is only 1, when it should be tabSize columnNum := strconv.Itoa(sline.view.Cursor.GetVisualX() + 1) - lineNum := strconv.Itoa(sline.view.Cursor.y + 1) + lineNum := strconv.Itoa(sline.view.Cursor.Y + 1) file += " (" + lineNum + "," + columnNum + ")" // Add the filetype - file += " " + sline.view.Buf.Filetype + file += " " + sline.view.Buf.FileType() + + file += " " + sline.view.Buf.Settings["fileformat"].(string) - rightText := "Ctrl-g for help " - if helpOpen { - rightText = "Ctrl-g to close help " + rightText := "" + if !sline.view.Buf.Settings["hidehelp"].(bool) { + 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) @@ -52,13 +75,24 @@ func (sline *Statusline) Display() { // Maybe there is a unicode filename? fileRunes := []rune(file) - for x := 0; x < sline.view.width; x++ { + + if sline.view.Type == vtTerm { + fileRunes = []rune(sline.view.term.title) + rightText = "" + } + + viewX := sline.view.x + if viewX != 0 { + screen.SetContent(viewX, y, ' ', nil, statusLineStyle) + viewX++ + } + for x := 0; x < sline.view.Width; x++ { if x < len(fileRunes) { - screen.SetContent(x, y, fileRunes[x], nil, statusLineStyle) - } else if x >= sline.view.width-len(rightText) && x < len(rightText)+sline.view.width-len(rightText) { - screen.SetContent(x, y, []rune(rightText)[x-sline.view.width+len(rightText)], nil, statusLineStyle) + 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 { - screen.SetContent(x, y, ' ', nil, statusLineStyle) + screen.SetContent(viewX+x, y, ' ', nil, statusLineStyle) } } }