Mirror of CollapseOS
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

17 行
622B

  1. : (rdlnc) ( -- c )
  2. ( buffer overflow? same as if we typed a newline )
  3. IN> @ IN) = IF 0x0a ELSE KEY THEN ( c )
  4. DUP 0x7f = IF DROP 0x8 THEN ( del? same as backspace )
  5. DUP 0x0a = IF DROP 0xd THEN ( lf? same as cr )
  6. ( bacspace? handle and exit )
  7. DUP 0x8 = IF (inbs) EXIT THEN
  8. ( echo back )
  9. DUP EMIT ( c )
  10. ( write and advance )
  11. DUP ( keep as result ) ( c c )
  12. ( We take advantage of the fact that c's MSB is always zero and
  13. thus ! automatically null-terminates our string )
  14. IN> @ ! 1 IN> +! ( c )
  15. ( if newline, replace with zero to indicate EOL )
  16. DUP 0xd = IF DROP 0 THEN ;