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

Line continuation support #26

Closed
nvanwyen opened this issue Sep 25, 2018 · 39 comments
Closed

Line continuation support #26

nvanwyen opened this issue Sep 25, 2018 · 39 comments

Comments

@nvanwyen
Copy link

I ran into your library, which looks stunning (thank you), and was wondering if it supported line continuation. For example, my need requires that the user be able to "enter" and continue to the next line, with a numerical indicator of the line. Except for the builtin (help format, save, etc... ) commands are ended with a semi-colon ";" ... something like this ...

replxx> this
      2 is
      3 an
      4 example of 
      5 continuation lines;
replxx> this is an example of  continuation lines;

I haven't dug into the library yet, so I thought I'd ask before spending to much time. Any advice, example, or information you can provide would be greatly appreciated.

Thank you

@nvanwyen nvanwyen changed the title Lin continuation support Line continuation support Sep 25, 2018
@AmokHuginnsson
Copy link
Owner

AmokHuginnsson commented Sep 25, 2018

Hello.

What you are talking right now is multiline editing.
Unfortunately replxx right now does not support this feature.
Though I am all for adding this feature to library.
The work required is substantial, I do not work on replxx full time ;)
so help would be appreciated.

The work would have to start with fixing #6, or maybe a new issue should be
opened for refactoring keybinding code in inputbuffer.cxx.

Only after that multiline editing (or continuation editing as you call it) should be added.

Hope that answers your question.

Regards.

@nvanwyen
Copy link
Author

I've cloned the code and I'm looking at it. If I get anywhere with #6 (as that would also be useful for my project), I'll certainly share it

@loics2
Copy link

loics2 commented Nov 26, 2020

Any news about this feature?

@AmokHuginnsson
Copy link
Owner

Replxx code base has been cleaned up so work on new major feature like multiline editing could be started. I would gladly accept pull requests implementing this feature.

@loics2
Copy link

loics2 commented Nov 30, 2020

Great ! I could take a look, do you have an idea where to start? I don't really know the codebase yet.

@AmokHuginnsson
Copy link
Owner

replxx_impl.cxx is where most of the logic is implemented.
One suggestion would be to disable all fancy features (hints, highlighting),
when multi-line entry is detected.
Newlines could be bound to Shift-Enter (as this combination can be distinguished from plain Enter on terminals).

@PerBothner
Copy link

"Newlines could be bound to Shift-Enter (as this combination can be distinguished from plain Enter on terminals)."

Alternatively Alt-Enter, which is used by fish shell

@minfrin
Copy link
Contributor

minfrin commented Apr 8, 2021

According to the README.md:

single-line and multi-line editing mode with the usual key bindings implemented

What is the "multi-line editing mode", and how is it different to "line continuation support"?

@AmokHuginnsson
Copy link
Owner

Hello.
Current master (e7646e7) is implementing true multiline editing.

@amosbird
Copy link
Contributor

amosbird commented Sep 10, 2021

@AmokHuginnsson This is pure awesome! I've started using it for a couple of hours now. However, there is one tiny issue: when moving cursors fast enough (word movements), replxx seems rendering a bit slow. I can visibly experience text "jittering". Maybe we can improve the performance somehow?

@AmokHuginnsson
Copy link
Owner

I think we could partially skip virtual_render() calls if we detect that refresh_line() was called because of cursor movement. We could skip painting itself.

@AmokHuginnsson
Copy link
Owner

@amosbird
I have implemented cursor movement optimization in current master (5ee2234).

@amosbird
Copy link
Contributor

Cool! It's indeed better. Though some movements are still glitchy.

Good: Word-Left, Home, End
Bad: Up, Down, Left, Right, Word-Right

Btw, it seems we don't handle multiple lines properly which cannot be filled in one screen. I guess it's ok for the moment)

@AmokHuginnsson
Copy link
Owner

In what ways are they glitchy?

@AmokHuginnsson
Copy link
Owner

Oh, I know how left and right can be glitchy. I will happen if you have a lot of parentheses in your input entry.

@amosbird
Copy link
Contributor

In what ways are they glitchy?

I tried to make some screencast but it's not enough to capture the issue.... It's a visible text re-rendering when moving cursors right by word. It's interesting that moving left is perfectly fine.

@AmokHuginnsson
Copy link
Owner

Up and Down should work a little bit better on current master.

@AmokHuginnsson
Copy link
Owner

I tried to make some screencast but it's not enough to capture the issue.... It's a visible text re-rendering when moving cursors right by word. It's interesting that moving left is perfectly fine.

