Helios-Transcript.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. define("helios/Helios-Transcript", ["amber/boot", "helios/Helios-Core", "amber_core/Kernel-Objects"], function($boot){
  2. var $core=$boot.api,nil=$boot.nil,$recv=$boot.asReceiver,$globals=$boot.globals;
  3. $core.addPackage('Helios-Transcript');
  4. $core.packages["Helios-Transcript"].innerEval = function (expr) { return eval(expr); };
  5. $core.packages["Helios-Transcript"].transport = {"type":"amd","amdNamespace":"helios"};
  6. $core.addClass('HLTranscript', $globals.HLWidget, ['textarea'], 'Helios-Transcript');
  7. //>>excludeStart("ide", pragmas.excludeIdeData);
  8. $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` service class.";
  9. //>>excludeEnd("ide");
  10. $core.addMethod(
  11. $core.method({
  12. selector: "clear",
  13. protocol: 'actions',
  14. fn: function (){
  15. var self=this;
  16. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  17. return $core.withContext(function($ctx1) {
  18. //>>excludeEnd("ctx");
  19. $recv($recv(self["@textarea"])._asJQuery())._text_("");
  20. return self;
  21. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  22. }, function($ctx1) {$ctx1.fill(self,"clear",{},$globals.HLTranscript)});
  23. //>>excludeEnd("ctx");
  24. },
  25. //>>excludeStart("ide", pragmas.excludeIdeData);
  26. args: [],
  27. source: "clear\x0a\x09textarea asJQuery text: ''",
  28. referencedClasses: [],
  29. //>>excludeEnd("ide");
  30. messageSends: ["text:", "asJQuery"]
  31. }),
  32. $globals.HLTranscript);
  33. $core.addMethod(
  34. $core.method({
  35. selector: "initialize",
  36. protocol: 'initialization',
  37. fn: function (){
  38. var self=this;
  39. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  40. return $core.withContext(function($ctx1) {
  41. //>>excludeEnd("ctx");
  42. (
  43. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  44. $ctx1.supercall = true,
  45. //>>excludeEnd("ctx");
  46. $globals.HLTranscript.superclass.fn.prototype._initialize.apply($recv(self), []));
  47. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  48. $ctx1.supercall = false;
  49. //>>excludeEnd("ctx");;
  50. self._register();
  51. return self;
  52. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  53. }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.HLTranscript)});
  54. //>>excludeEnd("ctx");
  55. },
  56. //>>excludeStart("ide", pragmas.excludeIdeData);
  57. args: [],
  58. source: "initialize\x0a\x09super initialize.\x0a\x09self register",
  59. referencedClasses: [],
  60. //>>excludeEnd("ide");
  61. messageSends: ["initialize", "register"]
  62. }),
  63. $globals.HLTranscript);
  64. $core.addMethod(
  65. $core.method({
  66. selector: "register",
  67. protocol: 'registration',
  68. fn: function (){
  69. var self=this;
  70. function $HLTranscriptHandler(){return $globals.HLTranscriptHandler||(typeof HLTranscriptHandler=="undefined"?nil:HLTranscriptHandler)}
  71. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  72. return $core.withContext(function($ctx1) {
  73. //>>excludeEnd("ctx");
  74. $recv($HLTranscriptHandler())._register_(self);
  75. return self;
  76. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  77. }, function($ctx1) {$ctx1.fill(self,"register",{},$globals.HLTranscript)});
  78. //>>excludeEnd("ctx");
  79. },
  80. //>>excludeStart("ide", pragmas.excludeIdeData);
  81. args: [],
  82. source: "register\x0a\x09HLTranscriptHandler register: self",
  83. referencedClasses: ["HLTranscriptHandler"],
  84. //>>excludeEnd("ide");
  85. messageSends: ["register:"]
  86. }),
  87. $globals.HLTranscript);
  88. $core.addMethod(
  89. $core.method({
  90. selector: "renderOn:",
  91. protocol: 'rendering',
  92. fn: function (html){
  93. var self=this;
  94. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  95. return $core.withContext(function($ctx1) {
  96. //>>excludeEnd("ctx");
  97. var $1,$2;
  98. $1=$recv(html)._div();
  99. $recv($1)._class_("transcript");
  100. $2=$recv($1)._with_((function(){
  101. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  102. return $core.withContext(function($ctx2) {
  103. //>>excludeEnd("ctx");
  104. self["@textarea"]=$recv(html)._textarea();
  105. return self["@textarea"];
  106. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  107. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  108. //>>excludeEnd("ctx");
  109. }));
  110. return self;
  111. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  112. }, function($ctx1) {$ctx1.fill(self,"renderOn:",{html:html},$globals.HLTranscript)});
  113. //>>excludeEnd("ctx");
  114. },
  115. //>>excludeStart("ide", pragmas.excludeIdeData);
  116. args: ["html"],
  117. source: "renderOn: html\x0a\x09html div\x0a\x09\x09class: 'transcript';\x0a\x09\x09with: [ textarea := html textarea ]",
  118. referencedClasses: [],
  119. //>>excludeEnd("ide");
  120. messageSends: ["class:", "div", "with:", "textarea"]
  121. }),
  122. $globals.HLTranscript);
  123. $core.addMethod(
  124. $core.method({
  125. selector: "show:",
  126. protocol: 'actions',
  127. fn: function (aString){
  128. var self=this;
  129. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  130. return $core.withContext(function($ctx1) {
  131. //>>excludeEnd("ctx");
  132. var $1,$receiver;
  133. $1=self["@textarea"];
  134. if(($receiver = $1) == null || $receiver.isNil){
  135. $1;
  136. } else {
  137. $recv($recv(self["@textarea"])._asJQuery())._append_($recv(aString)._asString());
  138. };
  139. return self;
  140. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  141. }, function($ctx1) {$ctx1.fill(self,"show:",{aString:aString},$globals.HLTranscript)});
  142. //>>excludeEnd("ctx");
  143. },
  144. //>>excludeStart("ide", pragmas.excludeIdeData);
  145. args: ["aString"],
  146. source: "show: aString\x0a\x09textarea ifNotNil: [\x0a \x09\x09textarea asJQuery append: aString asString ]",
  147. referencedClasses: [],
  148. //>>excludeEnd("ide");
  149. messageSends: ["ifNotNil:", "append:", "asJQuery", "asString"]
  150. }),
  151. $globals.HLTranscript);
  152. $core.addMethod(
  153. $core.method({
  154. selector: "unregister",
  155. protocol: 'registration',
  156. fn: function (){
  157. var self=this;
  158. function $HLTranscriptHandler(){return $globals.HLTranscriptHandler||(typeof HLTranscriptHandler=="undefined"?nil:HLTranscriptHandler)}
  159. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  160. return $core.withContext(function($ctx1) {
  161. //>>excludeEnd("ctx");
  162. (
  163. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  164. $ctx1.supercall = true,
  165. //>>excludeEnd("ctx");
  166. $globals.HLTranscript.superclass.fn.prototype._unregister.apply($recv(self), []));
  167. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  168. $ctx1.supercall = false;
  169. //>>excludeEnd("ctx");;
  170. $recv($HLTranscriptHandler())._unregister_(self);
  171. return self;
  172. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  173. }, function($ctx1) {$ctx1.fill(self,"unregister",{},$globals.HLTranscript)});
  174. //>>excludeEnd("ctx");
  175. },
  176. //>>excludeStart("ide", pragmas.excludeIdeData);
  177. args: [],
  178. source: "unregister\x0a\x09super unregister.\x0a\x09HLTranscriptHandler unregister: self",
  179. referencedClasses: ["HLTranscriptHandler"],
  180. //>>excludeEnd("ide");
  181. messageSends: ["unregister", "unregister:"]
  182. }),
  183. $globals.HLTranscript);
  184. $core.addClass('HLTranscriptHandler', $globals.Object, [], 'Helios-Transcript');
  185. //>>excludeStart("ide", pragmas.excludeIdeData);
  186. $globals.HLTranscriptHandler.comment="I handle transcript events, dispatching them to all instances of `HLTranscript`.\x0a\x0a## API\x0a\x0aUse the class-side method `#register:` to add transcript instances.";
  187. //>>excludeEnd("ide");
  188. $globals.HLTranscriptHandler.klass.iVarNames = ['transcripts'];
  189. $core.addMethod(
  190. $core.method({
  191. selector: "clear",
  192. protocol: 'printing',
  193. fn: function (){
  194. var self=this;
  195. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  196. return $core.withContext(function($ctx1) {
  197. //>>excludeEnd("ctx");
  198. $recv(self._transcripts())._do_((function(each){
  199. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  200. return $core.withContext(function($ctx2) {
  201. //>>excludeEnd("ctx");
  202. return $recv(each)._clear();
  203. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  204. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  205. //>>excludeEnd("ctx");
  206. }));
  207. return self;
  208. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  209. }, function($ctx1) {$ctx1.fill(self,"clear",{},$globals.HLTranscriptHandler.klass)});
  210. //>>excludeEnd("ctx");
  211. },
  212. //>>excludeStart("ide", pragmas.excludeIdeData);
  213. args: [],
  214. source: "clear\x0a\x09self transcripts do: [ :each |\x0a\x09\x09each clear ]",
  215. referencedClasses: [],
  216. //>>excludeEnd("ide");
  217. messageSends: ["do:", "transcripts", "clear"]
  218. }),
  219. $globals.HLTranscriptHandler.klass);
  220. $core.addMethod(
  221. $core.method({
  222. selector: "cr",
  223. protocol: 'printing',
  224. fn: function (){
  225. var self=this;
  226. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  227. return $core.withContext(function($ctx1) {
  228. //>>excludeEnd("ctx");
  229. $recv(self._transcripts())._do_((function(each){
  230. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  231. return $core.withContext(function($ctx2) {
  232. //>>excludeEnd("ctx");
  233. return $recv(each)._cr();
  234. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  235. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  236. //>>excludeEnd("ctx");
  237. }));
  238. return self;
  239. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  240. }, function($ctx1) {$ctx1.fill(self,"cr",{},$globals.HLTranscriptHandler.klass)});
  241. //>>excludeEnd("ctx");
  242. },
  243. //>>excludeStart("ide", pragmas.excludeIdeData);
  244. args: [],
  245. source: "cr\x0a\x09self transcripts do: [ :each | each cr ]",
  246. referencedClasses: [],
  247. //>>excludeEnd("ide");
  248. messageSends: ["do:", "transcripts", "cr"]
  249. }),
  250. $globals.HLTranscriptHandler.klass);
  251. $core.addMethod(
  252. $core.method({
  253. selector: "register:",
  254. protocol: 'registration',
  255. fn: function (aTranscript){
  256. var self=this;
  257. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  258. return $core.withContext(function($ctx1) {
  259. //>>excludeEnd("ctx");
  260. $recv(self._transcripts())._add_(aTranscript);
  261. return self;
  262. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  263. }, function($ctx1) {$ctx1.fill(self,"register:",{aTranscript:aTranscript},$globals.HLTranscriptHandler.klass)});
  264. //>>excludeEnd("ctx");
  265. },
  266. //>>excludeStart("ide", pragmas.excludeIdeData);
  267. args: ["aTranscript"],
  268. source: "register: aTranscript\x0a\x09self transcripts add: aTranscript",
  269. referencedClasses: [],
  270. //>>excludeEnd("ide");
  271. messageSends: ["add:", "transcripts"]
  272. }),
  273. $globals.HLTranscriptHandler.klass);
  274. $core.addMethod(
  275. $core.method({
  276. selector: "show:",
  277. protocol: 'printing',
  278. fn: function (aString){
  279. var self=this;
  280. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  281. return $core.withContext(function($ctx1) {
  282. //>>excludeEnd("ctx");
  283. $recv(self._transcripts())._do_((function(each){
  284. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  285. return $core.withContext(function($ctx2) {
  286. //>>excludeEnd("ctx");
  287. return $recv(each)._show_(aString);
  288. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  289. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  290. //>>excludeEnd("ctx");
  291. }));
  292. return self;
  293. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  294. }, function($ctx1) {$ctx1.fill(self,"show:",{aString:aString},$globals.HLTranscriptHandler.klass)});
  295. //>>excludeEnd("ctx");
  296. },
  297. //>>excludeStart("ide", pragmas.excludeIdeData);
  298. args: ["aString"],
  299. source: "show: aString\x0a\x09self transcripts do: [ :each |\x0a\x09\x09each show: aString ]",
  300. referencedClasses: [],
  301. //>>excludeEnd("ide");
  302. messageSends: ["do:", "transcripts", "show:"]
  303. }),
  304. $globals.HLTranscriptHandler.klass);
  305. $core.addMethod(
  306. $core.method({
  307. selector: "transcripts",
  308. protocol: 'accessing',
  309. fn: function (){
  310. var self=this;
  311. function $OrderedCollection(){return $globals.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  312. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  313. return $core.withContext(function($ctx1) {
  314. //>>excludeEnd("ctx");
  315. var $2,$1,$receiver;
  316. $2=self["@transcripts"];
  317. if(($receiver = $2) == null || $receiver.isNil){
  318. self["@transcripts"]=$recv($OrderedCollection())._new();
  319. $1=self["@transcripts"];
  320. } else {
  321. $1=$2;
  322. };
  323. return $1;
  324. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  325. }, function($ctx1) {$ctx1.fill(self,"transcripts",{},$globals.HLTranscriptHandler.klass)});
  326. //>>excludeEnd("ctx");
  327. },
  328. //>>excludeStart("ide", pragmas.excludeIdeData);
  329. args: [],
  330. source: "transcripts\x0a\x09^ transcripts ifNil: [ transcripts := OrderedCollection new ]",
  331. referencedClasses: ["OrderedCollection"],
  332. //>>excludeEnd("ide");
  333. messageSends: ["ifNil:", "new"]
  334. }),
  335. $globals.HLTranscriptHandler.klass);
  336. $core.addMethod(
  337. $core.method({
  338. selector: "unregister:",
  339. protocol: 'registration',
  340. fn: function (aTranscript){
  341. var self=this;
  342. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  343. return $core.withContext(function($ctx1) {
  344. //>>excludeEnd("ctx");
  345. $recv(self._transcripts())._remove_(aTranscript);
  346. return self;
  347. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  348. }, function($ctx1) {$ctx1.fill(self,"unregister:",{aTranscript:aTranscript},$globals.HLTranscriptHandler.klass)});
  349. //>>excludeEnd("ctx");
  350. },
  351. //>>excludeStart("ide", pragmas.excludeIdeData);
  352. args: ["aTranscript"],
  353. source: "unregister: aTranscript\x0a\x09self transcripts remove: aTranscript",
  354. referencedClasses: [],
  355. //>>excludeEnd("ide");
  356. messageSends: ["remove:", "transcripts"]
  357. }),
  358. $globals.HLTranscriptHandler.klass);
  359. });