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

Wrap long lines in editor #1447

Open
mc-butler opened this issue Aug 3, 2009 · 19 comments
Open

Wrap long lines in editor #1447

mc-butler opened this issue Aug 3, 2009 · 19 comments
Labels
area: mcedit mcedit, the built-in text editor prio: low Minor problem or easily worked around ver: 4.7.0-pre1 Reproducible in version 4.7.0-pre1

Comments

@mc-butler
Copy link

Important

This issue was migrated from Trac:

Origin https://midnight-commander.org/ticket/1447
Reporter ache (acheron@….ru)
Mentions mooffie@….com (@mooffie), ales.janda@….cz (@kybl)

It would be convenient if editor gets the ability to wrap lines when line length exceeds screen width.

Note

Original attachments:

@mc-butler
Copy link
Author

Changed by slavazanko (@slavaz) on Aug 3, 2009 at 10:05 UTC (comment 1)

Is you mean behaviour like VI(M)?

@mc-butler
Copy link
Author

Changed by ache (acheron@….ru) on Aug 3, 2009 at 15:28 UTC (comment 2)

Yes, similar to VIM with wrap=on.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Oct 29, 2011 at 16:56 UTC (comment 3)

  • Branch state set to no branch
  • Milestone changed from 4.7 to Future Releases

@mc-butler
Copy link
Author

Changed by mooffie (@mooffie) on Apr 6, 2015 at 5:36 UTC (comment 4)

  • Cc set to mooffie@….com

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Mar 8, 2022 at 9:29 UTC (comment 5)

Ticket #4336 has been marked as a duplicate of this ticket.

@mc-butler
Copy link
Author

Changed by kybl (@kybl) on Mar 15, 2022 at 15:48 UTC (comment 6)

  • Cc changed from mooffie@….com to mooffie@….com, ales.janda@….cz

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Aug 17, 2023 at 13:43 UTC (comment 7)

Ticket #4492 has been marked as a duplicate of this ticket.

@mc-butler
Copy link
Author

Changed by psprint (sg44567@….com) on Aug 17, 2023 at 14:22 UTC

Add soft wraps to MCEdit

@mc-butler
Copy link
Author

Changed by psprint (sg44567@….com) on Aug 17, 2023 at 14:30 UTC (comment 8)

Hi,
I've implemented screen-only division of long lines. I'll call it soft wraps.

I think that this feature is missing from mcedit. Currently, when a line exceeds the screen it is scrolled right. This is, IMHO, a less effective way of working with long lines. More natural is to have them soft-divided by the editor with moving, home/end keys support, etc.

The patch is little long and complex, but I'm using it from 2 years with no problems. To have the lines soft wrapped, select "Soft wraps" in the General options dialog.


Answering the comment in the previous (closed as duplicate) ticket: there are markings of the wrapped lines – if one enables line numbers: https://asciinema.org/a/KVP6dRocGtb2XGLO26sjL60sZ. Also I disagree that code shouldn't be folded at least to me, as I'm using the patch from 2 years to edit code. After turning the option on I've never looked back.

@mc-butler
Copy link
Author

Changed by psprint (sg44567@….com) on Aug 17, 2023 at 14:39 UTC

An update that restores the missing CK action allowing keybind toggling soft wraps (alt-w by default)

@mc-butler
Copy link
Author

Changed by psprint (sg44567@….com) on Aug 17, 2023 at 14:43 UTC (comment 9)

I've restored the keybinding SoftFolds that got lost in the merge (Alt-w by default). Demo: https://asciinema.org/a/o3N8nrNdt3Q1dBjHGt0yP6uP8

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Aug 17, 2023 at 17:44 UTC (comment 10)

https://midnight-commander.org/wiki/Hacking

@mc-butler
Copy link
Author

Changed by psprint (sg44567@….com) on Aug 18, 2023 at 14:34 UTC

Reformatted the patch to meet Hacking document. Other things like comparing NULL for pointers instead of if(ptr) already meet

@mc-butler
Copy link
Author

Changed by psprint (sg44567@….com) on Aug 18, 2023 at 14:35 UTC (comment 11)

Andrew: I've submitted updated patch

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Aug 18, 2023 at 15:31 UTC (comment 12)

https://midnight-commander.org/wiki/Hacking

@mc-butler
Copy link
Author

Changed by psprint (sg44567@….com) on Aug 19, 2023 at 9:33 UTC (comment 12.13)

Replying to andrew_b:

https://midnight-commander.org/wiki/Hacking

I've uploaded updated patch. I've removed int q=Q() from it. Are there any other things that are unaligned? I would ask for a direct references or at least names of the formatting/code errors.

@mc-butler
Copy link
Author

Changed by psprint (sg44567@….com) on Aug 19, 2023 at 9:34 UTC

An update that removes the inline declaration assignments like: int q=Q()

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Aug 19, 2023 at 13:59 UTC (comment 13.14)

Replying to psprint:

I've uploaded updated patch. I've removed int q=Q() from it. Are there any other things that are unaligned?

Is it all that you read in HACKING?

I would ask for a direct references or at least names of the formatting/code errors.

  • Follow source templates
  • Do not unnecessarily use braces where a single statement will do.
  • Use your best judgement and choose the more readable option.
            for (;
                 (edit_buffer_get_byte_ex (buf, current_eol) != '\n') &&
                 current_eol <= buf->size &&
                 (current_eol == current_save
                  ||
                  ((q =
                    edit_move_forward3 (buf->edit_widget, current_bol, 0, current_eol, FALSE,
                                        0) % buf->end_col) != 0));
                 current_eol =
                 edit_move_forward3 (buf->edit_widget, current_eol, 1, 0, FALSE, 0), current_eol +=
                 prev_eol == current_eol ? 1 : 0, prev_eol = current_eol)
                ;
    

Save my eyes and my brain.

  • Avoid initialized and not initialized variables in one declaration.
  • Reduce variable scope as much as possible: declare local variable in that block where it is used.
  • Split variable declaration and code using one empty line.
  • Do not use gboolean as integer and integer as gboolean.

And this is only the first step.

@mc-butler
Copy link
Author

Changed by psprint (sg44567@….com) on Aug 20, 2023 at 10:53 UTC (comment 15)

Sorry, but I have to stop supporting this patch. Someone paid me for the soft wraps implementation, but now the financing stopped and I'm unable to meet your high level expectations.

@mc-butler mc-butler marked this as a duplicate of #4336 Feb 28, 2025
@mc-butler mc-butler marked this as a duplicate of #4492 Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: mcedit mcedit, the built-in text editor prio: low Minor problem or easily worked around ver: 4.7.0-pre1 Reproducible in version 4.7.0-pre1
Development

No branches or pull requests

1 participant