kopia lustrzana https://github.com/micropython/micropython-lib
Merge 5ab36aed4a
into 6e24cffe95
commit
3833980b7f
|
@ -119,16 +119,22 @@ async def task(g=None, prompt="--> "):
|
||||||
pt = t # save previous time
|
pt = t # save previous time
|
||||||
t = time.ticks_ms()
|
t = time.ticks_ms()
|
||||||
if c < 0x20 or c > 0x7E:
|
if c < 0x20 or c > 0x7E:
|
||||||
if c == 0x0A:
|
if c == 0x0A or c == 0x0D:
|
||||||
# LF
|
# LF or CR (handle both for raw terminal mode compatibility)
|
||||||
if paste:
|
if paste:
|
||||||
|
# In paste mode, preserve the actual character
|
||||||
sys.stdout.write(b)
|
sys.stdout.write(b)
|
||||||
cmd += b
|
cmd += b
|
||||||
continue
|
continue
|
||||||
# If the previous character was also LF, and was less
|
# Handle various newline sequences to avoid double-execution:
|
||||||
# than 20 ms ago, this was likely due to CRLF->LFLF
|
# - CR+LF (Windows style): ignore LF if it follows CR quickly
|
||||||
# conversion, so ignore this linefeed.
|
# - LF+LF (PTY double-newline): ignore second LF if it follows quickly
|
||||||
if pc == 0x0A and time.ticks_diff(t, pt) < 20:
|
# - CR+CR (potential double-CR): ignore second CR if it follows quickly
|
||||||
|
if (
|
||||||
|
(c == 0x0A and pc == 0x0D) # LF after CR (CRLF)
|
||||||
|
or (c == 0x0A and pc == 0x0A) # LF after LF (double LF)
|
||||||
|
or (c == 0x0D and pc == 0x0D)
|
||||||
|
) and time.ticks_diff(t, pt) < 20: # CR after CR
|
||||||
continue
|
continue
|
||||||
if curs:
|
if curs:
|
||||||
# move cursor to end of the line
|
# move cursor to end of the line
|
||||||
|
|
Ładowanie…
Reference in New Issue