/src/wrappers/readline/examples/read_line_test.e

http://github.com/tybor/Liberty · Specman e · 46 lines · 40 code · 6 blank · 0 comment · 4 complexity · 0274fbc2f98514625fdb4cab1b7b593e MD5 · raw file

  1. class READ_LINE_TEST
  2. inherit
  3. ANY
  4. insert
  5. READ_LINE
  6. create {ANY}
  7. make
  8. feature {ANY}
  9. make
  10. do
  11. prompt := "Liberty> "
  12. from
  13. read_line
  14. until
  15. last_line = Void or else last_line.is_empty -- handles Ctrl-D to exit
  16. loop
  17. if last_line /= Void then
  18. if last_line.count > 3 then
  19. print("Adding `")
  20. print(last_line)
  21. print("' to history.%N")
  22. history.add(last_line)
  23. else
  24. print("Got `")
  25. print(last_line)
  26. print("'.%N")
  27. end
  28. end
  29. read_line
  30. end
  31. print("History entries:")
  32. history.for_each(agent print_entry(?))
  33. end
  34. print_entry (x: HISTORY_ENTRY)
  35. do
  36. if x /= Void then
  37. print("'" + x.line + "'%N")
  38. end
  39. end
  40. end -- class READ_LINE_TEST