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

Enable right-justified text #7

Open
dimo414 opened this issue Apr 13, 2016 · 1 comment
Open

Enable right-justified text #7

dimo414 opened this issue Apr 13, 2016 · 1 comment
Labels
enhancement New feature or request major

Comments

@dimo414
Copy link
Owner

dimo414 commented Apr 13, 2016

Original report by Michael Diamond (Bitbucket: dimo414).


Example syntax:

ansi().out("Message").rightJustify().out("[ ").color(GREEN).out("OK").out(" ]");

Should ouput (in an 80 column window):

Message                                                                   [ OK ]

This is a little tricky since both the left- and right-justified text can have complex formatting, but we want to avoid just replicating the same logic twice. Ideally also rightJustify() wouldn't just return an Ansi instance since the right-justified text will have limited functionality (shouldn't be able to call rightJustify() again, no cursor movement, etc.).

I'm also not certain whether this should live in Ansi or AnsiUtils. It feels a little complex for Ansi, but it would fit nicely with it's fluent interface.

One idea would be for rightJustify() to simply record the current buffer length and insert $COLUMNS - rightSide.length() spaces at that index before outputting.

@dimo414
Copy link
Owner Author

dimo414 commented Jun 14, 2017

Original comment by Michael Diamond (Bitbucket: dimo414).


Unfortunately $COLUMNS isn't available unless the user runs export COLUMNS, which isn't desirable. Some workarounds in https://stackoverflow.com/q/1286461/113632

@dimo414 dimo414 added major enhancement New feature or request labels Jan 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request major
Projects
None yet
Development

No branches or pull requests

1 participant