test2.mod 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. MODULE test2;
  2. (* based on the kilo editor building course*)
  3. (* Step 6 *)
  4. IMPORT FIO, SYSTEM, termios, libc, STextIO, NumberIO;
  5. VAR
  6. c : CHAR;
  7. p : POINTER TO CHAR;
  8. thetermios : termios.TERMIOS;
  9. theoldtermios : termios.TERMIOS;
  10. result : INTEGER;
  11. TCSAFLUSH : INTEGER;
  12. bresult : BOOLEAN;
  13. BEGIN
  14. thetermios := termios.InitTermios();
  15. theoldtermios := termios.InitTermios();
  16. TCSAFLUSH := termios.tcsflush ();
  17. result := termios.tcgetattr(FIO.StdIn, thetermios);
  18. STextIO.WriteString (" call 1 to tcgetattr ");
  19. NumberIO.WriteCard(result, 5);
  20. STextIO.WriteLn;
  21. result := termios.tcgetattr(FIO.StdIn, theoldtermios);
  22. STextIO.WriteString (" call 2 to tcgetattr ");
  23. NumberIO.WriteCard(result, 5);
  24. STextIO.WriteLn;
  25. bresult := termios.SetFlag(thetermios,termios.lecho, TRUE);
  26. STextIO.WriteString ("call to SetFlag");
  27. STextIO.WriteLn;
  28. IF bresult = TRUE THEN
  29. STextIO.WriteString("true");
  30. STextIO.WriteLn;
  31. ELSE
  32. STextIO.WriteString("false");
  33. STextIO.WriteLn
  34. END;
  35. result := termios.tcsetattr(FIO.StdIn, TCSAFLUSH, theoldtermios);
  36. STextIO.WriteString (" call to tcsetattr ");
  37. NumberIO.WriteCard(result, 5);
  38. STextIO.WriteLn;
  39. END test2.