Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disabling alignment when rendering multiple lines #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions get.go
Expand Up @@ -417,12 +417,12 @@ func (s Style) getAsInt(k propKey) int {
func (s Style) getAsPosition(k propKey) Position {
v, ok := s.rules[k]
if !ok {
return Position(0)
return NotAligned
}
if p, ok := v.(Position); ok {
return p
}
return Position(0)
return NotAligned
}

func (s Style) getBorderStyle() Border {
Expand Down
11 changes: 6 additions & 5 deletions position.go
Expand Up @@ -24,11 +24,12 @@ func (p Position) value() float64 {

// Position aliases.
const (
Top Position = 0.0
Bottom Position = 1.0
Center Position = 0.5
Left Position = 0.0
Right Position = 1.0
Top Position = 0.0
Bottom Position = 1.0
Center Position = 0.5
Left Position = 0.0
Right Position = 1.0
NotAligned Position = -1.0
)

// Place places a string or text block vertically in an unstyled box of a given
Expand Down
2 changes: 1 addition & 1 deletion style.go
Expand Up @@ -333,7 +333,7 @@ func (s Style) Render(str string) string {
// Set alignment. This will also pad short lines with spaces so that all
// lines are the same length, so we run it under a few different conditions
// beyond alignment.
{
if align != NotAligned {
numLines := strings.Count(str, "\n")

if !(numLines == 0 && width == 0) {
Expand Down