Skip to content

Commit

Permalink
fixed whitespace in accordance with review https://github.com/huderle…
Browse files Browse the repository at this point in the history
  • Loading branch information
pkmnsnfrn committed Dec 24, 2023
1 parent 43c349f commit 0a4ee78
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions parser/formattext.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Fonts struct {
Widths map[string]int `json:"widths"`
CursorOverlapWidth int `json:"cursorOverlapWidth"`
MaxLineLength int `json:"maxLineLength"`
numLines int `json:"numLines"`
numLines int `json:"numLines"`
}

// LoadFontConfig reads a font width config JSON file.
Expand Down Expand Up @@ -57,7 +57,7 @@ func (fc *FontConfig) FormatText(text string, maxWidth int, cursorOverlapWidth i
var formattedSb strings.Builder
var curLineSb strings.Builder
curWidth := 0
curLineNum := 0
curLineNum := 0
isFirstWord := true
spaceCharWidth := fc.getRunePixelWidth(' ', fontID)
pos, word := fc.getNextWord(text)
Expand All @@ -72,7 +72,7 @@ func (fc *FontConfig) FormatText(text string, maxWidth int, cursorOverlapWidth i
curWidth = 0
formattedSb.WriteString(curLineSb.String())
if fc.isAutoLineBreak(word) {
if fc.isFirstLine(curLineNum) {
if fc.isFirstLine(curLineNum) {
formattedSb.WriteString(`\n`)
} else {
formattedSb.WriteString(`\l`)
Expand All @@ -82,7 +82,7 @@ func (fc *FontConfig) FormatText(text string, maxWidth int, cursorOverlapWidth i
}
formattedSb.WriteByte('\n')
if !fc.isParagraphBreak(word) {
curLineNum++
curLineNum++
}
isFirstWord = true
curLineSb.Reset()
Expand All @@ -103,13 +103,13 @@ func (fc *FontConfig) FormatText(text string, maxWidth int, cursorOverlapWidth i
if nextWidth > maxWidth && curLineSb.Len() > 0 {
formattedSb.WriteString(curLineSb.String())

if fc.shouldUseLineFeed(curLineNum, numLines) {
if fc.shouldUseLineFeed(curLineNum, numLines) {
formattedSb.WriteString(`\l`)
} else {
formattedSb.WriteString(`\n`)
}
formattedSb.WriteString(`\n`)
}

curLineNum++
curLineNum++
formattedSb.WriteByte('\n')
isFirstWord = false
curLineSb.Reset()
Expand All @@ -135,11 +135,11 @@ func (fc *FontConfig) FormatText(text string, maxWidth int, cursorOverlapWidth i
}

func (fc *FontConfig) isFirstLine(curLineNum int) bool {
return curLineNum == 0
return curLineNum == 0
}

func (fc *FontConfig) shouldUseLineFeed(curLineNum int, numLines int) bool {
return curLineNum >= (numLines - 1)
return curLineNum >= (numLines - 1)
}

func (fc *FontConfig) getNextWord(text string) (int, string) {
Expand Down

0 comments on commit 0a4ee78

Please sign in to comment.