Helios-Transcript.st 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. Smalltalk current createPackage: 'Helios-Transcript'!
  2. HLWidget subclass: #HLTranscript
  3. instanceVariableNames: 'textarea'
  4. package: 'Helios-Transcript'!
  5. !HLTranscript commentStamp!
  6. I am a widget responsible for displaying transcript contents.
  7. ## Transcript API
  8. Transcript
  9. show: 'hello world';
  10. cr;
  11. show: anObject.
  12. Transcript clear.
  13. See the `Transcript` class.!
  14. !HLTranscript methodsFor: 'actions'!
  15. clear
  16. textarea asJQuery text: ''
  17. !
  18. show: aString
  19. textarea asJQuery append: aString
  20. ! !
  21. !HLTranscript methodsFor: 'initialization'!
  22. initialize
  23. super initialize.
  24. self register
  25. ! !
  26. !HLTranscript methodsFor: 'registration'!
  27. register
  28. HLTranscriptHandler register: self
  29. !
  30. unregister
  31. super unregister.
  32. HLTranscriptHandler unregister: self
  33. ! !
  34. !HLTranscript methodsFor: 'rendering'!
  35. renderOn: html
  36. html div
  37. class: 'transcript';
  38. with: [ textarea := html textarea ]
  39. ! !
  40. !HLTranscript class methodsFor: 'accessing'!
  41. tabLabel
  42. ^ 'Transcript'
  43. !
  44. tabPriority
  45. ^ 1
  46. ! !
  47. !HLTranscript class methodsFor: 'testing'!
  48. canBeOpenAsTab
  49. ^ true
  50. ! !
  51. Object subclass: #HLTranscriptHandler
  52. instanceVariableNames: ''
  53. package: 'Helios-Transcript'!
  54. !HLTranscriptHandler commentStamp!
  55. I handle transcript events, dispatching them to all instances of `HLTranscript`.
  56. ## API
  57. On class initialization I am automatically registered as the current transcript.!
  58. HLTranscriptHandler class instanceVariableNames: 'transcripts'!
  59. !HLTranscriptHandler class methodsFor: 'accessing'!
  60. transcripts
  61. ^ transcripts ifNil: [ transcripts := OrderedCollection new ]
  62. ! !
  63. !HLTranscriptHandler class methodsFor: 'initialization'!
  64. initialize
  65. Transcript register: self
  66. ! !
  67. !HLTranscriptHandler class methodsFor: 'registration'!
  68. clear
  69. self transcripts do: [ :each |
  70. each clear ]
  71. !
  72. register: aTranscript
  73. self transcripts add: aTranscript
  74. !
  75. show: aString
  76. self transcripts do: [ :each |
  77. each show: aString ]
  78. !
  79. unregister: aTranscript
  80. self transcripts remove: aTranscript
  81. ! !