GNU nano - Patches: patch #10263, Add line folding support
You are not allowed to post comments on this tracker with your current authentication level.
patch #10263: Add line folding support
Submitter: | Sam <rexy712> | ||
Submitted: | Mon 04 Jul 2022 10:46:55 PM UTC | ||
Priority: | 3 - Low | Status: | None |
Privacy: | Public | Assigned to: | None |
Open/Closed: | Open | Release: | None |
( Jump to the original submission )
Mon 11 Jul 2022 03:16:45 PM UTC, comment #6: |
Benno Schulenberg <bens>![]() |
Mon 11 Jul 2022 01:00:07 AM UTC, comment #5: I appreciate you taking the time to go over the patch. I can see a lot of cruft and old bits that I forgot to clean up as I worked on it now that you've pointed some out. And some other cruft that I didn't even think of as such until having someone else mention it.
|
Sam <rexy712> |
Sun 10 Jul 2022 07:35:27 AM UTC, comment #4:
Coloring things is not an essential part of folding. It can be added later. Now it just clutters the patch.
Don't use a variable that isn't needed to make things work. It's just clutter.
Is there any situation where one doesn't need to do a refresh when one folds or unfolds? I can't think of any. So setting 'refresh_needed' should just be part of the folding and unfolding routines. Then the above can be just two lines instead of four. Yes: nano's style is not to use braces for a single statement.
Again: do not add braces where they are not needed. And certainly don't add braces where they weren't before.
^E is already taken. You have to pick a keystroke that is not ued yet. I would suggest M-[, which even looks a bit mnemonic.
The comment does not match the code any more.
Ouch. Why not just use 'line'?
Poor function name. I read 'fold' as a verb here.
Ugh. This could simply be:
|
Benno Schulenberg <bens>![]() |
Tue 05 Jul 2022 07:09:27 PM UTC, comment #3: I'm attaching an updated patch with the folded_segment struct removed, the pointer ('fold') in linestruct changed to a bool ('folded'), and the function names made less awkward and confusing. |
Sam <rexy712> |
Tue 05 Jul 2022 04:34:50 PM UTC, comment #2: I know it's a huge patch, I was trying to keep it small but I kept having issues where different functionality wouldn't handle the cursor placement or unfolding when necessary. I apologize for that.
|
Sam <rexy712> |
Tue 05 Jul 2022 10:53:38 AM UTC, comment #1: After staring at the huge patch for a while, two things.
|
Benno Schulenberg <bens>![]() |
Mon 04 Jul 2022 10:46:55 PM UTC, original submission:
Folding lines is the ability to hide or collapse a section of a file when you don't need to see it. All IDEs I've used have had this feature and it's the one thing I feel GNU nano has been missing when working from the terminal. It helps to keep the screen less cluttered when trying to focus.
|
Sam <rexy712> |
Depends on the following items: None found
Items that depend on this one: None found
There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.
What I would try when trying to implement default folding is: search backward for a blank line (or folded line), then from there search forward for the first opening brace at end of line. When found, then find the matching closing brace, and fold from the blank or folded line to the closing brace. When a blank line is encountered before an opening brace is found, just fold from the first blank or folded line to the found blank line. (Of course, this kind of folding works only for C-like programs and for plain text where paragraphs are separated by blank lines, but... it's a start.)