Why doesn't \r\n / CRLF result in the line being reread in perpetuity?

22 Views Asked by At

If CR (\r) moves the cursor to the front of the line, and LF (\n) moves the cursor to the next line, why is LF consumed, rather than the line being re-read?

e.g.: hello world\r\n

  • Read hello world, cursor is at d

  • \r is seen, move to front of line(?)

  • We don't reread hello world, but the cursor is now looking at... h? (I would think that \r would now result in us re-reading hello world.

  • \n is seen, move to next line

To me, this functionality implies that the cursor is not necessarily related to the consumption of the file/text/buffer, but how this all cooperates is not immediately apparent to me, either.

What gives?

0

There are 0 best solutions below