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

Update AreaPrinter.WithCenter() to allow individual centering of lines #619

Closed

Conversation

prnvbn
Copy link

@prnvbn prnvbn commented Jan 21, 2024

Description

Update AreaPrinter.WithCenter() to allow individual centering of lines

Scope

What is affected by this pull request?

  • Bug Fix
  • New Feature
  • Documentation
  • Other

Related Issue

Fixes #618

To-Do Checklist

  • I tested my changes
  • I have commented every method that I created/changed
  • I updated the examples to fit with my changes
  • I have added tests for my newly created methods

Copy link

codecov bot commented Jan 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (55cd2a7) 81.65% compared to head (f5e646c) 81.67%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #619      +/-   ##
==========================================
+ Coverage   81.65%   81.67%   +0.01%     
==========================================
  Files          33       33              
  Lines        4127     4130       +3     
==========================================
+ Hits         3370     3373       +3     
  Misses        693      693              
  Partials       64       64              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -43,7 +44,10 @@ func (p AreaPrinter) WithFullscreen(b ...bool) *AreaPrinter {
}

// WithCenter centers the AreaPrinter content to the terminal.
func (p AreaPrinter) WithCenter(b ...bool) *AreaPrinter {
func (p AreaPrinter) WithCenter(centerEachLineSeparately bool, b ...bool) *AreaPrinter {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, this would be a breaking change, as the parameters changed.

@MarvinJWendt
Copy link
Member

Thanks for the PR!
I am not sure if we really need to add this to the AreaPrinter, as it is already possible using the putils package in PTerm (which should definitely be documented better):

func main() {
	area, _ := pterm.DefaultArea.WithCenter().Start()

	for i := 0; i < 10; i++ {
		var str string
		str += "Hello, World!\n"
		str += "Current iteration: " + strconv.Itoa(i) + "\n"
		str += "Long text asdasdasdasdasd"
		area.Update(putils.CenterText(str))
		time.Sleep(time.Second)
	}

	area.Stop()
}

@prnvbn prnvbn closed this Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update AreaPrinter.WithCenter() to allow individual centering of lines
2 participants