1
0

Helios-Transcript.js 8.5 KB

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