spacing.go
This file
Path
style/spacing.go
51 lines · 1002 bytes · Go
Last changed by
feat: adding --padding to most commands (#960)Carlos Alexandro Beckerbefore adoption6045525
History of this fileTake it
The walk stopped after 200 commits: lines older than 6837ed2 point at it.
feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
lines 1–7why, one step back1package style23import (4 "strconv"5 "strings"6)7fix: lint issues (#909)Carlos Alexandro Beckerbefore adoption817c4bd
lines 8–12why, one step back8const (9 minTokens = 110 halfTokens = 211 maxTokens = 412)feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
line 13why, one step back13feat: adding --padding to most commands (#960)Carlos Alexandro Beckerbefore adoption6045525
line 14why, one step back14// ParsePadding parses 1 - 4 integers from a string and returns them in a top,feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
line 15why, one step back15// right, bottom, left order for use in the lipgloss.Padding() method.feat: adding --padding to most commands (#960)Carlos Alexandro Beckerbefore adoption6045525
line 16why, one step back16func ParsePadding(s string) (int, int, int, int) {feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
lines 17–50why, one step back17 var ints [maxTokens]int1819 tokens := strings.Split(s, " ")2021 if len(tokens) > maxTokens {22 return 0, 0, 0, 023 }2425 // All tokens must be an integer26 for i, token := range tokens {27 parsed, err := strconv.Atoi(token)28 if err != nil {29 return 0, 0, 0, 030 }31 ints[i] = parsed32 }3334 if len(tokens) == minTokens {35 return ints[0], ints[0], ints[0], ints[0]36 }3738 if len(tokens) == halfTokens {39 return ints[0], ints[1], ints[0], ints[1]40 }4142 if len(tokens) == maxTokens {43 return ints[0], ints[1], ints[2], ints[3]44 }4546 return 0, 0, 0, 047}4849// parseMargin is an alias for parsePadding since they involve the same logic50// to parse integers to the same format.feat: adding --padding to most commands (#960)Carlos Alexandro Beckerbefore adoption6045525
line 51why, one step back51var parseMargin = ParsePadding