Skip to content

Commit

Permalink
Merge pull request #22 from matsuyoshi30/fix-width
Browse files Browse the repository at this point in the history
Fix width calculation
  • Loading branch information
matsuyoshi30 authored Aug 11, 2021
2 parents 31472af + eb2f629 commit b9dcd82
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 0 additions & 1 deletion panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ type Labeler interface {

func NewImage(src string, face font.Face, noWindowAccessBar bool) *Panel {
ml := MaxLine(src)
ml = strings.ReplaceAll(ml, "\t", " ") // replace tab to whitespace
ml = ml + " "

width := CalcWidth(font.MeasureString(face, " ").Ceil() * len(ml))
Expand Down
2 changes: 2 additions & 0 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func ReadString(r io.Reader, face font.Face) (string, error) {
}

func MaxLine(s string) string {
s = strings.ReplaceAll(s, "\t", " ") // replace tab to whitespace

var ret string
for _, line := range strings.Split(s, "\n") {
if utf8.RuneCountInString(ret) < utf8.RuneCountInString(line) {
Expand Down

0 comments on commit b9dcd82

Please # to comment.