Skip to content
Myr

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 file

Take 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 back
1package style
23import (4 "strconv"5 "strings"6)7

fix: lint issues (#909)Carlos Alexandro Beckerbefore adoption817c4bd

lines 8–12why, one step back
8const (
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 back
13

feat: adding --padding to most commands (#960)Carlos Alexandro Beckerbefore adoption6045525

line 14why, one step back
14// 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 back
15// 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 back
16func 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 back
17 var ints [maxTokens]int
1819 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 back
51var parseMargin = ParsePadding