Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Eol Mode

Developers
2004-12-12
2013-04-26
  • I think, the recognition of end of line characters is
    not accurate.

    In the RemoveTrailingSpaces, i used:

    relewin = re.compile('\r\n', re.M)
    releunix = re.compile('[^\r]\n', re.M)
    relemac = re.compile('\r[^\n]', re.M)

    text = DrDocument.GetText()

    #check line endings
    win = unix = mac = 0
    if relewin.search(text):
        win = 1
    if releunix.search(text):
        unix = 1
    if relemac.search(text):
        mac = 1
    mixed = win + unix + mac

    #correct the lineendings before
    if mixed > 1:
        wx.MessageDialog(DrFrame, "Line endings mixed", "Remove trailing Whitespace", wx.ICON_EXCLAMATION).ShowModal()

    Now: if one line ending is crlf, then WIN is display in the status bar.

    Also:
    Wouldn't it be better, if one opens a file,
    the first eol char is used to display the mode,
    and the eol mode should be set to this mode (?)
    if the line endings are mixed, then in the statusbar,
    there could be: "UNIX mixed"

    Franz

     
    • Thanks, this is in 3.7.6 (not the trailing whitespace bit)