-
-
Notifications
You must be signed in to change notification settings - Fork 575
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
Backend support (in flush) for newline : false #654
Backend support (in flush) for newline : false #654
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, I will need to take a look little big closer how this work. And how it will behave with line wrapping, probably monkey patch in echo_newline.js also didn't handled that properly. The coverage dropped, maybe it would be good idea to also write unit tests for flush, that is missing coverage.
css/jquery.terminal.css
Outdated
width: -moz-fit-content; | ||
width: -webkit-fit-content; | ||
width: fit-content; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will not work in IE, but I think that this not a big deal. This only need to be documented. that echo newline don't work with IE.
Actually flush isn't missing coverage: most of the lines are covered 1000+ times and the only part missing coverage is the catch clause. Looking at the coverage report, every line that I added is covered a large number of times -- I was adjusting very hot functions. I don't really understand why the coverage went down: |
Few more issues I've found.
.terminal .partial {
position: relative;
z-index: 400;
}
.terminal div.partial > div {
width: -moz-fit-content !important;
width: -webkit-fit-content !important;
width: fit-content !important;
} While you modify CSS please modify
I don't have any other issues, good job, thanks for the PR PS: I didn't added the code into the library itself because it needed to be monkey patch, but I didn't know about |
That is better!
I'm really confused about why this is necessary. I don't understand the behavior of the measured height and width of elements very well at all, I always just get things to work by trial and error. In particular, do you know why |
Wait: .terminal .partial {
position: relative;
z-index: 400;
}
.terminal div.partial > div {
width: fit-content !important;
} Does this screw up the height of empty lines? Also, does |
Oh I get it, you only apply the |
Yeah this is broken when |
9f909c2
to
5779894
Compare
@jcubic Okay I think I addressed your comments? I tried to ensure that exactly one output div appears with each 'data-index' value. Currently consecutive calls to |
I'm thinking about all those inline styles you're adding, there is issue to make jQuery Terminal work with strict CSP maily inline styles. I'm planing on removing the inline styles at all. I'm wondering if it will be possible to change your code into Maybe there is better way then this, it seems that you just move the cmd to put above last line (didn't notice that first time when check the code), I think this is worse then modifying the prompt. Also I don't like exposing hidden This is why I didn't wanted to put that code into the terminal because your solution is also one big hack, like old Usually when I want echo without the newline I don't use (display "x") (display "y") (newline) and (display "x") (display "y") both work the same because there is implicit newline after the flush (flush in my code not in jQuery Terminal). I think this is better then broken command line like in bash when someone don't echo newline at the end. |
Does that approach work with sleep? I'm concerned about something like print("Enter your name: ", end="")
sys.stdin.readline() and in order to make code like this behave correctly it's helpful for the terminal to behave similar to a native terminal. |
I think I can update it to remove the inline styles, except for the
|
I will think about this, you did lot of great work. I will test how this works with my Scheme REPL in Scheme that give me problems with old echo_newline.js |
Hi, I decided that I will merge your code. I will need to check why the drop of 0.07 in coverage though. It's getting close to 82 after rounding. I will yet again documentation issue to document that |
Would you like me to try to modify to remove the added inline styles? |
You can try but I don't think it's really possible with current approach. You need dynamic top and left to move the cmd. I was thinking about CSP fix with dynamic I've found one issue with your solution. If you echo without newline you can't select text of the prompt. The problem is that div with partial class is on top of the cmd. This is the fix: .terminal div.partial > div, .terminal div.partial {
width: 100% !important;
width: -moz-fit-content !important;
width: -webkit-fit-content !important;
width: fit-content !important;
} |
I will also need to check how this will work on mobile phone. |
Another bug is in copy/paste terminal is hijacking the right click over hidden textarea to allow pasting of text. This don't work anymore if you echo without newline. |
Well if you had a css variable .cmd.shift_up {
top : calc(-var(--line-height));
} and then add or remove the .cmd .prompt-margin {
display: inline-block;
user-select : none;
visibility : hidden;
width : fit-content; /* plus vendor-versions */
} and set the text in the span like |
I think there is also a bug if the prompt is empty. |
Any update on this? |
Sorry didn't have time to test locally how this works. Will merge into experimental branch, since this is not 100% ready. |
Will check how this work and maybe fix some issues, maybe tomorrow will find some time. |
Thanks! |
It works great, thanks for working on this. I've added minor change to get rid of 0.01px border, I've added zero space width prompt when it's empty. |
About copy/paste it's also broken on devel branch. |
New version 2.23.0 with the feature was just released. |
Thanks! I'm really glad this worked out. |
Add one fix to your hack to force reflow in Firefox, it was not shoring the cursor in one of my projects, I've set the timeout to 0 but move the showing timeout into the first timeout. PS: what tools did you use to show the coverage? I've missed that first time when you added that screenshot. |
Fix scrolling up randomly when type run commands that echo something Caused by changes in PR #654
The current behavior of
term.echo(str, {newline : false})
is pretty buggy. For example:term.error(str, {newline : false})
doesn't produce red text, it interferes withterm.get_prompt
which will show the partially echoed line of text andterm.set_prompt
which won't work correctly at all, it seems to be incompatible with a bunch of the other options (I don't expect finalize to work). TheENTER
handler it provides also causes weird effect.The problem is that the text echoed with
newline : false
is handled in a hacked-on extension. In order to get the behavior to be consistent and to makenewline : false
interact correctly with other formatting, the feature should be implemented in the core rendering engine and not as an add-on.This PR moves the implementation of the
newline
option into the main rendering engine. The main idea is to output the partial line as normal but whenever the output ends in a partial line of text, update the style for the command line to move it up and the first line of it over to position the input field to the right of the final partial output field.