[Gambas-user] Question on preserving Windows EOL

T Lee Davidson t.lee.davidson at ...626...
Sun May 17 19:21:24 CEST 2015


On 05/17/2015 10:18 AM, Willy at ...3475... wrote:
> Hi All,
>
> I've been struggling with something I would like to implement.
>
> A user asked me if it would be possible to preserve Windows EOL (CRLF)
> for files originating from Windows, but opened and modified in gbEdit
> (Gambas written texteditor).
>
> What happens now is that, if I add a few new lines to a windows
> originated text file, the new lines will be saved with a linux EOL (LF).
> The lines already having the Windows EOL (CRLF) are preserved.
>
> gbEdit makes use of a Editor control. Saving the contents is now done
> with a simple:
>
> File.Save($sPathFileLoaded, editMain.Text)
>
> Where $sPathFileLoaded is the full path and name of the file
> AND
> editMain.Text is the name of the Editor control holding the content.
>
> Upon opening a file gbEdit determines the EOL and returns either:
> CRLF for Windows EOL
> LF for Unix EOL
> CR for Classic Apple Mac EOL
>
> So I have all in place to determine when Windows EOL needs to be used
> upon saving.
>
> What I need is that new lines added, to a file already using Windows
> EOL, have to be saved with Windows EOL as well.
>
> I imagine I could save the file as a stream, making sure the proper EOL
> is added, but was wondering if there might be any easier way in Gambas
> that can do the job (as somehow that often turns out to be the case).
>
> Any suggestions?
>
>

Effect the necessary EOL-type upon data entry by either:

#1) A new property for the Editor control that is set to the EOL-type of the 
text and ensures that RETURN and ENTER effect the appropriate characters, or

#2) Trapping the RETURN and ENTER key events to effect the appropriate characters.

I haven't looked further into either idea. They are just off the top of my head.


Lee
__________

"Artificial Intelligence is no match for natural stupidity."




More information about the User mailing list