1
0

Kernel-Transcript.st 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. Smalltalk current createPackage: 'Kernel-Transcript'!
  2. Object subclass: #ConsoleTranscript
  3. instanceVariableNames: 'textarea'
  4. package: 'Kernel-Transcript'!
  5. !ConsoleTranscript commentStamp!
  6. I am a specific transcript emitting to the JavaScript console.
  7. If no other transcript is registered, I am the default.!
  8. !ConsoleTranscript methodsFor: 'actions'!
  9. open
  10. ! !
  11. !ConsoleTranscript methodsFor: 'printing'!
  12. clear
  13. "no op"
  14. !
  15. cr
  16. "no op"
  17. !
  18. show: anObject
  19. <console.log(String(string._asString()))>
  20. ! !
  21. !ConsoleTranscript class methodsFor: 'initialization'!
  22. initialize
  23. Transcript register: self new
  24. ! !
  25. Object subclass: #Transcript
  26. instanceVariableNames: ''
  27. package: 'Kernel-Transcript'!
  28. !Transcript commentStamp!
  29. I am a facade for Transcript actions.
  30. I delegate actions to the currently registered transcript.
  31. ## API
  32. Transcript
  33. show: 'hello world';
  34. cr;
  35. show: anObject.!
  36. Transcript class instanceVariableNames: 'current'!
  37. !Transcript class methodsFor: 'instance creation'!
  38. current
  39. ^current
  40. !
  41. new
  42. self shouldNotImplement
  43. !
  44. open
  45. self current open
  46. !
  47. register: aTranscript
  48. current := aTranscript
  49. ! !
  50. !Transcript class methodsFor: 'printing'!
  51. clear
  52. self current clear
  53. !
  54. cr
  55. self current show: String cr
  56. !
  57. inspect: anObject
  58. self show: anObject
  59. !
  60. show: anObject
  61. self current show: anObject
  62. ! !