Helios-Transcript.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. smalltalk.addPackage('Helios-Transcript');
  2. smalltalk.addClass('HLTranscript', smalltalk.HLWidget, ['textarea'], 'Helios-Transcript');
  3. smalltalk.HLTranscript.comment="I am a widget responsible for displaying transcript contents.\x0a\x0a## Transcript API\x0a\x0a Transcript \x0a show: 'hello world';\x0a cr;\x0a show: anObject.\x0a\x0a Transcript clear.\x0a\x0aSee the `Transcript` class."
  4. smalltalk.addMethod(
  5. smalltalk.method({
  6. selector: "clear",
  7. category: 'actions',
  8. fn: function (){
  9. var self=this;
  10. return smalltalk.withContext(function($ctx1) {
  11. _st(_st(self["@textarea"])._asJQuery())._text_("");
  12. return self}, function($ctx1) {$ctx1.fill(self,"clear",{},smalltalk.HLTranscript)})},
  13. args: [],
  14. source: "clear\x0a\x09textarea asJQuery text: ''",
  15. messageSends: ["text:", "asJQuery"],
  16. referencedClasses: []
  17. }),
  18. smalltalk.HLTranscript);
  19. smalltalk.addMethod(
  20. smalltalk.method({
  21. selector: "initialize",
  22. category: 'initialization',
  23. fn: function (){
  24. var self=this;
  25. return smalltalk.withContext(function($ctx1) {
  26. smalltalk.HLWidget.fn.prototype._initialize.apply(_st(self), []);
  27. _st(self)._register();
  28. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.HLTranscript)})},
  29. args: [],
  30. source: "initialize\x0a\x09super initialize.\x0a\x09self register",
  31. messageSends: ["initialize", "register"],
  32. referencedClasses: []
  33. }),
  34. smalltalk.HLTranscript);
  35. smalltalk.addMethod(
  36. smalltalk.method({
  37. selector: "register",
  38. category: 'registration',
  39. fn: function (){
  40. var self=this;
  41. function $HLTranscriptHandler(){return smalltalk.HLTranscriptHandler||(typeof HLTranscriptHandler=="undefined"?nil:HLTranscriptHandler)}
  42. return smalltalk.withContext(function($ctx1) {
  43. _st($HLTranscriptHandler())._register_(self);
  44. return self}, function($ctx1) {$ctx1.fill(self,"register",{},smalltalk.HLTranscript)})},
  45. args: [],
  46. source: "register\x0a\x09HLTranscriptHandler register: self",
  47. messageSends: ["register:"],
  48. referencedClasses: ["HLTranscriptHandler"]
  49. }),
  50. smalltalk.HLTranscript);
  51. smalltalk.addMethod(
  52. smalltalk.method({
  53. selector: "renderOn:",
  54. category: 'rendering',
  55. fn: function (html){
  56. var self=this;
  57. return smalltalk.withContext(function($ctx1) {
  58. var $1,$2;
  59. $1=_st(html)._div();
  60. _st($1)._class_("transcript");
  61. $2=_st($1)._with_((function(){
  62. return smalltalk.withContext(function($ctx2) {
  63. self["@textarea"]=_st(html)._textarea();
  64. return self["@textarea"];
  65. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  66. return self}, function($ctx1) {$ctx1.fill(self,"renderOn:",{html:html},smalltalk.HLTranscript)})},
  67. args: ["html"],
  68. source: "renderOn: html\x0a\x09html div\x0a\x09\x09class: 'transcript';\x0a\x09\x09with: [ textarea := html textarea ]",
  69. messageSends: ["class:", "div", "with:", "textarea"],
  70. referencedClasses: []
  71. }),
  72. smalltalk.HLTranscript);
  73. smalltalk.addMethod(
  74. smalltalk.method({
  75. selector: "show:",
  76. category: 'actions',
  77. fn: function (aString){
  78. var self=this;
  79. return smalltalk.withContext(function($ctx1) {
  80. _st(_st(self["@textarea"])._asJQuery())._append_(_st(aString)._asString());
  81. return self}, function($ctx1) {$ctx1.fill(self,"show:",{aString:aString},smalltalk.HLTranscript)})},
  82. args: ["aString"],
  83. source: "show: aString\x0a\x09textarea asJQuery append: aString asString",
  84. messageSends: ["append:", "asString", "asJQuery"],
  85. referencedClasses: []
  86. }),
  87. smalltalk.HLTranscript);
  88. smalltalk.addMethod(
  89. smalltalk.method({
  90. selector: "unregister",
  91. category: 'registration',
  92. fn: function (){
  93. var self=this;
  94. function $HLTranscriptHandler(){return smalltalk.HLTranscriptHandler||(typeof HLTranscriptHandler=="undefined"?nil:HLTranscriptHandler)}
  95. return smalltalk.withContext(function($ctx1) {
  96. smalltalk.HLWidget.fn.prototype._unregister.apply(_st(self), []);
  97. _st($HLTranscriptHandler())._unregister_(self);
  98. return self}, function($ctx1) {$ctx1.fill(self,"unregister",{},smalltalk.HLTranscript)})},
  99. args: [],
  100. source: "unregister\x0a\x09super unregister.\x0a\x09HLTranscriptHandler unregister: self",
  101. messageSends: ["unregister", "unregister:"],
  102. referencedClasses: ["HLTranscriptHandler"]
  103. }),
  104. smalltalk.HLTranscript);
  105. smalltalk.addClass('HLTranscriptHandler', smalltalk.Object, [], 'Helios-Transcript');
  106. smalltalk.HLTranscriptHandler.comment="I handle transcript events, dispatching them to all instances of `HLTranscript`.\x0a\x0a## API\x0a\x0aOn class initialization I am automatically registered as the current transcript."
  107. smalltalk.HLTranscriptHandler.klass.iVarNames = ['transcripts'];
  108. smalltalk.addMethod(
  109. smalltalk.method({
  110. selector: "clear",
  111. category: 'registration',
  112. fn: function (){
  113. var self=this;
  114. return smalltalk.withContext(function($ctx1) {
  115. _st(_st(self)._transcripts())._do_((function(each){
  116. return smalltalk.withContext(function($ctx2) {
  117. return _st(each)._clear();
  118. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  119. return self}, function($ctx1) {$ctx1.fill(self,"clear",{},smalltalk.HLTranscriptHandler.klass)})},
  120. args: [],
  121. source: "clear\x0a\x09self transcripts do: [ :each |\x0a\x09\x09each clear ]",
  122. messageSends: ["do:", "clear", "transcripts"],
  123. referencedClasses: []
  124. }),
  125. smalltalk.HLTranscriptHandler.klass);
  126. smalltalk.addMethod(
  127. smalltalk.method({
  128. selector: "initialize",
  129. category: 'initialization',
  130. fn: function (){
  131. var self=this;
  132. function $Transcript(){return smalltalk.Transcript||(typeof Transcript=="undefined"?nil:Transcript)}
  133. return smalltalk.withContext(function($ctx1) {
  134. _st($Transcript())._register_(self);
  135. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.HLTranscriptHandler.klass)})},
  136. args: [],
  137. source: "initialize\x0a\x09Transcript register: self",
  138. messageSends: ["register:"],
  139. referencedClasses: ["Transcript"]
  140. }),
  141. smalltalk.HLTranscriptHandler.klass);
  142. smalltalk.addMethod(
  143. smalltalk.method({
  144. selector: "register:",
  145. category: 'registration',
  146. fn: function (aTranscript){
  147. var self=this;
  148. return smalltalk.withContext(function($ctx1) {
  149. _st(_st(self)._transcripts())._add_(aTranscript);
  150. return self}, function($ctx1) {$ctx1.fill(self,"register:",{aTranscript:aTranscript},smalltalk.HLTranscriptHandler.klass)})},
  151. args: ["aTranscript"],
  152. source: "register: aTranscript\x0a\x09self transcripts add: aTranscript",
  153. messageSends: ["add:", "transcripts"],
  154. referencedClasses: []
  155. }),
  156. smalltalk.HLTranscriptHandler.klass);
  157. smalltalk.addMethod(
  158. smalltalk.method({
  159. selector: "show:",
  160. category: 'registration',
  161. fn: function (aString){
  162. var self=this;
  163. return smalltalk.withContext(function($ctx1) {
  164. _st(_st(self)._transcripts())._do_((function(each){
  165. return smalltalk.withContext(function($ctx2) {
  166. return _st(each)._show_(aString);
  167. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  168. return self}, function($ctx1) {$ctx1.fill(self,"show:",{aString:aString},smalltalk.HLTranscriptHandler.klass)})},
  169. args: ["aString"],
  170. source: "show: aString\x0a\x09self transcripts do: [ :each |\x0a\x09\x09each show: aString ]",
  171. messageSends: ["do:", "show:", "transcripts"],
  172. referencedClasses: []
  173. }),
  174. smalltalk.HLTranscriptHandler.klass);
  175. smalltalk.addMethod(
  176. smalltalk.method({
  177. selector: "transcripts",
  178. category: 'accessing',
  179. fn: function (){
  180. var self=this;
  181. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  182. return smalltalk.withContext(function($ctx1) {
  183. var $2,$1;
  184. $2=self["@transcripts"];
  185. if(($receiver = $2) == nil || $receiver == undefined){
  186. self["@transcripts"]=_st($OrderedCollection())._new();
  187. $1=self["@transcripts"];
  188. } else {
  189. $1=$2;
  190. };
  191. return $1;
  192. }, function($ctx1) {$ctx1.fill(self,"transcripts",{},smalltalk.HLTranscriptHandler.klass)})},
  193. args: [],
  194. source: "transcripts\x0a\x09^ transcripts ifNil: [ transcripts := OrderedCollection new ]",
  195. messageSends: ["ifNil:", "new"],
  196. referencedClasses: ["OrderedCollection"]
  197. }),
  198. smalltalk.HLTranscriptHandler.klass);
  199. smalltalk.addMethod(
  200. smalltalk.method({
  201. selector: "unregister:",
  202. category: 'registration',
  203. fn: function (aTranscript){
  204. var self=this;
  205. return smalltalk.withContext(function($ctx1) {
  206. _st(_st(self)._transcripts())._remove_(aTranscript);
  207. return self}, function($ctx1) {$ctx1.fill(self,"unregister:",{aTranscript:aTranscript},smalltalk.HLTranscriptHandler.klass)})},
  208. args: ["aTranscript"],
  209. source: "unregister: aTranscript\x0a\x09self transcripts remove: aTranscript",
  210. messageSends: ["remove:", "transcripts"],
  211. referencedClasses: []
  212. }),
  213. smalltalk.HLTranscriptHandler.klass);