LineBreak and FileFormat properties of TSynEditStringList #48
Closed
pyscripter
started this conversation in
Ideas
Replies: 2 comments 4 replies
-
You don't need to drop it. Enough is that FileFormat will read and set
SLineBreak. It will keep compatibility and you will use current
implementation
Jan Fiala
Dne pá 9. 12. 2022 1:04 uživatel pyscripter ***@***.***>
napsal:
… There are currently two properties of TSynEditStringList that relate to
the line endings of saved files:
- FileFormat: TSynEditFileFormat = (sffDos, sffUnix, sffMac,
sffUnicode)
- LineBreak inherited from TStrings (introduced in Delphi Berlin 10.1)
The base class TStrings uses LineBreak only when:
- saving files (GetTextStr)
- reading files (SetTextStr)
- Text property getter
Currently TSynEditStringList uses instead FileFormat without setting
LineBreak:
- SetTextStr is overwritten and detects line endings in the provided
text, setting FIleFormat appropriately
- GetTextStr is inherited and uses LineBreak except when saving in
which case the FileFormat is taken into account
- In all other cases SynEdit uses SLineBreak (SelText, SelLength). In
a few places it is assumed that SLineBreak = #13
<#13>#10 (e.g.
CharIndexToRowCol, RowColToCharIndex).
It is confusing to have two properties that relate to Line Endings. Also,
I think it is more consistent for TSynEditStringList to inherit behavior
from TStrings.
Since LineBreak has been availalbe since Delphi Berlin, ant this repo is
not compatible with version before that, I propose that we drop FileFormat
and use instead LineBreak:
- LineBreak is set when reading files or setting the Text property
(SetTextStr). TStrings does not do that.
- LineBreak is used reading the Text property. This is inherited
behavior. However and since LineBreak is currently not changed, this is a
breaking change. Currently Text always contains SLineBreaks.
- In all cases SynEdit uses SLineBreak.
@MShark67 ***@***.***
***@***.*** <https://github.com/JaFi-cz>
What do you think?
—
Reply to this email directly, view it on GitHub
<#48>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AT5VHKUJG3JOJRJS6UDO2GDWMJZQRANCNFSM6AAAAAASYXFOPI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
4 replies
-
Fixed as @JaFi-cz suggested. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There are currently two properties of TSynEditStringList that relate to the line endings of saved files:
The base class TStrings uses LineBreak only in:
Currently TSynEditStringList uses instead FileFormat without setting LineBreak:
#13#10
(e.g. CharIndexToRowCol, RowColToCharIndex).It is confusing to have two properties that relate to Line Endings. Also, I think it is more consistent for TSynEditStringList to inherit behavior from TStrings.
Since LineBreak has been availalbe since Delphi Berlin, and this repo is not compatible with versions before that, I propose that we drop FileFormat and use instead LineBreak:
An advantage is that users can programmatically set LineBreak without casting to TSynEditStringList.
I want to add that an analogous change was made earlier, so that TSynEditStringList now uses the Encoding inherited property instead of a custom property in SynUnicode.pas. Since Encoding is a read-only property of TStrings (no idea why!), a SetEncoding method was added to TSynEditStringList.
The properties that affect how a file is saved are: Encoding, WriteBOM, LineBreak and TrailingLineBreak. Encoding, WriteBOM and LineBreak are detected when reading a file. This is so that reading and later saving a file, preserves the original format. With TrailingLineBreak set to False, reading and then writing to any file will keep the file identical to its original.
@MShark67,@vincentparrett,@JaFi-cz What do you think?
Beta Was this translation helpful? Give feedback.
All reactions