1
0

Helios-Transcript.js 12 KB

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