]> git.lizzy.rs Git - micro.git/blobdiff - cmd/micro/statusline.go
Code optimisation (#1117)
[micro.git] / cmd / micro / statusline.go
index 763f53c56f19b177955a8d6f88faf09b82b51c35..d346a033852e0fd4a370896fa2b6fdf0f61038aa 100644 (file)
@@ -1,6 +1,7 @@
 package main
 
 import (
+       "path"
        "strconv"
 )
 
@@ -14,10 +15,17 @@ 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
 
        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.Modified() {
@@ -39,24 +47,26 @@ func (sline *Statusline) Display() {
        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 !sline.view.Buf.Settings["hidehelp"].(bool) {
                if len(kmenuBinding) > 0 {
-                       rightText += ", "
+                       if globalSettings["keymenu"].(bool) {
+                               rightText += kmenuBinding + ": hide bindings"
+                       } else {
+                               rightText += kmenuBinding + ": show bindings"
+                       }
                }
-               if sline.view.Type == vtHelp {
-                       rightText += helpBinding + ": close help"
-               } else {
-                       rightText += helpBinding + ": open help"
+               if len(helpBinding) > 0 {
+                       if len(kmenuBinding) > 0 {
+                               rightText += ", "
+                       }
+                       if sline.view.Type == vtHelp {
+                               rightText += helpBinding + ": close help"
+                       } else {
+                               rightText += helpBinding + ": open help"
+                       }
                }
+               rightText += " "
        }
-       rightText += " "
 
        statusLineStyle := defStyle.Reverse(true)
        if style, ok := colorscheme["statusline"]; ok {
@@ -65,6 +75,12 @@ func (sline *Statusline) Display() {
 
        // Maybe there is a unicode filename?
        fileRunes := []rune(file)
+
+       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)