Add new line support for multi-line input box
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.
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)
What about Enter inserts a newline and ^c (ctrl c or alt c) commits (just like ^a) amends?
What about
Enterinserts a newline and^c(ctrl c or alt c) commits (just like^a) amends?
Thats a good idea!
^c is to exit GitUI, so I'd be worried the user could try to exit and instead commit whatever was in the textbox so right now I've changed it to alt+c, but that seems awkward. With nano it would be ^x, would that be better? (The user can always change it to what they want in the config) Happy to go with whatever people want.
Option+c does not work either on a Mac..

at this point only something Ctrl + ... seems to be a workable option. lets start with Ctrl + m and gather some feedback (x with Ctrl breaks my wrist ^^)
edit: damn ctrl + m is a carriage return and cannot be differentiated in crossterm, so I settled on ctrl + o for now
@WizardOhio24 see https://github.com/extrawurst/gitui/pull/645
after playing around with this PR I realize we cannot merge this without also adding scrolling to the TextInputComponent otherwise after adding a couple of newlines the user cannot see the cursor anymore
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 is emitting a warning in clippy about intersperse (on iterators), this is fine, both functions will do the same thing. All this is saying is that in the future, intersperse will be included in Rust and so will not use the itertools version. It will go away when intersperse is in stable Rust.
This is emitting a warning in clippy about
intersperse(on iterators), this is fine, both functions will do the same thing. All this is saying is that in the future, intersperse will be included in Rust and so will not use the itertools version. It will go away when intersperse is in stable Rust.
please look for get_text_info in details.rs on how to explicitly allow this. we wanna be warning free (this turned to be an error now on master)
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:
07:17:06 [ERROR] panic: PanicInfo { payload: Any, message: Some(attempt to subtract with overflow), location: Location { file: "src/c
omponents/textinput.rs", line: 148, col: 13 } }
trace:
[...]
11: gitui::components::textinput::TextInputComponent::decr_cursor_multiline
at src/components/textinput.rs:148:13
12: gitui::components::textinput::TextInputComponent::decr_cursor
at src/components/textinput.rs:163:13
13: gitui::components::textinput::TextInputComponent::backspace
at src/components/textinput.rs:286:13
also up/down behaves weird when having empty lines in between:

the scrollbar is also not keeping the cursor in view. instead of adding new features like auto growing lets focus on getting one thing working first please.
closing in favour of #1309