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

if the text is wider than the term every frame is printed on a new line #7

Closed
dylang opened this issue Mar 31, 2016 · 4 comments
Closed

Comments

@dylang
Copy link

dylang commented Mar 31, 2016

Problem

If the text is too long, every frame is printed on a new line, eventually filling up the screen.

Example

const ora = require('ora');
const spinner = ora('too long! '.repeat(process.stdout.columns));
spinner.start();
// be prepared to hit control-c a bunch of times

screen shot 2016-03-30 at 8 47 58 pm

### Real-world example - https://github.com/dylang/npm-check/issues/98 ### Possible workaround - Limit text to `process.stdout.columns - 2` (spinner and the space next to the spinner)
@dylang
Copy link
Author

dylang commented Mar 31, 2016

Another possible solution is to support wrapped text.

I'm not able to check to see if #4 is a possible solution to this issue at this time.

@daveseco7
Copy link

daveseco7 commented Aug 17, 2017

I was trying out the @dylang work around, where we limit the line size to the size of the stdout.columns - 2, thus reserving space for the spinner and white space.
My only concern with this approach is, can the oversize text be discarded?

The following gif illustrates the result of such implementation, if it's something in line with what you have in mind, I can prepare a PR.
github

@sindresorhus
Copy link
Owner

This could probably be fixed by using log-update.

@daveseco7
Copy link

By replacing stream.write(...) method calls to logUpdate(...) this problem is solved, but once again it may cause some problems. How to manage streams? In ora stdout and stderr may be specified as an argument, which translates into calling logUpdate() or logUpdate.stderr() respectively. This also causes tests to fail, since the output may not be read by the test result. (have not yet confirmed the cause of this issue).

sindresorhus pushed a commit that referenced this issue Feb 21, 2018
* Conform with latest XO

* Handle wrapped text

Count how many rows are taken up by the spinner and the text and clear
the appropriate number of lines. Fix clear() so it doesn't clear
*further* lines until render() is called again.

Fixes #38. Fixes #7.

* Add hideCursor option

Fixes #27. Users may still hide the cursor outside of Ora.

* Test with Node.js 8 and 9

* Properly clear empty lines

* Consistently set linesToClear to 0 once cleared
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants