Ticket #1447 (new enhancement)

Opened 15 years ago

Last modified 11 months ago

Wrap long lines in editor

Reported by: ache Owned by:
Priority: minor Milestone: Future Releases
Component: mcedit Version: 4.7.0-pre1
Keywords: Cc: mooffie@…, ales.janda@…
Blocked By: Blocking:
Branch state: no branch Votes for changeset:

Description

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

Attachments

0001-Implementation-of-soft-wraps-screen-only-division-of.patch (112.2 KB) - added by psprint 11 months ago.
Add soft wraps to MCEdit
0001-Implementation-of-soft-wraps-screen-only-division-of.2.patch (113.1 KB) - added by psprint 11 months ago.
An update that restores the missing CK action allowing keybind toggling soft wraps (alt-w by default)
0001-Implementation-of-soft-wraps-screen-only-division-of.3.patch (114.8 KB) - added by psprint 11 months ago.
Reformatted the patch to meet Hacking document. Other things like comparing NULL for pointers instead of if(ptr) already meet
0001-Implementation-of-soft-wraps-screen-only-division-of.4.patch (115.2 KB) - added by psprint 11 months ago.
An update that removes the inline declaration assignments like: int q=Q()

Change History

comment:1 Changed 15 years ago by slavazanko

Is you mean behaviour like VI(M)?

comment:2 Changed 15 years ago by ache

Yes, similar to VIM with wrap=on.

comment:3 Changed 13 years ago by andrew_b

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

comment:4 Changed 9 years ago by mooffie

  • Cc mooffie@… added

comment:5 Changed 2 years ago by andrew_b

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

comment:6 Changed 2 years ago by kybl

  • Cc ales.janda@… added

comment:7 Changed 11 months ago by andrew_b

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

Changed 11 months ago by psprint

Add soft wraps to MCEdit

comment:8 Changed 11 months ago by psprint

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.

Changed 11 months ago by psprint

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

comment:9 Changed 11 months ago by psprint

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

Last edited 11 months ago by psprint (previous) (diff)

Changed 11 months ago by psprint

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

comment:11 Changed 11 months ago by psprint

Andrew: I've submitted updated patch

comment:13 in reply to: ↑ 12 ; follow-up: ↓ 14 Changed 11 months ago by psprint

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.

Changed 11 months ago by psprint

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

comment:14 in reply to: ↑ 13 Changed 11 months ago by andrew_b

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.

Last edited 11 months ago by andrew_b (previous) (diff)

comment:15 Changed 11 months ago by psprint

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.

Note: See TracTickets for help on using tickets.