Skip to content

Add new line support for multi-line input box (follow up PR) #1309

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

Closed
wants to merge 29 commits into from

Conversation

guzzit
Copy link
Contributor

@guzzit guzzit commented Sep 1, 2022

This Pull Request completes #509.

I followed the checklist:

  • I added unittests
  • I ran make check without errors (I will when I rebase with master)
  • I tested the overall application
  • I added an appropriate item to the changelog

@extrawurst
Copy link
Collaborator

@guzzit thanks for your interest in picking this up. will you bring it up to date with master please?

@guzzit
Copy link
Contributor Author

guzzit commented Sep 4, 2022

Done @extrawurst

if i >= self.cursor_position {
if i == self.cursor_position {
//for when cursor position is on a new line just before text
if c == '\n' {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like in the previous PR I am not sure this will work on windows where line breaks are two bytes AFAIK?

@@ -19,6 +19,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixes
* remove insecure dependency `ansi_term` ([#1290](https://github.com/extrawurst/gitui/issues/1290))

### Changed
* `enter` adds *newline* to commit msg (*commit* via `ctrl+o` now) [[@WizardOhio24](https://github.com/WizardOhio24)] ([#509](https://github.com/extrawurst/gitui/issues/509))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not forget to add yourself here

@@ -43,6 +44,10 @@ pub struct TextInputComponent {
input_type: InputType,
current_area: Cell<Rect>,
embed: bool,
scroll_top: usize, // The current scroll from the top
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be simplified, using VerticalScroll. please see usage of VerticalScroll in other places

top_line_start = middle_line_start;
top_line_end = middle_line_end;
middle_line_start = bottom_line_start;
middle_line_end = i.saturating_sub(1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not look like it will work on multibyte chars. we need to unittest this function


/// Move the cursor down a line.
/// Only for multi-line textinputs
fn line_down_cursor(&mut self) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lots of code duplication with the above function. can this be combined?

@@ -130,9 +322,27 @@ impl TextInputComponent {
Some(index)
}

/// Backspace for multiline textinputs
fn multiline_backspace(&mut self) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this guy needs unittesting aswell

self.get_msg(0..self.cursor_position);
let text_before_cursor: String = self
.get_msg(0..self.cursor_position)
.split('\n')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again not sure this will work on all platforms where lineendings might be two bytes

Copy link
Collaborator

@extrawurst extrawurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a bunch more review comments

@extrawurst
Copy link
Collaborator

putting in draft until the required changes are made

@extrawurst extrawurst marked this pull request as draft September 18, 2022 13:04
@al3xandru
Copy link

Was this idea abandoned? Tracking this feature request across different tickets leads to this final leaf which seems to be dormant at this time.

@guzzit
Copy link
Contributor Author

guzzit commented Jan 5, 2023

Hi @al3xandru, I'm not working on it at the moment. Please feel free to pick up the issue if you're interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants