2
0

Helios-Transcript.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. define("amber_core/Helios-Transcript", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Helios-Core", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st, globals){
  2. smalltalk.addPackage('Helios-Transcript');
  3. smalltalk.packages["Helios-Transcript"].transport = {"type":"amd","amdNamespace":"amber_core"};
  4. smalltalk.addClass('HLTranscript', globals.HLWidget, ['textarea'], 'Helios-Transcript');
  5. globals.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. protocol: '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",{},globals.HLTranscript)})},
  15. args: [],
  16. source: "clear\x0a\x09textarea asJQuery text: ''",
  17. messageSends: ["text:", "asJQuery"],
  18. referencedClasses: []
  19. }),
  20. globals.HLTranscript);
  21. smalltalk.addMethod(
  22. smalltalk.method({
  23. selector: "initialize",
  24. protocol: 'initialization',
  25. fn: function (){
  26. var self=this;
  27. return smalltalk.withContext(function($ctx1) {
  28. globals.HLTranscript.superclass.fn.prototype._initialize.apply(_st(self), []);
  29. self._register();
  30. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.HLTranscript)})},
  31. args: [],
  32. source: "initialize\x0a\x09super initialize.\x0a\x09self register",
  33. messageSends: ["initialize", "register"],
  34. referencedClasses: []
  35. }),
  36. globals.HLTranscript);
  37. smalltalk.addMethod(
  38. smalltalk.method({
  39. selector: "register",
  40. protocol: 'registration',
  41. fn: function (){
  42. var self=this;
  43. function $HLTranscriptHandler(){return globals.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",{},globals.HLTranscript)})},
  47. args: [],
  48. source: "register\x0a\x09HLTranscriptHandler register: self",
  49. messageSends: ["register:"],
  50. referencedClasses: ["HLTranscriptHandler"]
  51. }),
  52. globals.HLTranscript);
  53. smalltalk.addMethod(
  54. smalltalk.method({
  55. selector: "renderOn:",
  56. protocol: '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},globals.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. globals.HLTranscript);
  75. smalltalk.addMethod(
  76. smalltalk.method({
  77. selector: "show:",
  78. protocol: '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},globals.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. globals.HLTranscript);
  96. smalltalk.addMethod(
  97. smalltalk.method({
  98. selector: "unregister",
  99. protocol: 'registration',
  100. fn: function (){
  101. var self=this;
  102. function $HLTranscriptHandler(){return globals.HLTranscriptHandler||(typeof HLTranscriptHandler=="undefined"?nil:HLTranscriptHandler)}
  103. return smalltalk.withContext(function($ctx1) {
  104. globals.HLTranscript.superclass.fn.prototype._unregister.apply(_st(self), []);
  105. _st($HLTranscriptHandler())._unregister_(self);
  106. return self}, function($ctx1) {$ctx1.fill(self,"unregister",{},globals.HLTranscript)})},
  107. args: [],
  108. source: "unregister\x0a\x09super unregister.\x0a\x09HLTranscriptHandler unregister: self",
  109. messageSends: ["unregister", "unregister:"],
  110. referencedClasses: ["HLTranscriptHandler"]
  111. }),
  112. globals.HLTranscript);
  113. smalltalk.addClass('HLTranscriptHandler', globals.Object, [], 'Helios-Transcript');
  114. globals.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. globals.HLTranscriptHandler.klass.iVarNames = ['transcripts'];
  116. smalltalk.addMethod(
  117. smalltalk.method({
  118. selector: "clear",
  119. protocol: 'printing',
  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",{},globals.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. globals.HLTranscriptHandler.klass);
  134. smalltalk.addMethod(
  135. smalltalk.method({
  136. selector: "cr",
  137. protocol: 'printing',
  138. fn: function (){
  139. var self=this;
  140. return smalltalk.withContext(function($ctx1) {
  141. _st(self._transcripts())._do_((function(each){
  142. return smalltalk.withContext(function($ctx2) {
  143. return _st(each)._cr();
  144. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  145. return self}, function($ctx1) {$ctx1.fill(self,"cr",{},globals.HLTranscriptHandler.klass)})},
  146. args: [],
  147. source: "cr\x0a\x09self transcripts do: [ :each | each cr ]",
  148. messageSends: ["do:", "transcripts", "cr"],
  149. referencedClasses: []
  150. }),
  151. globals.HLTranscriptHandler.klass);
  152. smalltalk.addMethod(
  153. smalltalk.method({
  154. selector: "register:",
  155. protocol: 'registration',
  156. fn: function (aTranscript){
  157. var self=this;
  158. return smalltalk.withContext(function($ctx1) {
  159. _st(self._transcripts())._add_(aTranscript);
  160. return self}, function($ctx1) {$ctx1.fill(self,"register:",{aTranscript:aTranscript},globals.HLTranscriptHandler.klass)})},
  161. args: ["aTranscript"],
  162. source: "register: aTranscript\x0a\x09self transcripts add: aTranscript",
  163. messageSends: ["add:", "transcripts"],
  164. referencedClasses: []
  165. }),
  166. globals.HLTranscriptHandler.klass);
  167. smalltalk.addMethod(
  168. smalltalk.method({
  169. selector: "show:",
  170. protocol: 'printing',
  171. fn: function (aString){
  172. var self=this;
  173. return smalltalk.withContext(function($ctx1) {
  174. _st(self._transcripts())._do_((function(each){
  175. return smalltalk.withContext(function($ctx2) {
  176. return _st(each)._show_(aString);
  177. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  178. return self}, function($ctx1) {$ctx1.fill(self,"show:",{aString:aString},globals.HLTranscriptHandler.klass)})},
  179. args: ["aString"],
  180. source: "show: aString\x0a\x09self transcripts do: [ :each |\x0a\x09\x09each show: aString ]",
  181. messageSends: ["do:", "transcripts", "show:"],
  182. referencedClasses: []
  183. }),
  184. globals.HLTranscriptHandler.klass);
  185. smalltalk.addMethod(
  186. smalltalk.method({
  187. selector: "transcripts",
  188. protocol: 'accessing',
  189. fn: function (){
  190. var self=this;
  191. function $OrderedCollection(){return globals.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  192. return smalltalk.withContext(function($ctx1) {
  193. var $2,$1;
  194. $2=self["@transcripts"];
  195. if(($receiver = $2) == nil || $receiver == null){
  196. self["@transcripts"]=_st($OrderedCollection())._new();
  197. $1=self["@transcripts"];
  198. } else {
  199. $1=$2;
  200. };
  201. return $1;
  202. }, function($ctx1) {$ctx1.fill(self,"transcripts",{},globals.HLTranscriptHandler.klass)})},
  203. args: [],
  204. source: "transcripts\x0a\x09^ transcripts ifNil: [ transcripts := OrderedCollection new ]",
  205. messageSends: ["ifNil:", "new"],
  206. referencedClasses: ["OrderedCollection"]
  207. }),
  208. globals.HLTranscriptHandler.klass);
  209. smalltalk.addMethod(
  210. smalltalk.method({
  211. selector: "unregister:",
  212. protocol: 'registration',
  213. fn: function (aTranscript){
  214. var self=this;
  215. return smalltalk.withContext(function($ctx1) {
  216. _st(self._transcripts())._remove_(aTranscript);
  217. return self}, function($ctx1) {$ctx1.fill(self,"unregister:",{aTranscript:aTranscript},globals.HLTranscriptHandler.klass)})},
  218. args: ["aTranscript"],
  219. source: "unregister: aTranscript\x0a\x09self transcripts remove: aTranscript",
  220. messageSends: ["remove:", "transcripts"],
  221. referencedClasses: []
  222. }),
  223. globals.HLTranscriptHandler.klass);
  224. });