2
0

Helios-Transcript.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. 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. var $1;
  81. $1=self["@textarea"];
  82. if(($receiver = $1) == nil || $receiver == undefined){
  83. $1;
  84. } else {
  85. _st(_st(self["@textarea"])._asJQuery())._append_(_st(aString)._asString());
  86. };
  87. return self}, function($ctx1) {$ctx1.fill(self,"show:",{aString:aString},smalltalk.HLTranscript)})},
  88. args: ["aString"],
  89. source: "show: aString\x0a\x09textarea ifNotNil: [\x0a \x09\x09textarea asJQuery append: aString asString ]",
  90. messageSends: ["ifNotNil:", "append:", "asString", "asJQuery"],
  91. referencedClasses: []
  92. }),
  93. smalltalk.HLTranscript);
  94. smalltalk.addMethod(
  95. smalltalk.method({
  96. selector: "unregister",
  97. category: 'registration',
  98. fn: function (){
  99. var self=this;
  100. function $HLTranscriptHandler(){return smalltalk.HLTranscriptHandler||(typeof HLTranscriptHandler=="undefined"?nil:HLTranscriptHandler)}
  101. return smalltalk.withContext(function($ctx1) {
  102. smalltalk.HLWidget.fn.prototype._unregister.apply(_st(self), []);
  103. _st($HLTranscriptHandler())._unregister_(self);
  104. return self}, function($ctx1) {$ctx1.fill(self,"unregister",{},smalltalk.HLTranscript)})},
  105. args: [],
  106. source: "unregister\x0a\x09super unregister.\x0a\x09HLTranscriptHandler unregister: self",
  107. messageSends: ["unregister", "unregister:"],
  108. referencedClasses: ["HLTranscriptHandler"]
  109. }),
  110. smalltalk.HLTranscript);
  111. smalltalk.addClass('HLTranscriptHandler', smalltalk.Object, [], 'Helios-Transcript');
  112. 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.";
  113. smalltalk.HLTranscriptHandler.klass.iVarNames = ['transcripts'];
  114. smalltalk.addMethod(
  115. smalltalk.method({
  116. selector: "clear",
  117. category: 'registration',
  118. fn: function (){
  119. var self=this;
  120. return smalltalk.withContext(function($ctx1) {
  121. _st(self._transcripts())._do_((function(each){
  122. return smalltalk.withContext(function($ctx2) {
  123. return _st(each)._clear();
  124. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  125. return self}, function($ctx1) {$ctx1.fill(self,"clear",{},smalltalk.HLTranscriptHandler.klass)})},
  126. args: [],
  127. source: "clear\x0a\x09self transcripts do: [ :each |\x0a\x09\x09each clear ]",
  128. messageSends: ["do:", "clear", "transcripts"],
  129. referencedClasses: []
  130. }),
  131. smalltalk.HLTranscriptHandler.klass);
  132. smalltalk.addMethod(
  133. smalltalk.method({
  134. selector: "initialize",
  135. category: 'initialization',
  136. fn: function (){
  137. var self=this;
  138. function $Transcript(){return smalltalk.Transcript||(typeof Transcript=="undefined"?nil:Transcript)}
  139. return smalltalk.withContext(function($ctx1) {
  140. _st($Transcript())._register_(self);
  141. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.HLTranscriptHandler.klass)})},
  142. args: [],
  143. source: "initialize\x0a\x09Transcript register: self",
  144. messageSends: ["register:"],
  145. referencedClasses: ["Transcript"]
  146. }),
  147. smalltalk.HLTranscriptHandler.klass);
  148. smalltalk.addMethod(
  149. smalltalk.method({
  150. selector: "register:",
  151. category: 'registration',
  152. fn: function (aTranscript){
  153. var self=this;
  154. return smalltalk.withContext(function($ctx1) {
  155. _st(self._transcripts())._add_(aTranscript);
  156. return self}, function($ctx1) {$ctx1.fill(self,"register:",{aTranscript:aTranscript},smalltalk.HLTranscriptHandler.klass)})},
  157. args: ["aTranscript"],
  158. source: "register: aTranscript\x0a\x09self transcripts add: aTranscript",
  159. messageSends: ["add:", "transcripts"],
  160. referencedClasses: []
  161. }),
  162. smalltalk.HLTranscriptHandler.klass);
  163. smalltalk.addMethod(
  164. smalltalk.method({
  165. selector: "show:",
  166. category: 'registration',
  167. fn: function (aString){
  168. var self=this;
  169. return smalltalk.withContext(function($ctx1) {
  170. _st(self._transcripts())._do_((function(each){
  171. return smalltalk.withContext(function($ctx2) {
  172. return _st(each)._show_(aString);
  173. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  174. return self}, function($ctx1) {$ctx1.fill(self,"show:",{aString:aString},smalltalk.HLTranscriptHandler.klass)})},
  175. args: ["aString"],
  176. source: "show: aString\x0a\x09self transcripts do: [ :each |\x0a\x09\x09each show: aString ]",
  177. messageSends: ["do:", "show:", "transcripts"],
  178. referencedClasses: []
  179. }),
  180. smalltalk.HLTranscriptHandler.klass);
  181. smalltalk.addMethod(
  182. smalltalk.method({
  183. selector: "transcripts",
  184. category: 'accessing',
  185. fn: function (){
  186. var self=this;
  187. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  188. return smalltalk.withContext(function($ctx1) {
  189. var $2,$1;
  190. $2=self["@transcripts"];
  191. if(($receiver = $2) == nil || $receiver == undefined){
  192. self["@transcripts"]=_st($OrderedCollection())._new();
  193. $1=self["@transcripts"];
  194. } else {
  195. $1=$2;
  196. };
  197. return $1;
  198. }, function($ctx1) {$ctx1.fill(self,"transcripts",{},smalltalk.HLTranscriptHandler.klass)})},
  199. args: [],
  200. source: "transcripts\x0a\x09^ transcripts ifNil: [ transcripts := OrderedCollection new ]",
  201. messageSends: ["ifNil:", "new"],
  202. referencedClasses: ["OrderedCollection"]
  203. }),
  204. smalltalk.HLTranscriptHandler.klass);
  205. smalltalk.addMethod(
  206. smalltalk.method({
  207. selector: "unregister:",
  208. category: 'registration',
  209. fn: function (aTranscript){
  210. var self=this;
  211. return smalltalk.withContext(function($ctx1) {
  212. _st(self._transcripts())._remove_(aTranscript);
  213. return self}, function($ctx1) {$ctx1.fill(self,"unregister:",{aTranscript:aTranscript},smalltalk.HLTranscriptHandler.klass)})},
  214. args: ["aTranscript"],
  215. source: "unregister: aTranscript\x0a\x09self transcripts remove: aTranscript",
  216. messageSends: ["remove:", "transcripts"],
  217. referencedClasses: []
  218. }),
  219. smalltalk.HLTranscriptHandler.klass);