1
0

Helios-Workspace.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  1. smalltalk.addPackage('Helios-Workspace', {});
  2. smalltalk.addClass('HLCodeModel', smalltalk.Object, ['announcer', 'environment', 'receiver'], 'Helios-Workspace');
  3. smalltalk.addMethod(
  4. "_announcer",
  5. smalltalk.method({
  6. selector: "announcer",
  7. category: 'accessing',
  8. fn: function () {
  9. var self = this;
  10. var $1;
  11. if (($receiver = self['@announcer']) == nil || $receiver == undefined) {
  12. self['@announcer'] = smalltalk.send(smalltalk.Announcer || Announcer, "_new", []);
  13. $1 = self['@announcer'];
  14. } else {
  15. $1 = self['@announcer'];
  16. }
  17. return $1;
  18. },
  19. args: [],
  20. source: "announcer\x0a\x09^ announcer ifNil: [ announcer := Announcer new ]",
  21. messageSends: ["ifNil:", "new"],
  22. referencedClasses: ["Announcer"]
  23. }),
  24. smalltalk.HLCodeModel);
  25. smalltalk.addMethod(
  26. "_defaultReceiver",
  27. smalltalk.method({
  28. selector: "defaultReceiver",
  29. category: 'defaults',
  30. fn: function () {
  31. var self = this;
  32. var $1;
  33. $1 = smalltalk.send(smalltalk.DoIt || DoIt, "_new", []);
  34. return $1;
  35. },
  36. args: [],
  37. source: "defaultReceiver\x0a\x09^ DoIt new",
  38. messageSends: ["new"],
  39. referencedClasses: ["DoIt"]
  40. }),
  41. smalltalk.HLCodeModel);
  42. smalltalk.addMethod(
  43. "_doIt_",
  44. smalltalk.method({
  45. selector: "doIt:",
  46. category: 'actions',
  47. fn: function (someCode) {
  48. var self = this;
  49. var $1;
  50. $1 = smalltalk.send(smalltalk.send(self, "_environment", []), "_eval_on_", [someCode, smalltalk.send(self, "_receiver", [])]);
  51. return $1;
  52. },
  53. args: ["someCode"],
  54. source: "doIt: someCode\x0a\x0a\x09^ self environment eval: someCode on: self receiver",
  55. messageSends: ["eval:on:", "receiver", "environment"],
  56. referencedClasses: []
  57. }),
  58. smalltalk.HLCodeModel);
  59. smalltalk.addMethod(
  60. "_environment",
  61. smalltalk.method({
  62. selector: "environment",
  63. category: 'accessing',
  64. fn: function () {
  65. var self = this;
  66. var $1;
  67. if (($receiver = self['@environment']) == nil || $receiver == undefined) {
  68. $1 = smalltalk.send(smalltalk.send(smalltalk.HLManager || HLManager, "_current", []), "_environment", []);
  69. } else {
  70. $1 = self['@environment'];
  71. }
  72. return $1;
  73. },
  74. args: [],
  75. source: "environment\x0a\x09^ environment ifNil: [ HLManager current environment ]",
  76. messageSends: ["ifNil:", "environment", "current"],
  77. referencedClasses: ["HLManager"]
  78. }),
  79. smalltalk.HLCodeModel);
  80. smalltalk.addMethod(
  81. "_environment_",
  82. smalltalk.method({
  83. selector: "environment:",
  84. category: 'accessing',
  85. fn: function (anEnvironment) {
  86. var self = this;
  87. self['@environment'] = anEnvironment;
  88. return self;
  89. },
  90. args: ["anEnvironment"],
  91. source: "environment: anEnvironment\x0a\x09environment := anEnvironment",
  92. messageSends: [],
  93. referencedClasses: []
  94. }),
  95. smalltalk.HLCodeModel);
  96. smalltalk.addMethod(
  97. "_receiver",
  98. smalltalk.method({
  99. selector: "receiver",
  100. category: 'accessing',
  101. fn: function () {
  102. var self = this;
  103. var $1;
  104. if (($receiver = self['@receiver']) == nil || $receiver == undefined) {
  105. self['@receiver'] = smalltalk.send(self, "_defaultReceiver", []);
  106. $1 = self['@receiver'];
  107. } else {
  108. $1 = self['@receiver'];
  109. }
  110. return $1;
  111. },
  112. args: [],
  113. source: "receiver\x0a\x09^ receiver ifNil: [ receiver := self defaultReceiver ]",
  114. messageSends: ["ifNil:", "defaultReceiver"],
  115. referencedClasses: []
  116. }),
  117. smalltalk.HLCodeModel);
  118. smalltalk.addMethod(
  119. "_receiver_",
  120. smalltalk.method({
  121. selector: "receiver:",
  122. category: 'accessing',
  123. fn: function (anObject) {
  124. var self = this;
  125. self['@receiver'] = anObject;
  126. return self;
  127. },
  128. args: ["anObject"],
  129. source: "receiver: anObject\x0a\x09receiver := anObject",
  130. messageSends: [],
  131. referencedClasses: []
  132. }),
  133. smalltalk.HLCodeModel);
  134. smalltalk.addMethod(
  135. "_subscribe_",
  136. smalltalk.method({
  137. selector: "subscribe:",
  138. category: 'actions',
  139. fn: function (aWidget) {
  140. var self = this;
  141. smalltalk.send(aWidget, "_subscribeTo_", [smalltalk.send(self, "_announcer", [])]);
  142. return self;
  143. },
  144. args: ["aWidget"],
  145. source: "subscribe: aWidget\x0a\x09aWidget subscribeTo: self announcer",
  146. messageSends: ["subscribeTo:", "announcer"],
  147. referencedClasses: []
  148. }),
  149. smalltalk.HLCodeModel);
  150. smalltalk.addMethod(
  151. "_on_",
  152. smalltalk.method({
  153. selector: "on:",
  154. category: 'actions',
  155. fn: function (anEnvironment) {
  156. var self = this;
  157. var $2, $3, $1;
  158. $2 = smalltalk.send(self, "_new", []);
  159. smalltalk.send($2, "_environment_", [anEnvironment]);
  160. $3 = smalltalk.send($2, "_yourself", []);
  161. $1 = $3;
  162. return $1;
  163. },
  164. args: ["anEnvironment"],
  165. source: "on: anEnvironment\x0a\x0a\x09^ self new\x0a \x09environment: anEnvironment;\x0a yourself",
  166. messageSends: ["environment:", "new", "yourself"],
  167. referencedClasses: []
  168. }),
  169. smalltalk.HLCodeModel.klass);
  170. smalltalk.addClass('HLCodeWidget', smalltalk.HLWidget, ['model', 'wrapper', 'code', 'editor'], 'Helios-Workspace');
  171. smalltalk.addMethod(
  172. "_announcer",
  173. smalltalk.method({
  174. selector: "announcer",
  175. category: 'accessing',
  176. fn: function () {
  177. var self = this;
  178. var $1;
  179. $1 = smalltalk.send(smalltalk.send(self, "_model", []), "_announcer", []);
  180. return $1;
  181. },
  182. args: [],
  183. source: "announcer\x0a\x09^ self model announcer",
  184. messageSends: ["announcer", "model"],
  185. referencedClasses: []
  186. }),
  187. smalltalk.HLCodeWidget);
  188. smalltalk.addMethod(
  189. "_clear",
  190. smalltalk.method({
  191. selector: "clear",
  192. category: 'actions',
  193. fn: function () {
  194. var self = this;
  195. smalltalk.send(self, "_contents_", [""]);
  196. return self;
  197. },
  198. args: [],
  199. source: "clear\x0a self contents: ''",
  200. messageSends: ["contents:"],
  201. referencedClasses: []
  202. }),
  203. smalltalk.HLCodeWidget);
  204. smalltalk.addMethod(
  205. "_contents",
  206. smalltalk.method({
  207. selector: "contents",
  208. category: 'accessing',
  209. fn: function (){
  210. var self=this;
  211. var $1;
  212. $1=smalltalk.send(self["@editor"],"_getValue",[]);
  213. return $1;
  214. },
  215. args: [],
  216. source: "contents\x0a\x09^ editor getValue",
  217. messageSends: ["getValue"],
  218. referencedClasses: []
  219. }),
  220. smalltalk.HLCodeWidget);
  221. smalltalk.addMethod(
  222. "_contents_",
  223. smalltalk.method({
  224. selector: "contents:",
  225. category: 'accessing',
  226. fn: function (aString){
  227. var self=this;
  228. smalltalk.send(self["@editor"],"_setValue_",[aString]);
  229. return self},
  230. args: ["aString"],
  231. source: "contents: aString\x0a\x09editor setValue: aString",
  232. messageSends: ["setValue:"],
  233. referencedClasses: []
  234. }),
  235. smalltalk.HLCodeWidget);
  236. smalltalk.addMethod(
  237. "_currentLine",
  238. smalltalk.method({
  239. selector: "currentLine",
  240. category: 'accessing',
  241. fn: function () {
  242. var self = this;
  243. var $1;
  244. $1 = smalltalk.send(self['@editor'], "_getLine_", [smalltalk.send(smalltalk.send(self['@editor'], "_getCursor", []), "_line", [])]);
  245. return $1;
  246. },
  247. args: [],
  248. source: "currentLine\x0a ^editor getLine: (editor getCursor line)",
  249. messageSends: ["getLine:", "line", "getCursor"],
  250. referencedClasses: []
  251. }),
  252. smalltalk.HLCodeWidget);
  253. smalltalk.addMethod(
  254. "_currentLineOrSelection",
  255. smalltalk.method({
  256. selector: "currentLineOrSelection",
  257. category: 'accessing',
  258. fn: function () {
  259. var self = this;
  260. var $2, $1;
  261. $2 = smalltalk.send(self['@editor'], "_somethingSelected", []);
  262. if (smalltalk.assert($2)) {
  263. $1 = smalltalk.send(self, "_selection", []);
  264. } else {
  265. $1 = smalltalk.send(self, "_currentLine", []);
  266. }
  267. return $1;
  268. },
  269. args: [],
  270. source: "currentLineOrSelection\x0a ^editor somethingSelected\x0a\x09\x09ifFalse: [self currentLine]\x0a\x09\x09ifTrue: [self selection]",
  271. messageSends: ["ifFalse:ifTrue:", "currentLine", "selection", "somethingSelected"],
  272. referencedClasses: []
  273. }),
  274. smalltalk.HLCodeWidget);
  275. smalltalk.addMethod(
  276. "_doIt",
  277. smalltalk.method({
  278. selector: "doIt",
  279. category: 'actions',
  280. fn: function () {
  281. var self = this;
  282. var result;
  283. smalltalk.send(smalltalk.send(self, "_announcer", []), "_announce_", [smalltalk.send(smalltalk.HLDoItRequested || HLDoItRequested, "_on_", [self['@model']])]);
  284. result = smalltalk.send(self['@model'], "_doIt_", [smalltalk.send(self, "_currentLineOrSelection", [])]);
  285. smalltalk.send(smalltalk.send(self, "_announcer", []), "_announce_", [smalltalk.send(smalltalk.HLDoItExecuted || HLDoItExecuted, "_on_", [self['@model']])]);
  286. return result;
  287. },
  288. args: [],
  289. source: "doIt\x0a\x09| result |\x0a\x0a\x09self announcer announce: (HLDoItRequested on: model).\x0a\x0a\x09result:= model doIt: self currentLineOrSelection.\x0a\x0a\x09self announcer announce: (HLDoItExecuted on: model).\x0a\x0a\x09^ result ",
  290. messageSends: ["announce:", "on:", "announcer", "doIt:", "currentLineOrSelection"],
  291. referencedClasses: ["HLDoItRequested", "HLDoItExecuted"]
  292. }),
  293. smalltalk.HLCodeWidget);
  294. smalltalk.addMethod(
  295. "_editor",
  296. smalltalk.method({
  297. selector: "editor",
  298. category: 'actions',
  299. fn: function () {
  300. var self = this;
  301. return self['@editor'];
  302. },
  303. args: [],
  304. source: "editor\x0a\x09^editor",
  305. messageSends: [],
  306. referencedClasses: []
  307. }),
  308. smalltalk.HLCodeWidget);
  309. smalltalk.addMethod(
  310. "_focus",
  311. smalltalk.method({
  312. selector: "focus",
  313. category: 'actions',
  314. fn: function () {
  315. var self = this;
  316. smalltalk.send(smalltalk.send(self, "_editor", []), "_focus", []);
  317. return self;
  318. },
  319. args: [],
  320. source: "focus\x0a self editor focus",
  321. messageSends: ["focus", "editor"],
  322. referencedClasses: []
  323. }),
  324. smalltalk.HLCodeWidget);
  325. smalltalk.addMethod(
  326. "_inspectIt",
  327. smalltalk.method({
  328. selector: "inspectIt",
  329. category: 'actions',
  330. fn: function () {
  331. var self = this;
  332. var newInspector;
  333. smalltalk.send(smalltalk.send(self, "_announcer", []), "_announce_", [smalltalk.send(smalltalk.HLInspectItRequested || HLInspectItRequested, "_on_", [self['@model']])]);
  334. newInspector = smalltalk.send(self, "_makeInspectorOn_", [smalltalk.send(self, "_doIt", [])]);
  335. smalltalk.send(newInspector, "_open", []);
  336. return self;
  337. },
  338. args: [],
  339. source: "inspectIt\x0a\x0a\x09| newInspector |\x0a \x0a\x09self announcer announce: (HLInspectItRequested on: model).\x0a\x09newInspector := self makeInspectorOn: self doIt.\x0a\x09newInspector open",
  340. messageSends: ["announce:", "on:", "announcer", "makeInspectorOn:", "doIt", "open"],
  341. referencedClasses: ["HLInspectItRequested"]
  342. }),
  343. smalltalk.HLCodeWidget);
  344. smalltalk.addMethod(
  345. "_makeInspectorOn_",
  346. smalltalk.method({
  347. selector: "makeInspectorOn:",
  348. category: 'actions',
  349. fn: function (anObject) {
  350. var self = this;
  351. var $2, $3, $1;
  352. $2 = smalltalk.send(smalltalk.HLInspector || HLInspector, "_new", []);
  353. smalltalk.send($2, "_inspect_", [anObject]);
  354. $3 = smalltalk.send($2, "_yourself", []);
  355. $1 = $3;
  356. return $1;
  357. },
  358. args: ["anObject"],
  359. source: "makeInspectorOn: anObject\x0a\x0a\x09^ HLInspector new \x0a\x09\x09inspect: anObject;\x0a\x09\x09yourself",
  360. messageSends: ["inspect:", "new", "yourself"],
  361. referencedClasses: ["HLInspector"]
  362. }),
  363. smalltalk.HLCodeWidget);
  364. smalltalk.addMethod(
  365. "_model",
  366. smalltalk.method({
  367. selector: "model",
  368. category: 'accessing',
  369. fn: function () {
  370. var self = this;
  371. var $1;
  372. if (($receiver = self['@model']) == nil || $receiver == undefined) {
  373. smalltalk.send(self, "_model_", [smalltalk.send(smalltalk.HLCodeModel || HLCodeModel, "_new", [])]);
  374. $1 = self['@model'];
  375. } else {
  376. $1 = self['@model'];
  377. }
  378. return $1;
  379. },
  380. args: [],
  381. source: "model\x0a\x09^ model ifNil: [ \x0a \x09self model: HLCodeModel new.\x0a\x09\x09model ]",
  382. messageSends: ["ifNil:", "model:", "new"],
  383. referencedClasses: ["HLCodeModel"]
  384. }),
  385. smalltalk.HLCodeWidget);
  386. smalltalk.addMethod(
  387. "_model_",
  388. smalltalk.method({
  389. selector: "model:",
  390. category: 'accessing',
  391. fn: function (aModel){
  392. var self=this;
  393. self["@model"]=aModel;
  394. return self},
  395. args: ["aModel"],
  396. source: "model: aModel\x0a\x09model := aModel",
  397. messageSends: [],
  398. referencedClasses: []
  399. }),
  400. smalltalk.HLCodeWidget);
  401. smalltalk.addMethod(
  402. "_observeWrapper",
  403. smalltalk.method({
  404. selector: "observeWrapper",
  405. category: 'actions',
  406. fn: function () {
  407. var self = this;
  408. smalltalk.send(self['@wrapper'], "_onKeyDown_", [function (e) {return smalltalk.send(self, "_onKeyDown_", [e]);}]);
  409. return self;
  410. },
  411. args: [],
  412. source: "observeWrapper\x0a\x0a wrapper onKeyDown: [ :e | self onKeyDown: e ]\x0a",
  413. messageSends: ["onKeyDown:"],
  414. referencedClasses: []
  415. }),
  416. smalltalk.HLCodeWidget);
  417. smalltalk.addMethod(
  418. "_onDoIt",
  419. smalltalk.method({
  420. selector: "onDoIt",
  421. category: 'reactions',
  422. fn: function () {
  423. var self = this;
  424. smalltalk.send(self, "_doIt", []);
  425. return self;
  426. },
  427. args: [],
  428. source: "onDoIt\x0a\x09\x0a self doIt",
  429. messageSends: ["doIt"],
  430. referencedClasses: []
  431. }),
  432. smalltalk.HLCodeWidget);
  433. smalltalk.addMethod(
  434. "_onInspectIt",
  435. smalltalk.method({
  436. selector: "onInspectIt",
  437. category: 'reactions',
  438. fn: function () {
  439. var self = this;
  440. smalltalk.send(self, "_inspectIt", []);
  441. return self;
  442. },
  443. args: [],
  444. source: "onInspectIt\x0a\x0a\x09self inspectIt",
  445. messageSends: ["inspectIt"],
  446. referencedClasses: []
  447. }),
  448. smalltalk.HLCodeWidget);
  449. smalltalk.addMethod(
  450. "_onKeyDown_",
  451. smalltalk.method({
  452. selector: "onKeyDown:",
  453. category: 'reactions',
  454. fn: function (anEvent) {
  455. var self = this;
  456. if (anEvent.ctrlKey) {
  457. if (anEvent.keyCode === 80) {
  458. self._onPrintIt();
  459. anEvent.preventDefault();
  460. return false;
  461. }
  462. if (anEvent.keyCode === 68) {
  463. self._onDoIt();
  464. anEvent.preventDefault();
  465. return false;
  466. }
  467. if (anEvent.keyCode === 73) {
  468. self._onInspectIt();
  469. anEvent.preventDefault();
  470. return false;
  471. }
  472. }
  473. return self;
  474. },
  475. args: ["anEvent"],
  476. source: "onKeyDown: anEvent\x0a\x0a <if(anEvent.ctrlKey) {\x0a\x09\x09if(anEvent.keyCode === 80) { //ctrl+p\x0a\x09\x09\x09self._onPrintIt();\x0a\x09\x09\x09anEvent.preventDefault();\x0a\x09\x09\x09return false;\x0a\x09\x09}\x0a\x09\x09if(anEvent.keyCode === 68) { //ctrl+d\x0a\x09\x09\x09self._onDoIt();\x0a\x09\x09\x09anEvent.preventDefault();\x0a\x09\x09\x09return false;\x0a\x09\x09}\x0a\x09\x09if(anEvent.keyCode === 73) { //ctrl+i\x0a\x09\x09\x09self._onInspectIt();\x0a\x09\x09\x09anEvent.preventDefault();\x0a\x09\x09\x09return false;\x0a\x09\x09}\x0a\x09}>\x09",
  477. messageSends: [],
  478. referencedClasses: []
  479. }),
  480. smalltalk.HLCodeWidget);
  481. smalltalk.addMethod(
  482. "_onPrintIt",
  483. smalltalk.method({
  484. selector: "onPrintIt",
  485. category: 'reactions',
  486. fn: function () {
  487. var self = this;
  488. smalltalk.send(self, "_printIt", []);
  489. return self;
  490. },
  491. args: [],
  492. source: "onPrintIt\x0a\x0a\x09self printIt",
  493. messageSends: ["printIt"],
  494. referencedClasses: []
  495. }),
  496. smalltalk.HLCodeWidget);
  497. smalltalk.addMethod(
  498. "_print_",
  499. smalltalk.method({
  500. selector: "print:",
  501. category: 'actions',
  502. fn: function (aString) {
  503. var self = this;
  504. var start;
  505. var stop;
  506. start = smalltalk.send(smalltalk.HashedCollection || HashedCollection, "_new", []);
  507. stop = smalltalk.send(smalltalk.HashedCollection || HashedCollection, "_new", []);
  508. smalltalk.send(start, "_at_put_", ["line", smalltalk.send(smalltalk.send(self['@editor'], "_getCursor_", [false]), "_line", [])]);
  509. smalltalk.send(start, "_at_put_", ["ch", smalltalk.send(smalltalk.send(self['@editor'], "_getCursor_", [false]), "_ch", [])]);
  510. smalltalk.send(stop, "_at_put_", ["line", smalltalk.send(start, "_at_", ["line"])]);
  511. smalltalk.send(stop, "_at_put_", ["ch", smalltalk.send(smalltalk.send(smalltalk.send(start, "_at_", ["ch"]), "__plus", [smalltalk.send(aString, "_size", [])]), "__plus", [2])]);
  512. smalltalk.send(self['@editor'], "_replaceSelection_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self['@editor'], "_getSelection", []), "__comma", [" "]), "__comma", [aString]), "__comma", [" "])]);
  513. smalltalk.send(self['@editor'], "_setCursor_", [smalltalk.send(self['@editor'], "_getCursor_", [true])]);
  514. smalltalk.send(self['@editor'], "_setSelection_end_", [stop, start]);
  515. return self;
  516. },
  517. args: ["aString"],
  518. source: "print: aString\x0a\x09| start stop |\x0a\x09start := HashedCollection new.\x0a\x09stop := HashedCollection new.\x0a\x09start at: 'line' put: (editor getCursor: false) line.\x0a\x09start at: 'ch' put: (editor getCursor: false) ch.\x0a\x09stop at: 'line' put: (start at: 'line').\x0a\x09stop at: 'ch' put: ((start at: 'ch') + aString size + 2).\x0a\x09editor replaceSelection: (editor getSelection, ' ', aString, ' ').\x0a\x09editor setCursor: (editor getCursor: true).\x0a\x09editor setSelection: stop end: start",
  519. messageSends: ["new", "at:put:", "line", "getCursor:", "ch", "at:", "+", "size", "replaceSelection:", ",", "getSelection", "setCursor:", "setSelection:end:"],
  520. referencedClasses: ["HashedCollection"]
  521. }),
  522. smalltalk.HLCodeWidget);
  523. smalltalk.addMethod(
  524. "_printIt",
  525. smalltalk.method({
  526. selector: "printIt",
  527. category: 'actions',
  528. fn: function () {
  529. var self = this;
  530. var result;
  531. result = smalltalk.send(self, "_doIt", []);
  532. smalltalk.send(smalltalk.send(self, "_announcer", []), "_announce_", [smalltalk.send(smalltalk.HLPrintItRequested || HLPrintItRequested, "_on_", [self['@model']])]);
  533. smalltalk.send(self, "_print_", [smalltalk.send(result, "_printString", [])]);
  534. smalltalk.send(self, "_focus", []);
  535. return self;
  536. },
  537. args: [],
  538. source: "printIt\x0a\x0a\x09| result |\x0a\x0a\x09result:= self doIt.\x0a \x0a\x09self announcer announce: (HLPrintItRequested on: model).\x0a\x0a self print: result printString.\x0a\x09self focus.",
  539. messageSends: ["doIt", "announce:", "on:", "announcer", "print:", "printString", "focus"],
  540. referencedClasses: ["HLPrintItRequested"]
  541. }),
  542. smalltalk.HLCodeWidget);
  543. smalltalk.addMethod(
  544. "_receiver",
  545. smalltalk.method({
  546. selector: "receiver",
  547. category: 'accessing',
  548. fn: function () {
  549. var self = this;
  550. var $1;
  551. $1 = smalltalk.send(smalltalk.send(self, "_model", []), "_receiver", []);
  552. return $1;
  553. },
  554. args: [],
  555. source: "receiver\x0a\x09^ self model receiver",
  556. messageSends: ["receiver", "model"],
  557. referencedClasses: []
  558. }),
  559. smalltalk.HLCodeWidget);
  560. smalltalk.addMethod(
  561. "_receiver_",
  562. smalltalk.method({
  563. selector: "receiver:",
  564. category: 'accessing',
  565. fn: function (anObject) {
  566. var self = this;
  567. smalltalk.send(smalltalk.send(self, "_model", []), "_receiver_", [anObject]);
  568. return self;
  569. },
  570. args: ["anObject"],
  571. source: "receiver: anObject\x0a\x09self model receiver: anObject",
  572. messageSends: ["receiver:", "model"],
  573. referencedClasses: []
  574. }),
  575. smalltalk.HLCodeWidget);
  576. smalltalk.addMethod(
  577. "_renderContentOn_",
  578. smalltalk.method({
  579. selector: "renderContentOn:",
  580. category: 'rendering',
  581. fn: function (html){
  582. var self=this;
  583. self["@code"]=smalltalk.send(html,"_textarea",[]);
  584. smalltalk.send(self,"_setEditorOn_",[smalltalk.send(self["@code"],"_element",[])]);
  585. smalltalk.send(self,"_observeWrapper",[]);
  586. return self},
  587. args: ["html"],
  588. source: "renderContentOn: html\x0a code := html textarea.\x0a self setEditorOn: code element.\x0a \x0a self observeWrapper",
  589. messageSends: ["textarea", "setEditorOn:", "element", "observeWrapper"],
  590. referencedClasses: []
  591. }),
  592. smalltalk.HLCodeWidget);
  593. smalltalk.addMethod(
  594. "_selection",
  595. smalltalk.method({
  596. selector: "selection",
  597. category: 'accessing',
  598. fn: function () {
  599. var self = this;
  600. var $1;
  601. $1 = smalltalk.send(self['@editor'], "_getSelection", []);
  602. return $1;
  603. },
  604. args: [],
  605. source: "selection\x0a\x09^editor getSelection",
  606. messageSends: ["getSelection"],
  607. referencedClasses: []
  608. }),
  609. smalltalk.HLCodeWidget);
  610. smalltalk.addMethod(
  611. "_selectionEnd",
  612. smalltalk.method({
  613. selector: "selectionEnd",
  614. category: 'accessing',
  615. fn: function () {
  616. var self = this;
  617. var $1;
  618. $1 = smalltalk.send(smalltalk.send(self['@code'], "_element", []), "_selectionEnd", []);
  619. return $1;
  620. },
  621. args: [],
  622. source: "selectionEnd\x0a ^code element selectionEnd",
  623. messageSends: ["selectionEnd", "element"],
  624. referencedClasses: []
  625. }),
  626. smalltalk.HLCodeWidget);
  627. smalltalk.addMethod(
  628. "_selectionEnd_",
  629. smalltalk.method({
  630. selector: "selectionEnd:",
  631. category: 'accessing',
  632. fn: function (anInteger) {
  633. var self = this;
  634. smalltalk.send(smalltalk.send(self['@code'], "_element", []), "_selectionEnd_", [anInteger]);
  635. return self;
  636. },
  637. args: ["anInteger"],
  638. source: "selectionEnd: anInteger\x0a code element selectionEnd: anInteger",
  639. messageSends: ["selectionEnd:", "element"],
  640. referencedClasses: []
  641. }),
  642. smalltalk.HLCodeWidget);
  643. smalltalk.addMethod(
  644. "_selectionStart",
  645. smalltalk.method({
  646. selector: "selectionStart",
  647. category: 'accessing',
  648. fn: function () {
  649. var self = this;
  650. var $1;
  651. $1 = smalltalk.send(smalltalk.send(self['@code'], "_element", []), "_selectionStart", []);
  652. return $1;
  653. },
  654. args: [],
  655. source: "selectionStart\x0a ^code element selectionStart",
  656. messageSends: ["selectionStart", "element"],
  657. referencedClasses: []
  658. }),
  659. smalltalk.HLCodeWidget);
  660. smalltalk.addMethod(
  661. "_selectionStart_",
  662. smalltalk.method({
  663. selector: "selectionStart:",
  664. category: 'accessing',
  665. fn: function (anInteger) {
  666. var self = this;
  667. smalltalk.send(smalltalk.send(self['@code'], "_element", []), "_selectionStart_", [anInteger]);
  668. return self;
  669. },
  670. args: ["anInteger"],
  671. source: "selectionStart: anInteger\x0a code element selectionStart: anInteger",
  672. messageSends: ["selectionStart:", "element"],
  673. referencedClasses: []
  674. }),
  675. smalltalk.HLCodeWidget);
  676. smalltalk.addMethod(
  677. "_setEditorOn_",
  678. smalltalk.method({
  679. selector: "setEditorOn:",
  680. category: 'actions',
  681. fn: function (aTextarea) {
  682. var self = this;
  683. self['@editor'] = CodeMirror.fromTextArea(aTextarea, {theme: "amber", lineNumbers: true, enterMode: "flat", matchBrackets: true, electricChars: false});
  684. return self;
  685. },
  686. args: ["aTextarea"],
  687. source: "setEditorOn: aTextarea\x0a\x09<self['@editor'] = CodeMirror.fromTextArea(aTextarea, {\x0a\x09\x09theme: 'amber',\x0a lineNumbers: true,\x0a enterMode: 'flat',\x0a matchBrackets: true,\x0a electricChars: false\x0a\x09})>",
  688. messageSends: [],
  689. referencedClasses: []
  690. }),
  691. smalltalk.HLCodeWidget);
  692. smalltalk.addClass('HLWorkspace', smalltalk.HLWidget, ['model', 'codeWidget'], 'Helios-Workspace');
  693. smalltalk.addMethod(
  694. "_codeWidget",
  695. smalltalk.method({
  696. selector: "codeWidget",
  697. category: 'accessing',
  698. fn: function () {
  699. var self = this;
  700. var $2, $3, $1;
  701. if (($receiver = self['@codeWidget']) == nil || $receiver == undefined) {
  702. $2 = smalltalk.send(smalltalk.HLCodeWidget || HLCodeWidget, "_new", []);
  703. smalltalk.send($2, "_model_", [smalltalk.send(smalltalk.send(self, "_model", []), "_code", [])]);
  704. $3 = smalltalk.send($2, "_yourself", []);
  705. self['@codeWidget'] = $3;
  706. $1 = self['@codeWidget'];
  707. } else {
  708. $1 = self['@codeWidget'];
  709. }
  710. return $1;
  711. },
  712. args: [],
  713. source: "codeWidget\x0a\x09^ codeWidget ifNil: [\x0a\x09\x09codeWidget := HLCodeWidget new\x0a \x09\x09model: self model code;\x0a \x09yourself ]",
  714. messageSends: ["ifNil:", "model:", "code", "model", "new", "yourself"],
  715. referencedClasses: ["HLCodeWidget"]
  716. }),
  717. smalltalk.HLWorkspace);
  718. smalltalk.addMethod(
  719. "_model",
  720. smalltalk.method({
  721. selector: "model",
  722. category: 'accessing',
  723. fn: function () {
  724. var self = this;
  725. var $1;
  726. if (($receiver = self['@model']) == nil || $receiver == undefined) {
  727. smalltalk.send(self, "_model_", [smalltalk.send(smalltalk.HLWorkspaceModel || HLWorkspaceModel, "_new", [])]);
  728. $1 = self['@model'];
  729. } else {
  730. $1 = self['@model'];
  731. }
  732. return $1;
  733. },
  734. args: [],
  735. source: "model\x0a\x09^ model ifNil: [ \x0a \x09self model: HLWorkspaceModel new.\x0a\x09\x09model ]",
  736. messageSends: ["ifNil:", "model:", "new"],
  737. referencedClasses: ["HLWorkspaceModel"]
  738. }),
  739. smalltalk.HLWorkspace);
  740. smalltalk.addMethod(
  741. "_model_",
  742. smalltalk.method({
  743. selector: "model:",
  744. category: 'accessing',
  745. fn: function (aModel) {
  746. var self = this;
  747. self['@model'] = aModel;
  748. smalltalk.send(smalltalk.send(self, "_codeWidget", []), "_model_", [smalltalk.send(aModel, "_code", [])]);
  749. smalltalk.send(self, "_observeCodeWidget", []);
  750. return self;
  751. },
  752. args: ["aModel"],
  753. source: "model: aModel\x0a\x09model := aModel.\x0a \x0a self codeWidget model: aModel code.\x0a self observeCodeWidget.\x0a ",
  754. messageSends: ["model:", "code", "codeWidget", "observeCodeWidget"],
  755. referencedClasses: []
  756. }),
  757. smalltalk.HLWorkspace);
  758. smalltalk.addMethod(
  759. "_observeCodeWidget",
  760. smalltalk.method({
  761. selector: "observeCodeWidget",
  762. category: 'actions',
  763. fn: function () {
  764. var self = this;
  765. return self;
  766. },
  767. args: [],
  768. source: "observeCodeWidget\x0a\x0a",
  769. messageSends: [],
  770. referencedClasses: []
  771. }),
  772. smalltalk.HLWorkspace);
  773. smalltalk.addMethod(
  774. "_onDoIt",
  775. smalltalk.method({
  776. selector: "onDoIt",
  777. category: 'reactions',
  778. fn: function () {
  779. var self = this;
  780. return self;
  781. },
  782. args: [],
  783. source: "onDoIt",
  784. messageSends: [],
  785. referencedClasses: []
  786. }),
  787. smalltalk.HLWorkspace);
  788. smalltalk.addMethod(
  789. "_onInspectIt",
  790. smalltalk.method({
  791. selector: "onInspectIt",
  792. category: 'reactions',
  793. fn: function () {
  794. var self = this;
  795. return self;
  796. },
  797. args: [],
  798. source: "onInspectIt",
  799. messageSends: [],
  800. referencedClasses: []
  801. }),
  802. smalltalk.HLWorkspace);
  803. smalltalk.addMethod(
  804. "_onPrintIt",
  805. smalltalk.method({
  806. selector: "onPrintIt",
  807. category: 'reactions',
  808. fn: function () {
  809. var self = this;
  810. return self;
  811. },
  812. args: [],
  813. source: "onPrintIt",
  814. messageSends: [],
  815. referencedClasses: []
  816. }),
  817. smalltalk.HLWorkspace);
  818. smalltalk.addMethod(
  819. "_renderContentOn_",
  820. smalltalk.method({
  821. selector: "renderContentOn:",
  822. category: 'rendering',
  823. fn: function (html) {
  824. var self = this;
  825. smalltalk.send(html, "_with_", [smalltalk.send(self, "_codeWidget", [])]);
  826. return self;
  827. },
  828. args: ["html"],
  829. source: "renderContentOn: html\x0a\x09html with: self codeWidget\x0a ",
  830. messageSends: ["with:", "codeWidget"],
  831. referencedClasses: []
  832. }),
  833. smalltalk.HLWorkspace);
  834. smalltalk.addMethod(
  835. "_canBeOpenAsTab",
  836. smalltalk.method({
  837. selector: "canBeOpenAsTab",
  838. category: 'testing',
  839. fn: function () {
  840. var self = this;
  841. return true;
  842. },
  843. args: [],
  844. source: "canBeOpenAsTab\x0a\x09^ true",
  845. messageSends: [],
  846. referencedClasses: []
  847. }),
  848. smalltalk.HLWorkspace.klass);
  849. smalltalk.addMethod(
  850. "_tabLabel",
  851. smalltalk.method({
  852. selector: "tabLabel",
  853. category: 'accessing',
  854. fn: function () {
  855. var self = this;
  856. return "Workspace";
  857. },
  858. args: [],
  859. source: "tabLabel\x0a\x09^ 'Workspace'",
  860. messageSends: [],
  861. referencedClasses: []
  862. }),
  863. smalltalk.HLWorkspace.klass);
  864. smalltalk.addMethod(
  865. "_tabPriority",
  866. smalltalk.method({
  867. selector: "tabPriority",
  868. category: 'accessing',
  869. fn: function () {
  870. var self = this;
  871. return 10;
  872. },
  873. args: [],
  874. source: "tabPriority\x0a\x09^ 10",
  875. messageSends: [],
  876. referencedClasses: []
  877. }),
  878. smalltalk.HLWorkspace.klass);
  879. smalltalk.addClass('HLWorkspaceModel', smalltalk.Object, ['announcer', 'environment', 'code'], 'Helios-Workspace');
  880. smalltalk.addMethod(
  881. "_announcer",
  882. smalltalk.method({
  883. selector: "announcer",
  884. category: 'accessing',
  885. fn: function () {
  886. var self = this;
  887. var $1;
  888. if (($receiver = self['@announcer']) == nil || $receiver == undefined) {
  889. self['@announcer'] = smalltalk.send(smalltalk.Announcer || Announcer, "_new", []);
  890. $1 = self['@announcer'];
  891. } else {
  892. $1 = self['@announcer'];
  893. }
  894. return $1;
  895. },
  896. args: [],
  897. source: "announcer\x0a\x09^ announcer ifNil: [ announcer := Announcer new ]",
  898. messageSends: ["ifNil:", "new"],
  899. referencedClasses: ["Announcer"]
  900. }),
  901. smalltalk.HLWorkspaceModel);
  902. smalltalk.addMethod(
  903. "_code",
  904. smalltalk.method({
  905. selector: "code",
  906. category: 'accessing',
  907. fn: function () {
  908. var self = this;
  909. var $1;
  910. if (($receiver = self['@code']) == nil || $receiver == undefined) {
  911. $1 = smalltalk.send(smalltalk.HLCodeModel || HLCodeModel, "_on_", [smalltalk.send(self, "_environment", [])]);
  912. } else {
  913. $1 = self['@code'];
  914. }
  915. return $1;
  916. },
  917. args: [],
  918. source: "code\x0a\x09\x22Answers the code model working for this workspace model\x22\x0a\x09^ code ifNil:[ HLCodeModel on: self environment ]",
  919. messageSends: ["ifNil:", "on:", "environment"],
  920. referencedClasses: ["HLCodeModel"]
  921. }),
  922. smalltalk.HLWorkspaceModel);
  923. smalltalk.addMethod(
  924. "_environment",
  925. smalltalk.method({
  926. selector: "environment",
  927. category: 'accessing',
  928. fn: function () {
  929. var self = this;
  930. var $1;
  931. if (($receiver = self['@environment']) == nil || $receiver == undefined) {
  932. $1 = smalltalk.send(smalltalk.send(smalltalk.HLManager || HLManager, "_current", []), "_environment", []);
  933. } else {
  934. $1 = self['@environment'];
  935. }
  936. return $1;
  937. },
  938. args: [],
  939. source: "environment\x0a\x09^ environment ifNil: [ HLManager current environment ]",
  940. messageSends: ["ifNil:", "environment", "current"],
  941. referencedClasses: ["HLManager"]
  942. }),
  943. smalltalk.HLWorkspaceModel);
  944. smalltalk.addMethod(
  945. "_environment_",
  946. smalltalk.method({
  947. selector: "environment:",
  948. category: 'accessing',
  949. fn: function (anEnvironment) {
  950. var self = this;
  951. self['@environment'] = anEnvironment;
  952. return self;
  953. },
  954. args: ["anEnvironment"],
  955. source: "environment: anEnvironment\x0a\x09environment := anEnvironment",
  956. messageSends: [],
  957. referencedClasses: []
  958. }),
  959. smalltalk.HLWorkspaceModel);
  960. smalltalk.addMethod(
  961. "_onKeyDown_",
  962. smalltalk.method({
  963. selector: "onKeyDown:",
  964. category: 'reactions',
  965. fn: function (anEvent) {
  966. var self = this;
  967. if (anEvent.ctrlKey) {
  968. if (anEvent.keyCode === 80) {
  969. self._printIt();
  970. anEvent.preventDefault();
  971. return false;
  972. }
  973. if (anEvent.keyCode === 68) {
  974. self._doIt();
  975. anEvent.preventDefault();
  976. return false;
  977. }
  978. if (anEvent.keyCode === 73) {
  979. self._inspectIt();
  980. anEvent.preventDefault();
  981. return false;
  982. }
  983. }
  984. return self;
  985. },
  986. args: ["anEvent"],
  987. source: "onKeyDown: anEvent\x0a\x0a\x09<if(anEvent.ctrlKey) {\x0a\x09\x09if(anEvent.keyCode === 80) { //ctrl+p\x0a\x09\x09\x09self._printIt();\x0a\x09\x09\x09anEvent.preventDefault();\x0a\x09\x09\x09return false;\x0a\x09\x09}\x0a\x09\x09if(anEvent.keyCode === 68) { //ctrl+d\x0a\x09\x09\x09self._doIt();\x0a\x09\x09\x09anEvent.preventDefault();\x0a\x09\x09\x09return false;\x0a\x09\x09}\x0a\x09\x09if(anEvent.keyCode === 73) { //ctrl+i\x0a\x09\x09\x09self._inspectIt();\x0a\x09\x09\x09anEvent.preventDefault();\x0a\x09\x09\x09return false;\x0a\x09\x09}\x0a\x09}>",
  988. messageSends: [],
  989. referencedClasses: []
  990. }),
  991. smalltalk.HLWorkspaceModel);
  992. smalltalk.addMethod(
  993. "_on_",
  994. smalltalk.method({
  995. selector: "on:",
  996. category: 'actions',
  997. fn: function (anEnvironment) {
  998. var self = this;
  999. var $2, $3, $1;
  1000. $2 = smalltalk.send(self, "_new", []);
  1001. smalltalk.send($2, "_environment_", [anEnvironment]);
  1002. $3 = smalltalk.send($2, "_yourself", []);
  1003. $1 = $3;
  1004. return $1;
  1005. },
  1006. args: ["anEnvironment"],
  1007. source: "on: anEnvironment\x0a\x0a\x09^ self new\x0a \x09environment: anEnvironment;\x0a yourself",
  1008. messageSends: ["environment:", "new", "yourself"],
  1009. referencedClasses: []
  1010. }),
  1011. smalltalk.HLWorkspaceModel.klass);