2
0

Kernel-Transcript.st 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. "Smalltalk objects should have no trouble displaying themselves on the Transcript; Javascript objects don't know how, so must be wrapped in a JSObectProxy."
  20. <console.log(String(_st(anObject)._asString()))>
  21. ! !
  22. !ConsoleTranscript class methodsFor: 'initialization'!
  23. initialize
  24. Transcript register: self new
  25. ! !
  26. Object subclass: #Transcript
  27. instanceVariableNames: ''
  28. package: 'Kernel-Transcript'!
  29. !Transcript commentStamp!
  30. I am a facade for Transcript actions.
  31. I delegate actions to the currently registered transcript.
  32. ## API
  33. Transcript
  34. show: 'hello world';
  35. cr;
  36. show: anObject.!
  37. Transcript class instanceVariableNames: 'current'!
  38. !Transcript class methodsFor: 'instance creation'!
  39. current
  40. ^current
  41. !
  42. new
  43. self shouldNotImplement
  44. !
  45. open
  46. self current open
  47. !
  48. register: aTranscript
  49. current := aTranscript
  50. ! !
  51. !Transcript class methodsFor: 'printing'!
  52. clear
  53. self current clear
  54. !
  55. cr
  56. self current show: String cr
  57. !
  58. inspect: anObject
  59. self show: anObject
  60. !
  61. show: anObject
  62. self current show: anObject
  63. ! !