rustne-kretser / noline

IO-agnostic line editor for embedded systems
Mozilla Public License 2.0
96 stars 9 forks source link

CarriageReturn or LineFeed #18

Closed m5p3nc3r closed 4 months ago

m5p3nc3r commented 1 year ago

Hi

I am having issues when using base64 to stream data through noline. If I use a command under a unix like system (macos)

base64 -b64 -i <file>

the line endings are LF not CR, so I don't get any lines read from the input stream with noline.

I must admit I'm no expert in the dark arts of line endings, and the differences between OS's views of the LF/CRLF, but if I change the core::Line::advance to:

-CarriageReturn => {
+CarriageReturn | LineFeed => {
    if self.buffer.len() > 0 {
        let _ = self.nav.history.add_entry(self.buffer.as_str());
    }

    self.generate_output(Done)
}

I am able to process normal input from stdin, but also piped input from a unix command.

Is this a sensible change, or am I mis-understanding the problem>

eivindbergem commented 1 year ago

Pressing Enter inputs a CR in the terminal, so it's not really a newline in this context. I never tested with pasting lines in, so I didn't encounter this problem. Accepting LF in this case seems reasonable to me. Create a PR, and I'll merge it in.

m5p3nc3r commented 1 year ago

I have create #19 to implement this.