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

Stop words breaking across lines. #641

Closed
Kingsy opened this issue Jan 19, 2021 · 21 comments
Closed

Stop words breaking across lines. #641

Kingsy opened this issue Jan 19, 2021 · 21 comments
Labels
feature resolved if issue is resolved, it will be open until merge with master

Comments

@Kingsy
Copy link

Kingsy commented Jan 19, 2021

Hello,

By default if you echo a line longer than the terminal if it happens land in the middle of the word the terminal does not carry the word over to the next line but splits it so some chars are on one line and others on the next. This makes things quite hard to read for a paragraph of text.

Is there a way of preventing this?

Thanks

@Kingsy
Copy link
Author

Kingsy commented Jan 20, 2021

Oh, I have also just realised that when using less it doesn't word wrap at all, any idea on that one too?
Its actually really strange, it trims the line depending on the width of the page, so if you inspect the you'll see the words on that line which stops at the width of the page, if you decrease the width and inspect again there are less words in the span directly relating to how many that were trimmed off due to the loss of width.

I am guessing this is just a setting I have missed?

@jcubic
Copy link
Owner

jcubic commented Jan 20, 2021

You can make echo wrap on words there is option for that in echo keepWords

less don't wrap because this how native less works you need to use left/right arrow to show more.

@Kingsy
Copy link
Author

Kingsy commented Jan 20, 2021

Ah thats good news about echo.

Ah you are absolutely right about less, but its unfortunate in my case as I want to use it to read paragraphs of text. Is there an easy way of turning off this functionality? so it word wraps like echo within the less command?

If not I will have to write a hack before it to insert \n chars in the right places, which I don't really want to do.

@jcubic
Copy link
Owner

jcubic commented Jan 20, 2021

You would need to modify less plugin. I can check how hard it would be to add options to less. You can also try it yourself.

@Kingsy
Copy link
Author

Kingsy commented Jan 20, 2021

That would be great if you could have a look.
I'll take a look at the file myself too as you say to investigate.

@jcubic
Copy link
Owner

jcubic commented Jan 20, 2021

You need to modify function print()
https://github.com/jcubic/jquery.terminal/blob/master/js/less.js#L164
You will need to use $.terminal.split_equal before the lines are splitted, so you can proper number of lines.
I can add later today the options: wrap and keepWords.

@jcubic
Copy link
Owner

jcubic commented Jan 20, 2021

or maybe even before the lines get printed so you don't split lines each time less render text that can happen a lot on scroll.

@jcubic
Copy link
Owner

jcubic commented Jan 20, 2021

I think it would be better to modify function run() here:
https://github.com/jcubic/jquery.terminal/blob/master/js/less.js#L238
that handle initial input and return lines. Note that input can be Array of strings or string and function. There are a bit of logic there is will be more complicated when new options will be added.

@Kingsy
Copy link
Author

Kingsy commented Jan 20, 2021

Hm, that run function isnt clear how it would take the fix.
I can see that just making var should_substring = false; does the job, but the starting vertical position of less is off if I just do that, so perhaps it needs something else.

Oh right. if I am understand what you said above correctly? should I wait and you are going to add options into less to do this today?

@jcubic
Copy link
Owner

jcubic commented Jan 20, 2021

Updated less plugin, it now have two more options: wrap and keepWords.

@Kingsy
Copy link
Author

Kingsy commented Jan 20, 2021

Ahh this is great.
Will this change automatically be available via npm?

@Kingsy
Copy link
Author

Kingsy commented Jan 20, 2021

Looks like it has the latest release on there. Sorry that was obvious.
Do you think you could create a new release so I can include the new flags via npm please?

@jcubic
Copy link
Owner

jcubic commented Jan 20, 2021

No, I need to release new version first, it make take few days I have on feature that I can add to this version, which will be 2.21.0.
Also I found one bug in parsing commands that I would like to fix as soon as possible.

@Kingsy
Copy link
Author

Kingsy commented Jan 20, 2021

Thanks!
I will keep an eye out for the new version. much appreciated.

@jcubic
Copy link
Owner

jcubic commented Jan 20, 2021

The version of the file is devel branch I've accidentally pushed to master so I've removed the commit that was adding the fix.

@Kingsy
Copy link
Author

Kingsy commented Jan 20, 2021

ok np. I'll wait for the new version instead of copying the js file and linking to that.

@Kingsy
Copy link
Author

Kingsy commented Feb 1, 2021

Hi, any word on getting this in a new release?

@jcubic jcubic added feature resolved if issue is resolved, it will be open until merge with master labels Feb 2, 2021
@jcubic
Copy link
Owner

jcubic commented Feb 2, 2021

Sorry I didn't had much time to fix the other issue to release new version. In fact I've completely forgot that I need to release new version. Will fix that other issue and create that other feature maybe in this week.
If you really need this I can release kind of weird beta version for 2.21.0-beta.1 you will be able to install it from npm using:

npm install jquery.terminal@beta

@jcubic
Copy link
Owner

jcubic commented Feb 3, 2021

I've just finished fixing one bug and added the feature that I wanted in 2.21.0 it will be released soon after GitHub solve their issues, because I want my CI script to run, so I it can test the code on the server. It's works locally but I want my tests to run on the server as well.

@jcubic
Copy link
Owner

jcubic commented Feb 4, 2021

Version 2.21.0 got released.

@jcubic jcubic closed this as completed Feb 4, 2021
@king-c
Copy link

king-c commented Feb 4, 2021

Thanks for this! I'll try out the new features today. Appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature resolved if issue is resolved, it will be open until merge with master
Projects
None yet
Development

No branches or pull requests

3 participants