-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tartavull
committed
Aug 20, 2023
1 parent
765ea0e
commit ad076ef
Showing
7 changed files
with
109 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package common | ||
|
||
import ( | ||
zone "github.com/lrstanley/bubblezone" | ||
"github.com/muesli/reflow/truncate" | ||
"github.com/muesli/termenv" | ||
) | ||
|
||
// TruncateString is a convenient wrapper around truncate.TruncateString. | ||
func TruncateString(s string, max int) string { | ||
if max < 0 { | ||
max = 0 | ||
} | ||
return truncate.StringWithTail(s, uint(max), "…") | ||
} | ||
|
||
type contextKey struct { | ||
name string | ||
} | ||
|
||
// Common is a struct all components should embed. | ||
type Common struct { | ||
Width, Height int | ||
Styles *Styles | ||
Zone *zone.Manager | ||
Output *termenv.Output | ||
} | ||
|
||
// NewCommon returns a new Common struct. | ||
func NewCommon(width, height int,s *Styles) Common { | ||
return Common{ | ||
Width: width, | ||
Height: height, | ||
Styles: s, | ||
Zone: zone.New(), | ||
} | ||
} | ||
|
||
// SetSize sets the width and height of the common struct. | ||
func (c *Common) SetSize(width, height int) { | ||
c.Width = width | ||
c.Height = height | ||
} | ||
|
||
func strptr(s string) *string { | ||
return &s | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters