github.com/dawidd6/lazygit@v0.8.1/pkg/commands/file.go (about) 1 package commands 2 3 import "github.com/fatih/color" 4 5 // File : A file from git status 6 // duplicating this for now 7 type File struct { 8 Name string 9 HasStagedChanges bool 10 HasUnstagedChanges bool 11 Tracked bool 12 Deleted bool 13 HasMergeConflicts bool 14 HasInlineMergeConflicts bool 15 DisplayString string 16 Type string // one of 'file', 'directory', and 'other' 17 ShortStatus string // e.g. 'AD', ' A', 'M ', '??' 18 } 19 20 // GetDisplayStrings returns the display string of a file 21 func (f *File) GetDisplayStrings(isFocused bool) []string { 22 // potentially inefficient to be instantiating these color 23 // objects with each render 24 red := color.New(color.FgRed) 25 green := color.New(color.FgGreen) 26 if !f.Tracked && !f.HasStagedChanges { 27 return []string{red.Sprint(f.DisplayString)} 28 } 29 30 output := green.Sprint(f.DisplayString[0:1]) 31 output += red.Sprint(f.DisplayString[1:3]) 32 if f.HasUnstagedChanges { 33 output += red.Sprint(f.Name) 34 } else { 35 output += green.Sprint(f.Name) 36 } 37 return []string{output} 38 }