Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

SyntaxEdit and line breaks

I've had this code for a long time.... but a user just reported that it isn't working.

Did something change? Is it a bug? Am I doing something wrong?

For example, I set this:
Doc->Lines->LineBreak=L"\n"

Then save the document:
Doc->SaveToFile(<filename>,0,false);

It uses CR+LF instead (when I view the file with a hex editor). And if I set this:
Doc->Lines->LineBreak=L"\r"

It still uses CR+LF.

Comments

  • 6 Comments sorted by Votes Date Added
  • TLMDSyntaxEdit does not rely on VCL's TStrings.LineBreak property. Instead TLMDEditDocument.LineSeparator property can be used.
  • edited June 2019 Posts: 192Vote Up0Vote Down
    Thank you... but it still always saves with CR+LF even when I do this:

    Doc->LineSeparator=lsLF;

    Am I missing something or is this a bug?
  • LineSeparator is used while editing text - formally when inserting new text line. Text is not preprocessed as a whole before saving.
  • Thank you. That would be good information to put into the documentation.

    The documentation says the default is lsCRLF.

    What if the program is running on Linux using Wine and the user opens a file that uses LF for line separators. The user then edits the file causing new lines to be inserted/added. Is LMDEdit smart enough to change the line separator to lsLF if the user opens a file that uses lsLF for line separators? Otherwise it would seem that there would be a mix of CR+LF and LF line separators which is probably not a good idea.
  • Such an auto-detection is not a part of syntax edit. You can only specify LineSeparator explicitly.
  • OK, thanks.... if you ever start developing SyntaxEdit again (I am still hoping you will) then it would make sense to auto-detect the line separators when opening a file and to use the same for new lines.

    For now I just removed this option from my software because it obviously wasn't working the way I thought it was/would.
Sign In or Register to comment.