[Geany-devel] Line operations

Eugene Arshinov earshinov at xxxxx
Mon Feb 6 07:55:25 UTC 2012


On Sun, 05 Feb 2012 20:50:38 +0100
Colomban Wendling <lists.ban at herbesfolles.org> wrote:

> Le 05/02/2012 13:51, Eugene Arshinov a écrit :
> > Hello all.
> 
> Hey Eugene,
> 
> > I have several suggestions and questions about certain line
> > operations implemented in Geany.
> > 
> > 1) Recently I found that "move lines up/down" command does not work
> > properly for the last line not ending with a newline.  You can
> > easily check it yourself.  Couple of minutes ago I made a pull
> > request [1] with an implementation of `editor.c:move_lines()` which
> > handles the problem.  Dear unknown someone, please review and pull
> > if it's okay.
> 
> I know this problem, but it needed a so big code refactoring it hurts
> (I want as a proof the fact your rewrite is... huge), so... I just
> postponed it.  Ok, shame on me.

No problem.  As the changes I made are (almost?) a complete rewrite, I
would suggest viewing the differences side by side instead of `diff`
format.  That will be easier.  Though, the resulting function indeed
became longer than the previous version...

> 
> I haven't reviewed the new code yet, but I'll do.  Just as a note,
> Scintilla has a command to do that that suffers (suffered?) of the
> exact same bug we had.  Maybe it'd be good to fix their copy and use
> the SCI message in place of our code.
> 

Uhh, I didn't know that…  I'll take a look later.

> 
> > [1]: <https://github.com/geany/geany/pull/21>
> > 
> > 2) I want to raise a question, do we need a "join lines" command?
> > This command would be a companion of the existing "reflow paragraph"
> > command, but in contrast with the latter, it would only join lines,
> > but not split them.
> > 
> > This command may be useful when, let's say, you have a document
> > created by someone else who sticks with line breaking and inserts
> > \n at column 80.  Suppose that you prefer using line wrapping
> > instead and want to remove those \n in a peace of a document which
> > you're editing.  The new command would help you a bit.
> > 
> > Implementation of the new "join lines" command could use the bits of
> > code already written for "reflow paragraph" (though, those bits
> > need to be extracted/refactored first).  Moreover, I already
> > implemented it and, if the new command seems useful to anyone, I
> > can put my implementation in a pull request.
> 
> Not sure I see a use case for this (read: I probably wouldn't use it
> if it simply removes the EOLs), but why not if some wants it.  But
> maybe Scintilla already have a message for it and thus we'd only need
> to use it?
> 

As Lex already wrote, there is SCI_LINESJOIN.  And that's the command
which is already used in Geany to implement "reflow paragraph" (to be
more precise, two commands are used: LINESJOIN and LINESSPLIT).

By the way, here is a related discussion: "[Geany-devel] Support
SCI_LINESJOIN and SCI_LINESSPLIT (patch included)" [1].  The first
message is authored by me :)

[1]: http://lists.uvena.de/geany-devel/2009-July/000834.html

--
Best regards,
Eugene.



More information about the Devel mailing list