Helios-Transcript.js 8.3 KB

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