-
-
Notifications
You must be signed in to change notification settings - Fork 609
Add new line support for multi-line input box #509
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
Conversation
Can you make this showup in the commands section aswell then? |
Done, I'm unsure the alt symbol is that clear, but should be fixable with #516 |
I just checked and it unfortunately does not work with this key binding on a Mac. it just commits, no line break. I'd like to find a binding that works on all platforms out of the box |
modifier keys+enter will not work reliably anyway (I think its a known limitation in crossterm) |
81a8849
to
f84f6f4
Compare
What about |
Thats a good idea! |
|
@WizardOhio24 see #645 after playing around with this PR I realize we cannot merge this without also adding scrolling to the |
fix command stack add to changelog
Yeah, I mean, this was more for writing a commit message in a single line (i.e 50 chars) then adding a new line and putting some other detail (such as issues it was linked to). If the user wanted to put in a lot of text it would be better to use nano or vim (or micro), this is more intended for small commits where 2-3 lines are needed (I think, though could be expanded to have a scrollbar). |
@WizardOhio24 thanks for updating this branch. still we can do better and add the scrollbar code we use all over the place already here aswell. this makes the cursor stay in view even when adding newlines. |
This now grows the commit box as new lines are added up to a limit, at which it stops growing and starts using a scrollbar, which seems better when typing out multiline commits. |
typed around a bit:
also the scrollbar is also not keeping the cursor in view. |
&& self.scroll_max >= 3 | ||
{ | ||
self.scroll_top = self.scroll_top.saturating_sub(1); | ||
//self.cur_line = self.cur_line.saturating_sub(1); |
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.
remove commented code please
let mut nearest_newline: usize = 0; | ||
let mut prev_line_newline_loc = 0; | ||
for (i, c) in self.msg.chars().enumerate() { | ||
if c == '\n' { |
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.
how does this behave on windows where a newline is two chars wide?
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.
A newline can be 2 chars? It's just '\n', right?
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.
No, google ‚windows line endings‘
src/components/textinput.rs
Outdated
break; | ||
} | ||
} | ||
// if !self.msg.is_char_boundary(i) { |
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.
commented code
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.
I was trying to get the scrolling working with characters which occupy more than 1 byte, such as ö or é. This code should have worked, but it doesn't, nothing seems to.
Size::new(10, 3), | ||
Size::new( | ||
10, | ||
min( |
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.
there is clamp
for this
"New Line [{}]", | ||
key_config.get_hint(key_config.enter), | ||
), | ||
"make a new line in the commit message", |
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.
insert newline
closing in favour of #1309 |
Adds multi-line support for multi-line input boxes, in particular the commit message box:

This is done with ALT+Enter, because SHIFT+Enter does not work in terminals and so does not work in crossterm.
The support is simple because it can sometimes be useful to add an extra line quickly and would be useful (and easier) to do in GitUI, but GitUI is not a text editor and so for large multi-line commit messages, a proper text editor should be used.