editor.mod 724 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. MODULE editor2;
  2. (* based on the kilo editor building course*)
  3. (* Step 5 *)
  4. (* using different libreries for the same purpose, some lowlevel, some higher level *)
  5. (* IO mode *)
  6. IMPORT IO, termios, FIO;
  7. VAR
  8. c : CHAR;
  9. theTermios : termios.TERMIOS;
  10. PROCEDURE enablerawMode;
  11. BEGIN
  12. theTermios := termios.InitTermios();
  13. IF termios.tcgetattr(FIO.StdIn, theTermios) = -1 THEN
  14. HALT
  15. END;
  16. IO.UnBufferedMode(0,TRUE);
  17. IO.UnBufferedMode(1,TRUE);
  18. END enablerawMode;
  19. BEGIN
  20. enablerawMode;
  21. LOOP
  22. IO.Read(c);
  23. IF c = "q" THEN
  24. EXIT
  25. END;
  26. END;
  27. theTermios := termios.KillTermios(theTermios);
  28. END editor2.