Eol Mode

  • Franz Steinhaeusler

    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.

    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"


    • Daniel Pozmanter

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


Log in to post a comment.