By any chance, when you are moving right by word, do you land on an opening bracket/parenthesis, e.g. input:

foo() bar() zoom()

?

@amosbird
Copy link
Contributor

Sorry I missed your last reply. There isn't any opening bracket/parenthesis. I'll try to make clickhouse-client use the upstream version and have it test more widely.

@AmokHuginnsson
Copy link
Owner

Please open a new issue when you find mode information about performance problems you are experiencing.

Thank you.

@amosbird
Copy link
Contributor

@AmokHuginnsson Do you think we should make Ctrl-U delete to the beginning of line instead of buffer? Same for Ctrl-k

@AmokHuginnsson
Copy link
Owner

AmokHuginnsson commented Oct 13, 2021

@amosbird Yes, it would be consistent with how HOME/END keys behave now.
Having some shortcut to delete everything to beginig/end of buffer would be nice.
ALT-u and ALT-U are taken by your previous work on subwords though.
Lets think carefully about what default key bindings should be.

@amosbird
Copy link
Contributor

it would be consistent with how HOME/END keys behave now.

We also need to tune the behavior of Ctrl-a and Ctrl-e to be consistent.

Lets think carefully about what default key bindings should be.

In fish-shell, when at the beginning of a line, pressing Ctrl-U will delete the carriage return and moves up a line. As a result, we can hold the key to kill all previous lines conveniently. Not sure if it's enough)

@AmokHuginnsson
Copy link
Owner

I implemented suggested change on current master.

Ctrl-u kills to beginning of line unless already at the beginning of line, when it kills to beginning of buffer as before.

Ctrl-k has analogous semantics.

Ctrl-a and Ctrl-e also have been updated.

@amosbird
Copy link
Contributor

It's actually quite good (though it's not exactly the same as the suggestion :D )

Btw, what do you think of rendering multiple lines with prompt indentation. In fish shell, we have multiple lines like this:

image

It's a bit unpleasant to see multiple lines unaligned in replxx.

image

@AmokHuginnsson
Copy link
Owner

That sounds interesting, though implementing it correctly sounds cumbersome, considering taking proper care of line wrapping (for overlong lines).
I implemented POC that works for lines that fit the terminal, it does not work for overlong lines though yet.

@amosbird
Copy link
Contributor

Line wrapping is indeed trouble some. Fish-shell doesn't indent the wrapping parts

image

@AmokHuginnsson
Copy link
Owner

AmokHuginnsson commented Oct 16, 2021

I wonder if its better to indent wrapped parts or not from UX point of view...

@AmokHuginnsson
Copy link
Owner

I have implemented first draft of extra indent in miltiline inputs feature.
It is on current master now.

@amosbird
Copy link
Contributor

I wonder if its better to indent wrapped parts or not from UX point of view...

I feel that indenting wrapped parts is not good because user cannot easily tell apart lines.

I have implemented first draft of extra indent in miltiline inputs feature.

I just tried it and it seems not so good. Moving cursors up and down will break the rendering. And I can move the cursor beyond the end of a given line.

@AmokHuginnsson
Copy link
Owner

Can you give me the "input" and set of key strokes where the rendering is broken?

@amosbird
Copy link
Contributor

Here is the input. It's braketed pasted into the buffer. Pressing UP makes prompt go away, and all the lines are re-rendered from the top of the terminal.

This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line!
This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line!
This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line!
This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line!
This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line!
This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line! This is a super long line!

@AmokHuginnsson
Copy link
Owner

Oh, I thought you meant that rendering is broken for lines that fit in the terminal.
I agree what indentation of wrapped parts makes it harder to read and I will change the implementation.

@AmokHuginnsson
Copy link
Owner

Can you check current version?

@amosbird
Copy link
Contributor

Can you check current version?

It's perfect!

@AmokHuginnsson
Copy link
Owner

@amosbird

Heads up!
Previous commit (master) was broken!
I pushed fixed version.
Look into commit message and diff on replxx_impl.cxx in refresh_line() method.

@amosbird
Copy link
Contributor

Ok.. I've pushed the fix to the PR)

@amosbird
Copy link
Contributor

@AmokHuginnsson Hi! I just found that when the multiple line content goes beyond the height of current terminal, going from bottom to top will not render the buffer from beginning but always shows the tail part.

@AmokHuginnsson
Copy link
Owner

AmokHuginnsson commented Nov 13, 2021

This + other reported issue related to very long lines seems difficult to fix properly to me.

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

6 participants