mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 12:55:47 +02:00
Mid refactor change some more stuff
This commit is contained in:
parent
e65ddd7b6f
commit
e8eb78617c
16 changed files with 220 additions and 118 deletions
|
@ -10,7 +10,10 @@ import (
|
|||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
func splitLines(multilineString string) []string {
|
||||
// SplitLines takes a multiline string and splits it on newlines
|
||||
// currently we are also stripping \r's which may have adverse effects for
|
||||
// windows users (but no issues have been raised yet)
|
||||
func SplitLines(multilineString string) []string {
|
||||
multilineString = strings.Replace(multilineString, "\r", "", -1)
|
||||
if multilineString == "" || multilineString == "\n" {
|
||||
return make([]string, 0)
|
||||
|
@ -22,25 +25,29 @@ func splitLines(multilineString string) []string {
|
|||
return lines
|
||||
}
|
||||
|
||||
func withPadding(str string, padding int) string {
|
||||
// WithPadding pads a string as much as you want
|
||||
func WithPadding(str string, padding int) string {
|
||||
if padding-len(str) < 0 {
|
||||
return str
|
||||
}
|
||||
return str + strings.Repeat(" ", padding-len(str))
|
||||
}
|
||||
|
||||
func coloredString(str string, colorAttribute color.Attribute) string {
|
||||
// ColoredString takes a string and a colour attribute and returns a colored
|
||||
// string with that attribute
|
||||
func ColoredString(str string, colorAttribute color.Attribute) string {
|
||||
colour := color.New(colorAttribute)
|
||||
return coloredStringDirect(str, colour)
|
||||
return ColoredStringDirect(str, colour)
|
||||
}
|
||||
|
||||
// used for aggregating a few color attributes rather than just sending a single one
|
||||
func coloredStringDirect(str string, colour *color.Color) string {
|
||||
// ColoredStringDirect used for aggregating a few color attributes rather than
|
||||
// just sending a single one
|
||||
func ColoredStringDirect(str string, colour *color.Color) string {
|
||||
return colour.SprintFunc()(fmt.Sprint(str))
|
||||
}
|
||||
|
||||
// used to get the project name
|
||||
func getCurrentProject() string {
|
||||
// GetCurrentProject gets the repo's base name
|
||||
func GetCurrentProject() string {
|
||||
pwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
log.Fatalln(err.Error())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue