Helios-KeyBindings.js 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320
  1. smalltalk.addPackage('Helios-KeyBindings');
  2. smalltalk.addClass('HLBinding', smalltalk.Object, ['key', 'label'], 'Helios-KeyBindings');
  3. smalltalk.addMethod(
  4. "_applyOn_",
  5. smalltalk.method({
  6. selector: "applyOn:",
  7. category: 'actions',
  8. fn: function (aKeyBinder){
  9. var self=this;
  10. return smalltalk.withContext(function($ctx1) { _st(self)._subclassResponsibility();
  11. return self}, function($ctx1) {$ctx1.fill(self,"applyOn:",{aKeyBinder:aKeyBinder}, smalltalk.HLBinding)})},
  12. args: ["aKeyBinder"],
  13. source: "applyOn: aKeyBinder\x0a\x09self subclassResponsibility",
  14. messageSends: ["subclassResponsibility"],
  15. referencedClasses: []
  16. }),
  17. smalltalk.HLBinding);
  18. smalltalk.addMethod(
  19. "_displayLabel",
  20. smalltalk.method({
  21. selector: "displayLabel",
  22. category: 'accessing',
  23. fn: function (){
  24. var self=this;
  25. return smalltalk.withContext(function($ctx1) { var $1;
  26. $1=_st(self)._label();
  27. return $1;
  28. }, function($ctx1) {$ctx1.fill(self,"displayLabel",{}, smalltalk.HLBinding)})},
  29. args: [],
  30. source: "displayLabel\x0a\x09^ self label",
  31. messageSends: ["label"],
  32. referencedClasses: []
  33. }),
  34. smalltalk.HLBinding);
  35. smalltalk.addMethod(
  36. "_isActive",
  37. smalltalk.method({
  38. selector: "isActive",
  39. category: 'testing',
  40. fn: function (){
  41. var self=this;
  42. return smalltalk.withContext(function($ctx1) { var $1;
  43. $1=_st(self)._subclassResponsibility();
  44. return $1;
  45. }, function($ctx1) {$ctx1.fill(self,"isActive",{},smalltalk.HLBinding)})},
  46. args: [],
  47. source: "isActive\x0a\x09^ self subclassResponsibility",
  48. messageSends: ["subclassResponsibility"],
  49. referencedClasses: []
  50. }),
  51. smalltalk.HLBinding);
  52. smalltalk.addMethod(
  53. "_isBindingAction",
  54. smalltalk.method({
  55. selector: "isBindingAction",
  56. category: 'testing',
  57. fn: function (){
  58. var self=this;
  59. return smalltalk.withContext(function($ctx1) { return false;
  60. }, function($ctx1) {$ctx1.fill(self,"isBindingAction",{}, smalltalk.HLBinding)})},
  61. args: [],
  62. source: "isBindingAction\x0a\x09^ false",
  63. messageSends: [],
  64. referencedClasses: []
  65. }),
  66. smalltalk.HLBinding);
  67. smalltalk.addMethod(
  68. "_isBindingGroup",
  69. smalltalk.method({
  70. selector: "isBindingGroup",
  71. category: 'testing',
  72. fn: function (){
  73. var self=this;
  74. return smalltalk.withContext(function($ctx1) { return false;
  75. }, function($ctx1) {$ctx1.fill(self,"isBindingGroup",{}, smalltalk.HLBinding)})},
  76. args: [],
  77. source: "isBindingGroup\x0a\x09^ false",
  78. messageSends: [],
  79. referencedClasses: []
  80. }),
  81. smalltalk.HLBinding);
  82. smalltalk.addMethod(
  83. "_key",
  84. smalltalk.method({
  85. selector: "key",
  86. category: 'accessing',
  87. fn: function (){
  88. var self=this;
  89. return smalltalk.withContext(function($ctx1) { var $1;
  90. $1=self["@key"];
  91. return $1;
  92. }, function($ctx1) {$ctx1.fill(self,"key",{}, smalltalk.HLBinding)})},
  93. args: [],
  94. source: "key\x0a\x09^ key",
  95. messageSends: [],
  96. referencedClasses: []
  97. }),
  98. smalltalk.HLBinding);
  99. smalltalk.addMethod(
  100. "_key_",
  101. smalltalk.method({
  102. selector: "key:",
  103. category: 'accessing',
  104. fn: function (anInteger){
  105. var self=this;
  106. return smalltalk.withContext(function($ctx1) { self["@key"]=anInteger;
  107. return self}, function($ctx1) {$ctx1.fill(self,"key:",{anInteger:anInteger}, smalltalk.HLBinding)})},
  108. args: ["anInteger"],
  109. source: "key: anInteger\x0a\x09key := anInteger",
  110. messageSends: [],
  111. referencedClasses: []
  112. }),
  113. smalltalk.HLBinding);
  114. smalltalk.addMethod(
  115. "_label",
  116. smalltalk.method({
  117. selector: "label",
  118. category: 'accessing',
  119. fn: function (){
  120. var self=this;
  121. return smalltalk.withContext(function($ctx1) { var $1;
  122. $1=self["@label"];
  123. return $1;
  124. }, function($ctx1) {$ctx1.fill(self,"label",{}, smalltalk.HLBinding)})},
  125. args: [],
  126. source: "label\x0a\x09^ label",
  127. messageSends: [],
  128. referencedClasses: []
  129. }),
  130. smalltalk.HLBinding);
  131. smalltalk.addMethod(
  132. "_label_",
  133. smalltalk.method({
  134. selector: "label:",
  135. category: 'accessing',
  136. fn: function (aString){
  137. var self=this;
  138. return smalltalk.withContext(function($ctx1) { self["@label"]=aString;
  139. return self}, function($ctx1) {$ctx1.fill(self,"label:",{aString:aString}, smalltalk.HLBinding)})},
  140. args: ["aString"],
  141. source: "label: aString\x0a\x09label := aString",
  142. messageSends: [],
  143. referencedClasses: []
  144. }),
  145. smalltalk.HLBinding);
  146. smalltalk.addMethod(
  147. "_renderOn_html_",
  148. smalltalk.method({
  149. selector: "renderOn:html:",
  150. category: 'rendering',
  151. fn: function (aBindingHelper,html){
  152. var self=this;
  153. return smalltalk.withContext(function($ctx1) { return self}, function($ctx1) {$ctx1.fill(self,"renderOn:html:",{aBindingHelper:aBindingHelper,html:html}, smalltalk.HLBinding)})},
  154. args: ["aBindingHelper", "html"],
  155. source: "renderOn: aBindingHelper html: html",
  156. messageSends: [],
  157. referencedClasses: []
  158. }),
  159. smalltalk.HLBinding);
  160. smalltalk.addMethod(
  161. "_shortcut",
  162. smalltalk.method({
  163. selector: "shortcut",
  164. category: 'accessing',
  165. fn: function (){
  166. var self=this;
  167. return smalltalk.withContext(function($ctx1) { var $1;
  168. $1=_st((smalltalk.String || String))._fromCharCode_(_st(self)._key());
  169. return $1;
  170. }, function($ctx1) {$ctx1.fill(self,"shortcut",{}, smalltalk.HLBinding)})},
  171. args: [],
  172. source: "shortcut\x0a\x09^ String fromCharCode: self key",
  173. messageSends: ["fromCharCode:", "key"],
  174. referencedClasses: ["String"]
  175. }),
  176. smalltalk.HLBinding);
  177. smalltalk.addMethod(
  178. "_on_labelled_",
  179. smalltalk.method({
  180. selector: "on:labelled:",
  181. category: 'instance creation',
  182. fn: function (anInteger,aString){
  183. var self=this;
  184. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  185. $2=_st(self)._new();
  186. _st($2)._key_(anInteger);
  187. _st($2)._label_(aString);
  188. $3=_st($2)._yourself();
  189. $1=$3;
  190. return $1;
  191. }, function($ctx1) {$ctx1.fill(self,"on:labelled:",{anInteger:anInteger,aString:aString}, smalltalk.HLBinding.klass)})},
  192. args: ["anInteger", "aString"],
  193. source: "on: anInteger labelled: aString\x0a\x09^ self new\x0a \x09key: anInteger;\x0a label: aString;\x0a yourself",
  194. messageSends: ["key:", "new", "label:", "yourself"],
  195. referencedClasses: []
  196. }),
  197. smalltalk.HLBinding.klass);
  198. smalltalk.addClass('HLBindingAction', smalltalk.HLBinding, ['callback', 'activeBlock'], 'Helios-KeyBindings');
  199. smalltalk.addMethod(
  200. "_activeBlock",
  201. smalltalk.method({
  202. selector: "activeBlock",
  203. category: 'accessing',
  204. fn: function (){
  205. var self=this;
  206. return smalltalk.withContext(function($ctx1) { var $2,$1;
  207. $2=self["@activeBlock"];
  208. if(($receiver = $2) == nil || $receiver == undefined){
  209. self["@activeBlock"]=(function(){
  210. return smalltalk.withContext(function($ctx2) { return true;
  211. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
  212. $1=self["@activeBlock"];
  213. } else {
  214. $1=$2;
  215. };
  216. return $1;
  217. }, function($ctx1) {$ctx1.fill(self,"activeBlock",{},smalltalk.HLBindingAction)})},
  218. args: [],
  219. source: "activeBlock\x0a\x09^ activeBlock ifNil: [ activeBlock := [ true ] ]",
  220. messageSends: ["ifNil:"],
  221. referencedClasses: []
  222. }),
  223. smalltalk.HLBindingAction);
  224. smalltalk.addMethod(
  225. "_activeBlock_",
  226. smalltalk.method({
  227. selector: "activeBlock:",
  228. category: 'accessing',
  229. fn: function (aBlock){
  230. var self=this;
  231. return smalltalk.withContext(function($ctx1) { self["@activeBlock"]=aBlock;
  232. return self}, function($ctx1) {$ctx1.fill(self,"activeBlock:",{aBlock:aBlock},smalltalk.HLBindingAction)})},
  233. args: ["aBlock"],
  234. source: "activeBlock: aBlock\x0a\x09activeBlock := aBlock",
  235. messageSends: [],
  236. referencedClasses: []
  237. }),
  238. smalltalk.HLBindingAction);
  239. smalltalk.addMethod(
  240. "_applyOn_",
  241. smalltalk.method({
  242. selector: "applyOn:",
  243. category: 'actions',
  244. fn: function (aKeyBinder){
  245. var self=this;
  246. return smalltalk.withContext(function($ctx1) { var $1,$2;
  247. $1=_st(self)._isActive();
  248. if(! smalltalk.assert($1)){
  249. $2=self;
  250. return $2;
  251. };
  252. _st(aKeyBinder)._applyBindingAction_(self);
  253. return self}, function($ctx1) {$ctx1.fill(self,"applyOn:",{aKeyBinder:aKeyBinder},smalltalk.HLBindingAction)})},
  254. args: ["aKeyBinder"],
  255. source: "applyOn: aKeyBinder\x0a\x09self isActive ifFalse: [ ^ self ].\x0a\x09\x0a\x09aKeyBinder applyBindingAction: self",
  256. messageSends: ["ifFalse:", "isActive", "applyBindingAction:"],
  257. referencedClasses: []
  258. }),
  259. smalltalk.HLBindingAction);
  260. smalltalk.addMethod(
  261. "_callback",
  262. smalltalk.method({
  263. selector: "callback",
  264. category: 'accessing',
  265. fn: function (){
  266. var self=this;
  267. return smalltalk.withContext(function($ctx1) { var $1;
  268. $1=self["@callback"];
  269. return $1;
  270. }, function($ctx1) {$ctx1.fill(self,"callback",{}, smalltalk.HLBindingAction)})},
  271. args: [],
  272. source: "callback\x0a\x09^ callback",
  273. messageSends: [],
  274. referencedClasses: []
  275. }),
  276. smalltalk.HLBindingAction);
  277. smalltalk.addMethod(
  278. "_callback_",
  279. smalltalk.method({
  280. selector: "callback:",
  281. category: 'accessing',
  282. fn: function (aBlock){
  283. var self=this;
  284. return smalltalk.withContext(function($ctx1) { self["@callback"]=aBlock;
  285. return self}, function($ctx1) {$ctx1.fill(self,"callback:",{aBlock:aBlock}, smalltalk.HLBindingAction)})},
  286. args: ["aBlock"],
  287. source: "callback: aBlock\x0a\x09callback := aBlock",
  288. messageSends: [],
  289. referencedClasses: []
  290. }),
  291. smalltalk.HLBindingAction);
  292. smalltalk.addMethod(
  293. "_isActive",
  294. smalltalk.method({
  295. selector: "isActive",
  296. category: 'testing',
  297. fn: function (){
  298. var self=this;
  299. return smalltalk.withContext(function($ctx1) { var $1;
  300. $1=_st(_st(self)._activeBlock())._value();
  301. return $1;
  302. }, function($ctx1) {$ctx1.fill(self,"isActive",{},smalltalk.HLBindingAction)})},
  303. args: [],
  304. source: "isActive\x0a\x09^ self activeBlock value",
  305. messageSends: ["value", "activeBlock"],
  306. referencedClasses: []
  307. }),
  308. smalltalk.HLBindingAction);
  309. smalltalk.addMethod(
  310. "_isBindingAction",
  311. smalltalk.method({
  312. selector: "isBindingAction",
  313. category: 'testing',
  314. fn: function (){
  315. var self=this;
  316. return smalltalk.withContext(function($ctx1) { return true;
  317. }, function($ctx1) {$ctx1.fill(self,"isBindingAction",{}, smalltalk.HLBindingAction)})},
  318. args: [],
  319. source: "isBindingAction\x0a\x09^ true",
  320. messageSends: [],
  321. referencedClasses: []
  322. }),
  323. smalltalk.HLBindingAction);
  324. smalltalk.addClass('HLBindingGroup', smalltalk.HLBinding, ['bindings'], 'Helios-KeyBindings');
  325. smalltalk.addMethod(
  326. "_activeBindings",
  327. smalltalk.method({
  328. selector: "activeBindings",
  329. category: 'accessing',
  330. fn: function (){
  331. var self=this;
  332. return smalltalk.withContext(function($ctx1) { var $1;
  333. $1=_st(_st(self)._bindings())._select_((function(each){
  334. return smalltalk.withContext(function($ctx2) { return _st(each)._isActive();
  335. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  336. return $1;
  337. }, function($ctx1) {$ctx1.fill(self,"activeBindings",{},smalltalk.HLBindingGroup)})},
  338. args: [],
  339. source: "activeBindings\x0a\x09^ self bindings select: [ :each | each isActive ]",
  340. messageSends: ["select:", "isActive", "bindings"],
  341. referencedClasses: []
  342. }),
  343. smalltalk.HLBindingGroup);
  344. smalltalk.addMethod(
  345. "_add_",
  346. smalltalk.method({
  347. selector: "add:",
  348. category: 'accessing',
  349. fn: function (aBinding){
  350. var self=this;
  351. return smalltalk.withContext(function($ctx1) { var $1;
  352. $1=_st(_st(self)._bindings())._add_(aBinding);
  353. return $1;
  354. }, function($ctx1) {$ctx1.fill(self,"add:",{aBinding:aBinding}, smalltalk.HLBindingGroup)})},
  355. args: ["aBinding"],
  356. source: "add: aBinding\x0a\x09^ self bindings add: aBinding",
  357. messageSends: ["add:", "bindings"],
  358. referencedClasses: []
  359. }),
  360. smalltalk.HLBindingGroup);
  361. smalltalk.addMethod(
  362. "_addActionKey_labelled_callback_",
  363. smalltalk.method({
  364. selector: "addActionKey:labelled:callback:",
  365. category: 'accessing',
  366. fn: function (anInteger,aString,aBlock){
  367. var self=this;
  368. return smalltalk.withContext(function($ctx1) { var $1,$2;
  369. $1=_st((smalltalk.HLBindingAction || HLBindingAction))._on_labelled_(anInteger,aString);
  370. _st($1)._callback_(aBlock);
  371. $2=_st($1)._yourself();
  372. _st(self)._add_($2);
  373. return self}, function($ctx1) {$ctx1.fill(self,"addActionKey:labelled:callback:",{anInteger:anInteger,aString:aString,aBlock:aBlock}, smalltalk.HLBindingGroup)})},
  374. args: ["anInteger", "aString", "aBlock"],
  375. source: "addActionKey: anInteger labelled: aString callback: aBlock\x0a\x09self add: ((HLBindingAction on: anInteger labelled: aString)\x0a \x09callback: aBlock;\x0a yourself)",
  376. messageSends: ["add:", "callback:", "on:labelled:", "yourself"],
  377. referencedClasses: ["HLBindingAction"]
  378. }),
  379. smalltalk.HLBindingGroup);
  380. smalltalk.addMethod(
  381. "_addActionKey_labelled_command_",
  382. smalltalk.method({
  383. selector: "addActionKey:labelled:command:",
  384. category: 'accessing',
  385. fn: function (anInteger,aString,aCommand){
  386. var self=this;
  387. return smalltalk.withContext(function($ctx1) { var $1,$2;
  388. $1=_st((smalltalk.HLBindingAction || HLBindingAction))._on_labelled_(anInteger,aString);
  389. _st($1)._command_(aCommand);
  390. $2=_st($1)._yourself();
  391. _st(self)._add_($2);
  392. return self}, function($ctx1) {$ctx1.fill(self,"addActionKey:labelled:command:",{anInteger:anInteger,aString:aString,aCommand:aCommand}, smalltalk.HLBindingGroup)})},
  393. args: ["anInteger", "aString", "aCommand"],
  394. source: "addActionKey: anInteger labelled: aString command: aCommand\x0a\x09self add: ((HLBindingAction on: anInteger labelled: aString)\x0a \x09command: aCommand;\x0a yourself)",
  395. messageSends: ["add:", "command:", "on:labelled:", "yourself"],
  396. referencedClasses: ["HLBindingAction"]
  397. }),
  398. smalltalk.HLBindingGroup);
  399. smalltalk.addMethod(
  400. "_addGroupKey_labelled_",
  401. smalltalk.method({
  402. selector: "addGroupKey:labelled:",
  403. category: 'accessing',
  404. fn: function (anInteger,aString){
  405. var self=this;
  406. return smalltalk.withContext(function($ctx1) { _st(self)._add_(_st((smalltalk.HLBindingGroup || HLBindingGroup))._on_labelled_(anInteger,aString));
  407. return self}, function($ctx1) {$ctx1.fill(self,"addGroupKey:labelled:",{anInteger:anInteger,aString:aString}, smalltalk.HLBindingGroup)})},
  408. args: ["anInteger", "aString"],
  409. source: "addGroupKey: anInteger labelled: aString\x0a\x09self add: (HLBindingGroup on: anInteger labelled: aString)",
  410. messageSends: ["add:", "on:labelled:"],
  411. referencedClasses: ["HLBindingGroup"]
  412. }),
  413. smalltalk.HLBindingGroup);
  414. smalltalk.addMethod(
  415. "_applyOn_",
  416. smalltalk.method({
  417. selector: "applyOn:",
  418. category: 'actions',
  419. fn: function (aKeyBinder){
  420. var self=this;
  421. return smalltalk.withContext(function($ctx1) { var $1,$2;
  422. $1=_st(self)._isActive();
  423. if(! smalltalk.assert($1)){
  424. $2=self;
  425. return $2;
  426. };
  427. _st(aKeyBinder)._applyBindingGroup_(self);
  428. return self}, function($ctx1) {$ctx1.fill(self,"applyOn:",{aKeyBinder:aKeyBinder},smalltalk.HLBindingGroup)})},
  429. args: ["aKeyBinder"],
  430. source: "applyOn: aKeyBinder\x0a\x09self isActive ifFalse: [ ^ self ].\x0a\x09\x0a\x09aKeyBinder applyBindingGroup: self",
  431. messageSends: ["ifFalse:", "isActive", "applyBindingGroup:"],
  432. referencedClasses: []
  433. }),
  434. smalltalk.HLBindingGroup);
  435. smalltalk.addMethod(
  436. "_at_",
  437. smalltalk.method({
  438. selector: "at:",
  439. category: 'accessing',
  440. fn: function (aString){
  441. var self=this;
  442. return smalltalk.withContext(function($ctx1) { var $1;
  443. $1=_st(_st(self)._bindings())._detect_ifNone_((function(each){
  444. return smalltalk.withContext(function($ctx2) { return _st(_st(each)._label()).__eq(aString);
  445. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  446. return smalltalk.withContext(function($ctx2) { return nil;
  447. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  448. return $1;
  449. }, function($ctx1) {$ctx1.fill(self,"at:",{aString:aString}, smalltalk.HLBindingGroup)})},
  450. args: ["aString"],
  451. source: "at: aString\x0a\x09^ self bindings \x0a \x09detect: [ :each | each label = aString ]\x0a \x09ifNone: [ nil ]",
  452. messageSends: ["detect:ifNone:", "=", "label", "bindings"],
  453. referencedClasses: []
  454. }),
  455. smalltalk.HLBindingGroup);
  456. smalltalk.addMethod(
  457. "_at_add_",
  458. smalltalk.method({
  459. selector: "at:add:",
  460. category: 'accessing',
  461. fn: function (aString,aBinding){
  462. var self=this;
  463. var binding;
  464. return smalltalk.withContext(function($ctx1) { var $1,$2;
  465. binding=_st(self)._at_(aString);
  466. $1=binding;
  467. if(($receiver = $1) == nil || $receiver == undefined){
  468. $2=self;
  469. return $2;
  470. } else {
  471. $1;
  472. };
  473. _st(binding)._add_(aBinding);
  474. return self}, function($ctx1) {$ctx1.fill(self,"at:add:",{aString:aString,aBinding:aBinding,binding:binding},smalltalk.HLBindingGroup)})},
  475. args: ["aString", "aBinding"],
  476. source: "at: aString add: aBinding\x0a\x09| binding |\x0a\x09\x0a\x09binding := self at: aString.\x0a\x09binding ifNil: [ ^ self ].\x0a\x09\x09\x0a\x09binding add: aBinding",
  477. messageSends: ["at:", "ifNil:", "add:"],
  478. referencedClasses: []
  479. }),
  480. smalltalk.HLBindingGroup);
  481. smalltalk.addMethod(
  482. "_atKey_",
  483. smalltalk.method({
  484. selector: "atKey:",
  485. category: 'accessing',
  486. fn: function (anInteger){
  487. var self=this;
  488. return smalltalk.withContext(function($ctx1) { var $1;
  489. $1=_st(_st(self)._bindings())._detect_ifNone_((function(each){
  490. return smalltalk.withContext(function($ctx2) { return _st(_st(each)._key()).__eq(anInteger);
  491. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}),(function(){
  492. return smalltalk.withContext(function($ctx2) { return nil;
  493. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  494. return $1;
  495. }, function($ctx1) {$ctx1.fill(self,"atKey:",{anInteger:anInteger}, smalltalk.HLBindingGroup)})},
  496. args: ["anInteger"],
  497. source: "atKey: anInteger\x0a\x09^ self bindings \x0a \x09detect: [ :each | each key = anInteger ]\x0a \x09ifNone: [ nil ]",
  498. messageSends: ["detect:ifNone:", "=", "key", "bindings"],
  499. referencedClasses: []
  500. }),
  501. smalltalk.HLBindingGroup);
  502. smalltalk.addMethod(
  503. "_bindings",
  504. smalltalk.method({
  505. selector: "bindings",
  506. category: 'accessing',
  507. fn: function (){
  508. var self=this;
  509. return smalltalk.withContext(function($ctx1) { var $2,$1;
  510. $2=self["@bindings"];
  511. if(($receiver = $2) == nil || $receiver == undefined){
  512. self["@bindings"]=_st((smalltalk.OrderedCollection || OrderedCollection))._new();
  513. $1=self["@bindings"];
  514. } else {
  515. $1=$2;
  516. };
  517. return $1;
  518. }, function($ctx1) {$ctx1.fill(self,"bindings",{}, smalltalk.HLBindingGroup)})},
  519. args: [],
  520. source: "bindings\x0a\x09^ bindings ifNil: [ bindings := OrderedCollection new ]",
  521. messageSends: ["ifNil:", "new"],
  522. referencedClasses: ["OrderedCollection"]
  523. }),
  524. smalltalk.HLBindingGroup);
  525. smalltalk.addMethod(
  526. "_displayLabel",
  527. smalltalk.method({
  528. selector: "displayLabel",
  529. category: 'accessing',
  530. fn: function (){
  531. var self=this;
  532. return smalltalk.withContext(function($ctx1) { var $1;
  533. $1=_st(smalltalk.HLBinding.fn.prototype._displayLabel.apply(_st(self), [])).__comma("...");
  534. return $1;
  535. }, function($ctx1) {$ctx1.fill(self,"displayLabel",{}, smalltalk.HLBindingGroup)})},
  536. args: [],
  537. source: "displayLabel\x0a\x09^ super displayLabel, '...'",
  538. messageSends: [",", "displayLabel"],
  539. referencedClasses: []
  540. }),
  541. smalltalk.HLBindingGroup);
  542. smalltalk.addMethod(
  543. "_isActive",
  544. smalltalk.method({
  545. selector: "isActive",
  546. category: 'testing',
  547. fn: function (){
  548. var self=this;
  549. return smalltalk.withContext(function($ctx1) { var $1;
  550. $1=_st(_st(self)._activeBindings())._notEmpty();
  551. return $1;
  552. }, function($ctx1) {$ctx1.fill(self,"isActive",{},smalltalk.HLBindingGroup)})},
  553. args: [],
  554. source: "isActive\x0a\x09^ self activeBindings notEmpty",
  555. messageSends: ["notEmpty", "activeBindings"],
  556. referencedClasses: []
  557. }),
  558. smalltalk.HLBindingGroup);
  559. smalltalk.addMethod(
  560. "_isBindingGroup",
  561. smalltalk.method({
  562. selector: "isBindingGroup",
  563. category: 'testing',
  564. fn: function (){
  565. var self=this;
  566. return smalltalk.withContext(function($ctx1) { return true;
  567. }, function($ctx1) {$ctx1.fill(self,"isBindingGroup",{}, smalltalk.HLBindingGroup)})},
  568. args: [],
  569. source: "isBindingGroup\x0a\x09^ true",
  570. messageSends: [],
  571. referencedClasses: []
  572. }),
  573. smalltalk.HLBindingGroup);
  574. smalltalk.addMethod(
  575. "_renderOn_html_",
  576. smalltalk.method({
  577. selector: "renderOn:html:",
  578. category: 'rendering',
  579. fn: function (aBindingHelper,html){
  580. var self=this;
  581. return smalltalk.withContext(function($ctx1) { var $1;
  582. $1=_st(self)._isActive();
  583. if(smalltalk.assert($1)){
  584. _st(aBindingHelper)._renderBindingGroup_on_(self,html);
  585. };
  586. return self}, function($ctx1) {$ctx1.fill(self,"renderOn:html:",{aBindingHelper:aBindingHelper,html:html},smalltalk.HLBindingGroup)})},
  587. args: ["aBindingHelper", "html"],
  588. source: "renderOn: aBindingHelper html: html\x0a\x09self isActive ifTrue: [\x0a\x09\x09aBindingHelper renderBindingGroup: self on: html ]",
  589. messageSends: ["ifTrue:", "renderBindingGroup:on:", "isActive"],
  590. referencedClasses: []
  591. }),
  592. smalltalk.HLBindingGroup);
  593. smalltalk.addClass('HLKeyBinder', smalltalk.Object, ['modifierKey', 'active', 'helper', 'bindings', 'selectedBinding'], 'Helios-KeyBindings');
  594. smalltalk.addMethod(
  595. "_activate",
  596. smalltalk.method({
  597. selector: "activate",
  598. category: 'actions',
  599. fn: function (){
  600. var self=this;
  601. return smalltalk.withContext(function($ctx1) { self["@active"]=true;
  602. _st(_st(self)._helper())._show();
  603. return self}, function($ctx1) {$ctx1.fill(self,"activate",{}, smalltalk.HLKeyBinder)})},
  604. args: [],
  605. source: "activate\x0a\x09active := true.\x0a\x09self helper show",
  606. messageSends: ["show", "helper"],
  607. referencedClasses: []
  608. }),
  609. smalltalk.HLKeyBinder);
  610. smalltalk.addMethod(
  611. "_activationKey",
  612. smalltalk.method({
  613. selector: "activationKey",
  614. category: 'accessing',
  615. fn: function (){
  616. var self=this;
  617. return smalltalk.withContext(function($ctx1) { return (32);
  618. }, function($ctx1) {$ctx1.fill(self,"activationKey",{}, smalltalk.HLKeyBinder)})},
  619. args: [],
  620. source: "activationKey\x0a\x09\x22SPACE\x22\x0a\x09^ 32",
  621. messageSends: [],
  622. referencedClasses: []
  623. }),
  624. smalltalk.HLKeyBinder);
  625. smalltalk.addMethod(
  626. "_activationKeyLabel",
  627. smalltalk.method({
  628. selector: "activationKeyLabel",
  629. category: 'accessing',
  630. fn: function (){
  631. var self=this;
  632. return smalltalk.withContext(function($ctx1) { return "ctrl + space";
  633. }, function($ctx1) {$ctx1.fill(self,"activationKeyLabel",{}, smalltalk.HLKeyBinder)})},
  634. args: [],
  635. source: "activationKeyLabel\x0a\x09^ 'ctrl + space'",
  636. messageSends: [],
  637. referencedClasses: []
  638. }),
  639. smalltalk.HLKeyBinder);
  640. smalltalk.addMethod(
  641. "_applyBinding_",
  642. smalltalk.method({
  643. selector: "applyBinding:",
  644. category: 'actions',
  645. fn: function (aBinding){
  646. var self=this;
  647. return smalltalk.withContext(function($ctx1) { _st(aBinding)._applyOn_(self);
  648. return self}, function($ctx1) {$ctx1.fill(self,"applyBinding:",{aBinding:aBinding}, smalltalk.HLKeyBinder)})},
  649. args: ["aBinding"],
  650. source: "applyBinding: aBinding\x0a aBinding applyOn: self",
  651. messageSends: ["applyOn:"],
  652. referencedClasses: []
  653. }),
  654. smalltalk.HLKeyBinder);
  655. smalltalk.addMethod(
  656. "_applyBindingAction_",
  657. smalltalk.method({
  658. selector: "applyBindingAction:",
  659. category: 'actions',
  660. fn: function (aBinding){
  661. var self=this;
  662. return smalltalk.withContext(function($ctx1) { _st(_st(aBinding)._callback())._value();
  663. _st(self)._deactivate();
  664. return self}, function($ctx1) {$ctx1.fill(self,"applyBindingAction:",{aBinding:aBinding}, smalltalk.HLKeyBinder)})},
  665. args: ["aBinding"],
  666. source: "applyBindingAction: aBinding\x0a aBinding callback value.\x0a\x09self deactivate",
  667. messageSends: ["value", "callback", "deactivate"],
  668. referencedClasses: []
  669. }),
  670. smalltalk.HLKeyBinder);
  671. smalltalk.addMethod(
  672. "_applyBindingGroup_",
  673. smalltalk.method({
  674. selector: "applyBindingGroup:",
  675. category: 'actions',
  676. fn: function (aBinding){
  677. var self=this;
  678. return smalltalk.withContext(function($ctx1) { self["@selectedBinding"]=aBinding;
  679. _st(_st(self)._helper())._refresh();
  680. return self}, function($ctx1) {$ctx1.fill(self,"applyBindingGroup:",{aBinding:aBinding}, smalltalk.HLKeyBinder)})},
  681. args: ["aBinding"],
  682. source: "applyBindingGroup: aBinding\x0a selectedBinding := aBinding.\x0a self helper refresh",
  683. messageSends: ["refresh", "helper"],
  684. referencedClasses: []
  685. }),
  686. smalltalk.HLKeyBinder);
  687. smalltalk.addMethod(
  688. "_bindings",
  689. smalltalk.method({
  690. selector: "bindings",
  691. category: 'accessing',
  692. fn: function (){
  693. var self=this;
  694. return smalltalk.withContext(function($ctx1) { var $2,$1;
  695. $2=self["@bindings"];
  696. if(($receiver = $2) == nil || $receiver == undefined){
  697. self["@bindings"]=_st(self)._defaultBindings();
  698. $1=self["@bindings"];
  699. } else {
  700. $1=$2;
  701. };
  702. return $1;
  703. }, function($ctx1) {$ctx1.fill(self,"bindings",{},smalltalk.HLKeyBinder)})},
  704. args: [],
  705. source: "bindings\x0a\x09^ bindings ifNil: [ bindings := self defaultBindings ]",
  706. messageSends: ["ifNil:", "defaultBindings"],
  707. referencedClasses: []
  708. }),
  709. smalltalk.HLKeyBinder);
  710. smalltalk.addMethod(
  711. "_deactivate",
  712. smalltalk.method({
  713. selector: "deactivate",
  714. category: 'actions',
  715. fn: function (){
  716. var self=this;
  717. return smalltalk.withContext(function($ctx1) { self["@active"]=false;
  718. self["@selectedBinding"]=nil;
  719. _st(_st(self)._helper())._hide();
  720. return self}, function($ctx1) {$ctx1.fill(self,"deactivate",{}, smalltalk.HLKeyBinder)})},
  721. args: [],
  722. source: "deactivate\x0a\x09active := false.\x0a selectedBinding := nil.\x0a\x09self helper hide",
  723. messageSends: ["hide", "helper"],
  724. referencedClasses: []
  725. }),
  726. smalltalk.HLKeyBinder);
  727. smalltalk.addMethod(
  728. "_defaultBindings",
  729. smalltalk.method({
  730. selector: "defaultBindings",
  731. category: 'defaults',
  732. fn: function (){
  733. var self=this;
  734. var group;
  735. return smalltalk.withContext(function($ctx1) { var $1,$2,$3;
  736. $1=_st((smalltalk.HLBindingGroup || HLBindingGroup))._new();
  737. _st($1)._addGroupKey_labelled_((79),"Open");
  738. _st($1)._addGroupKey_labelled_((86),"View");
  739. _st($1)._add_(_st(_st((smalltalk.HLCloseTabCommand || HLCloseTabCommand))._new())._asBinding());
  740. $2=_st($1)._yourself();
  741. group=$2;
  742. _st((smalltalk.HLOpenCommand || HLOpenCommand))._registerConcreteClassesOn_(_st(group)._at_("Open"));
  743. $3=group;
  744. return $3;
  745. }, function($ctx1) {$ctx1.fill(self,"defaultBindings",{group:group},smalltalk.HLKeyBinder)})},
  746. args: [],
  747. source: "defaultBindings\x0a\x09| group |\x0a\x09\x0a\x09group := HLBindingGroup new\x0a\x09\x09addGroupKey: 79 labelled: 'Open';\x0a\x09\x09addGroupKey: 86 labelled: 'View';\x0a\x09\x09add: HLCloseTabCommand new asBinding;\x0a\x09\x09yourself.\x0a\x09\x09\x0a\x09HLOpenCommand registerConcreteClassesOn: (group at: 'Open').\x0a\x09\x09\x09\x09\x0a\x09^ group",
  748. messageSends: ["addGroupKey:labelled:", "new", "add:", "asBinding", "yourself", "registerConcreteClassesOn:", "at:"],
  749. referencedClasses: ["HLBindingGroup", "HLCloseTabCommand", "HLOpenCommand"]
  750. }),
  751. smalltalk.HLKeyBinder);
  752. smalltalk.addMethod(
  753. "_escapeKey",
  754. smalltalk.method({
  755. selector: "escapeKey",
  756. category: 'accessing',
  757. fn: function (){
  758. var self=this;
  759. return smalltalk.withContext(function($ctx1) { return (27);
  760. }, function($ctx1) {$ctx1.fill(self,"escapeKey",{}, smalltalk.HLKeyBinder)})},
  761. args: [],
  762. source: "escapeKey\x0a\x09\x22ESC\x22\x0a\x09^ 27",
  763. messageSends: [],
  764. referencedClasses: []
  765. }),
  766. smalltalk.HLKeyBinder);
  767. smalltalk.addMethod(
  768. "_flushBindings",
  769. smalltalk.method({
  770. selector: "flushBindings",
  771. category: 'actions',
  772. fn: function (){
  773. var self=this;
  774. return smalltalk.withContext(function($ctx1) { self["@bindings"]=nil;
  775. return self}, function($ctx1) {$ctx1.fill(self,"flushBindings",{}, smalltalk.HLKeyBinder)})},
  776. args: [],
  777. source: "flushBindings\x0a\x09bindings := nil",
  778. messageSends: [],
  779. referencedClasses: []
  780. }),
  781. smalltalk.HLKeyBinder);
  782. smalltalk.addMethod(
  783. "_handleActiveKeyDown_",
  784. smalltalk.method({
  785. selector: "handleActiveKeyDown:",
  786. category: 'events',
  787. fn: function (event){
  788. var self=this;
  789. return smalltalk.withContext(function($ctx1) { var $1,$2;
  790. $1=_st(_st(_st(event)._which()).__eq(_st(self)._escapeKey()))._or_((function(){
  791. return smalltalk.withContext(function($ctx2) { return _st(_st(_st(event)._which()).__eq((71)))._and_((function(){
  792. return smalltalk.withContext(function($ctx3) { return _st(event)._ctrlKey();
  793. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  794. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  795. if(smalltalk.assert($1)){
  796. _st(self)._deactivate();
  797. _st(event)._preventDefault();
  798. return false;
  799. };
  800. $2=_st(self)._handleBindingFor_(event);
  801. return $2;
  802. }, function($ctx1) {$ctx1.fill(self,"handleActiveKeyDown:",{event:event}, smalltalk.HLKeyBinder)})},
  803. args: ["event"],
  804. source: "handleActiveKeyDown: event\x0a\x0a\x09\x22ESC or ctrl+g deactivate the keyBinder\x22\x0a\x09(event which = self escapeKey or: [\x0a\x09\x09event which = 71 and: [ event ctrlKey ] ])\x0a \x09ifTrue: [ \x0a \x09self deactivate.\x0a\x09\x09\x09\x09event preventDefault.\x0a\x09\x09\x09\x09^ false ].\x0a \x0a \x22Handle the keybinding\x22\x0a ^ self handleBindingFor: event",
  805. messageSends: ["ifTrue:", "deactivate", "preventDefault", "or:", "and:", "ctrlKey", "=", "which", "escapeKey", "handleBindingFor:"],
  806. referencedClasses: []
  807. }),
  808. smalltalk.HLKeyBinder);
  809. smalltalk.addMethod(
  810. "_handleBindingFor_",
  811. smalltalk.method({
  812. selector: "handleBindingFor:",
  813. category: 'events',
  814. fn: function (anEvent){
  815. var self=this;
  816. var binding;
  817. return smalltalk.withContext(function($ctx1) { var $1;
  818. binding=_st(_st(self)._selectedBinding())._atKey_(_st(anEvent)._which());
  819. $1=binding;
  820. if(($receiver = $1) == nil || $receiver == undefined){
  821. $1;
  822. } else {
  823. _st(self)._applyBinding_(binding);
  824. _st(anEvent)._preventDefault();
  825. return false;
  826. };
  827. return self}, function($ctx1) {$ctx1.fill(self,"handleBindingFor:",{anEvent:anEvent,binding:binding}, smalltalk.HLKeyBinder)})},
  828. args: ["anEvent"],
  829. source: "handleBindingFor: anEvent\x0a\x09| binding |\x0a binding := self selectedBinding atKey: anEvent which.\x0a \x0a binding ifNotNil: [ \x0a \x09self applyBinding: binding.\x0a\x09\x09anEvent preventDefault.\x0a\x09\x09^ false ]",
  830. messageSends: ["atKey:", "which", "selectedBinding", "ifNotNil:", "applyBinding:", "preventDefault"],
  831. referencedClasses: []
  832. }),
  833. smalltalk.HLKeyBinder);
  834. smalltalk.addMethod(
  835. "_handleInactiveKeyDown_",
  836. smalltalk.method({
  837. selector: "handleInactiveKeyDown:",
  838. category: 'events',
  839. fn: function (event){
  840. var self=this;
  841. return smalltalk.withContext(function($ctx1) { var $1,$2;
  842. $1=_st(_st(event)._which()).__eq(_st(self)._activationKey());
  843. if(smalltalk.assert($1)){
  844. $2=_st(event)._ctrlKey();
  845. if(smalltalk.assert($2)){
  846. _st(self)._activate();
  847. _st(event)._preventDefault();
  848. return false;
  849. };
  850. };
  851. return self}, function($ctx1) {$ctx1.fill(self,"handleInactiveKeyDown:",{event:event}, smalltalk.HLKeyBinder)})},
  852. args: ["event"],
  853. source: "handleInactiveKeyDown: event\x0a event which = self activationKey ifTrue: [\x0a \x09\x09event ctrlKey ifTrue: [\x0a\x09\x09\x09\x09\x09self activate. \x0a \x09\x09 event preventDefault. \x0a \x09^ false ] ]",
  854. messageSends: ["ifTrue:", "activate", "preventDefault", "ctrlKey", "=", "activationKey", "which"],
  855. referencedClasses: []
  856. }),
  857. smalltalk.HLKeyBinder);
  858. smalltalk.addMethod(
  859. "_handleKeyDown_",
  860. smalltalk.method({
  861. selector: "handleKeyDown:",
  862. category: 'events',
  863. fn: function (event){
  864. var self=this;
  865. return smalltalk.withContext(function($ctx1) { var $2,$1;
  866. $2=_st(self)._isActive();
  867. if(smalltalk.assert($2)){
  868. $1=_st(self)._handleActiveKeyDown_(event);
  869. } else {
  870. $1=_st(self)._handleInactiveKeyDown_(event);
  871. };
  872. return $1;
  873. }, function($ctx1) {$ctx1.fill(self,"handleKeyDown:",{event:event}, smalltalk.HLKeyBinder)})},
  874. args: ["event"],
  875. source: "handleKeyDown: event\x0a\x09^ self isActive\x0a \x09ifTrue: [ self handleActiveKeyDown: event ]\x0a \x09ifFalse: [ self handleInactiveKeyDown: event ]",
  876. messageSends: ["ifTrue:ifFalse:", "handleActiveKeyDown:", "handleInactiveKeyDown:", "isActive"],
  877. referencedClasses: []
  878. }),
  879. smalltalk.HLKeyBinder);
  880. smalltalk.addMethod(
  881. "_helper",
  882. smalltalk.method({
  883. selector: "helper",
  884. category: 'accessing',
  885. fn: function (){
  886. var self=this;
  887. return smalltalk.withContext(function($ctx1) { var $1;
  888. $1=self["@helper"];
  889. return $1;
  890. }, function($ctx1) {$ctx1.fill(self,"helper",{}, smalltalk.HLKeyBinder)})},
  891. args: [],
  892. source: "helper\x0a\x09^ helper",
  893. messageSends: [],
  894. referencedClasses: []
  895. }),
  896. smalltalk.HLKeyBinder);
  897. smalltalk.addMethod(
  898. "_initialize",
  899. smalltalk.method({
  900. selector: "initialize",
  901. category: 'initialization',
  902. fn: function (){
  903. var self=this;
  904. return smalltalk.withContext(function($ctx1) { smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  905. self["@helper"]=_st((smalltalk.HLKeyBinderHelper || HLKeyBinderHelper))._on_(self);
  906. _st(self["@helper"])._renderStart();
  907. self["@active"]=false;
  908. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{}, smalltalk.HLKeyBinder)})},
  909. args: [],
  910. source: "initialize\x0a\x09super initialize.\x0a\x09helper := HLKeyBinderHelper on: self.\x0a\x09helper renderStart.\x0a active := false",
  911. messageSends: ["initialize", "on:", "renderStart"],
  912. referencedClasses: ["HLKeyBinderHelper"]
  913. }),
  914. smalltalk.HLKeyBinder);
  915. smalltalk.addMethod(
  916. "_isActive",
  917. smalltalk.method({
  918. selector: "isActive",
  919. category: 'testing',
  920. fn: function (){
  921. var self=this;
  922. return smalltalk.withContext(function($ctx1) { var $2,$1;
  923. $2=self["@active"];
  924. if(($receiver = $2) == nil || $receiver == undefined){
  925. $1=false;
  926. } else {
  927. $1=$2;
  928. };
  929. return $1;
  930. }, function($ctx1) {$ctx1.fill(self,"isActive",{}, smalltalk.HLKeyBinder)})},
  931. args: [],
  932. source: "isActive\x0a\x09^ active ifNil: [ false ]",
  933. messageSends: ["ifNil:"],
  934. referencedClasses: []
  935. }),
  936. smalltalk.HLKeyBinder);
  937. smalltalk.addMethod(
  938. "_selectedBinding",
  939. smalltalk.method({
  940. selector: "selectedBinding",
  941. category: 'accessing',
  942. fn: function (){
  943. var self=this;
  944. return smalltalk.withContext(function($ctx1) { var $2,$1;
  945. $2=self["@selectedBinding"];
  946. if(($receiver = $2) == nil || $receiver == undefined){
  947. $1=_st(self)._bindings();
  948. } else {
  949. $1=$2;
  950. };
  951. return $1;
  952. }, function($ctx1) {$ctx1.fill(self,"selectedBinding",{}, smalltalk.HLKeyBinder)})},
  953. args: [],
  954. source: "selectedBinding\x0a\x09^ selectedBinding ifNil: [ self bindings ]",
  955. messageSends: ["ifNil:", "bindings"],
  956. referencedClasses: []
  957. }),
  958. smalltalk.HLKeyBinder);
  959. smalltalk.addMethod(
  960. "_setupEvents",
  961. smalltalk.method({
  962. selector: "setupEvents",
  963. category: 'events',
  964. fn: function (){
  965. var self=this;
  966. return smalltalk.withContext(function($ctx1) { _st(_st(window)._jQuery_("body"))._keydown_((function(event){
  967. return smalltalk.withContext(function($ctx2) { return _st(self)._handleKeyDown_(event);
  968. }, function($ctx2) {$ctx2.fillBlock({event:event},$ctx1)})}));
  969. return self}, function($ctx1) {$ctx1.fill(self,"setupEvents",{}, smalltalk.HLKeyBinder)})},
  970. args: [],
  971. source: "setupEvents\x0a\x09(window jQuery: 'body') keydown: [ :event | self handleKeyDown: event ]",
  972. messageSends: ["keydown:", "handleKeyDown:", "jQuery:"],
  973. referencedClasses: []
  974. }),
  975. smalltalk.HLKeyBinder);
  976. smalltalk.addMethod(
  977. "_systemIsMac",
  978. smalltalk.method({
  979. selector: "systemIsMac",
  980. category: 'testing',
  981. fn: function (){
  982. var self=this;
  983. return smalltalk.withContext(function($ctx1) { var $1;
  984. $1=_st(_st(navigator)._platform())._match_("Mac");
  985. return $1;
  986. }, function($ctx1) {$ctx1.fill(self,"systemIsMac",{}, smalltalk.HLKeyBinder)})},
  987. args: [],
  988. source: "systemIsMac\x0a\x09^ navigator platform match: 'Mac'",
  989. messageSends: ["match:", "platform"],
  990. referencedClasses: []
  991. }),
  992. smalltalk.HLKeyBinder);
  993. smalltalk.addClass('HLKeyBinderHelper', smalltalk.HLWidget, ['keyBinder'], 'Helios-KeyBindings');
  994. smalltalk.addMethod(
  995. "_cssClass",
  996. smalltalk.method({
  997. selector: "cssClass",
  998. category: 'accessing',
  999. fn: function (){
  1000. var self=this;
  1001. return smalltalk.withContext(function($ctx1) { return "key_helper";
  1002. }, function($ctx1) {$ctx1.fill(self,"cssClass",{}, smalltalk.HLKeyBinderHelper)})},
  1003. args: [],
  1004. source: "cssClass\x0a\x09^ 'key_helper'",
  1005. messageSends: [],
  1006. referencedClasses: []
  1007. }),
  1008. smalltalk.HLKeyBinderHelper);
  1009. smalltalk.addMethod(
  1010. "_hide",
  1011. smalltalk.method({
  1012. selector: "hide",
  1013. category: 'actions',
  1014. fn: function (){
  1015. var self=this;
  1016. return smalltalk.withContext(function($ctx1) { _st(_st(_st(".").__comma(_st(self)._cssClass()))._asJQuery())._remove();
  1017. return self}, function($ctx1) {$ctx1.fill(self,"hide",{}, smalltalk.HLKeyBinderHelper)})},
  1018. args: [],
  1019. source: "hide\x0a\x09('.', self cssClass) asJQuery remove",
  1020. messageSends: ["remove", "asJQuery", ",", "cssClass"],
  1021. referencedClasses: []
  1022. }),
  1023. smalltalk.HLKeyBinderHelper);
  1024. smalltalk.addMethod(
  1025. "_keyBinder",
  1026. smalltalk.method({
  1027. selector: "keyBinder",
  1028. category: 'accessing',
  1029. fn: function (){
  1030. var self=this;
  1031. return smalltalk.withContext(function($ctx1) { var $1;
  1032. $1=self["@keyBinder"];
  1033. return $1;
  1034. }, function($ctx1) {$ctx1.fill(self,"keyBinder",{}, smalltalk.HLKeyBinderHelper)})},
  1035. args: [],
  1036. source: "keyBinder\x0a\x09^ keyBinder",
  1037. messageSends: [],
  1038. referencedClasses: []
  1039. }),
  1040. smalltalk.HLKeyBinderHelper);
  1041. smalltalk.addMethod(
  1042. "_keyBinder_",
  1043. smalltalk.method({
  1044. selector: "keyBinder:",
  1045. category: 'accessing',
  1046. fn: function (aKeyBinder){
  1047. var self=this;
  1048. return smalltalk.withContext(function($ctx1) { self["@keyBinder"]=aKeyBinder;
  1049. return self}, function($ctx1) {$ctx1.fill(self,"keyBinder:",{aKeyBinder:aKeyBinder}, smalltalk.HLKeyBinderHelper)})},
  1050. args: ["aKeyBinder"],
  1051. source: "keyBinder: aKeyBinder\x0a\x09keyBinder := aKeyBinder",
  1052. messageSends: [],
  1053. referencedClasses: []
  1054. }),
  1055. smalltalk.HLKeyBinderHelper);
  1056. smalltalk.addMethod(
  1057. "_registerBindings",
  1058. smalltalk.method({
  1059. selector: "registerBindings",
  1060. category: 'keyBindings',
  1061. fn: function (){
  1062. var self=this;
  1063. return smalltalk.withContext(function($ctx1) { return self}, function($ctx1) {$ctx1.fill(self,"registerBindings",{}, smalltalk.HLKeyBinderHelper)})},
  1064. args: [],
  1065. source: "registerBindings\x0a\x09\x22Do nothing\x22",
  1066. messageSends: [],
  1067. referencedClasses: []
  1068. }),
  1069. smalltalk.HLKeyBinderHelper);
  1070. smalltalk.addMethod(
  1071. "_renderBindingGroup_on_",
  1072. smalltalk.method({
  1073. selector: "renderBindingGroup:on:",
  1074. category: 'rendering',
  1075. fn: function (aBindingGroup,html){
  1076. var self=this;
  1077. return smalltalk.withContext(function($ctx1) { var $1,$3,$4,$5,$6,$2;
  1078. _st(_st(_st(aBindingGroup)._activeBindings())._sorted_((function(a,b){
  1079. return smalltalk.withContext(function($ctx2) { return _st(_st(a)._key()).__lt(_st(b)._key());
  1080. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})})))._do_((function(each){
  1081. return smalltalk.withContext(function($ctx2) { $1=_st(html)._span();
  1082. _st($1)._class_("command");
  1083. $2=_st($1)._with_((function(){
  1084. return smalltalk.withContext(function($ctx3) { $3=_st(html)._span();
  1085. _st($3)._class_("label");
  1086. $4=_st($3)._with_(_st(_st(each)._shortcut())._asLowercase());
  1087. $4;
  1088. $5=_st(html)._a();
  1089. _st($5)._class_("action");
  1090. _st($5)._with_(_st(each)._displayLabel());
  1091. $6=_st($5)._onClick_((function(){
  1092. return smalltalk.withContext(function($ctx4) { return _st(_st(self)._keyBinder())._applyBinding_(each);
  1093. }, function($ctx4) {$ctx4.fillBlock({},$ctx1)})}));
  1094. return $6;
  1095. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  1096. return $2;
  1097. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  1098. return self}, function($ctx1) {$ctx1.fill(self,"renderBindingGroup:on:",{aBindingGroup:aBindingGroup,html:html},smalltalk.HLKeyBinderHelper)})},
  1099. args: ["aBindingGroup", "html"],
  1100. source: "renderBindingGroup: aBindingGroup on: html\x0a\x09(aBindingGroup activeBindings \x0a \x09sorted: [ :a :b | a key < b key ])\x0a do: [ :each |\x0a\x09\x09\x09html span class: 'command'; with: [\x0a\x09\x09\x09\x09html span class: 'label'; with: each shortcut asLowercase.\x0a \x09\x09\x09\x09html a \x0a \x09class: 'action'; \x0a with: each displayLabel;\x0a \x09\x09\x09\x09\x09onClick: [ self keyBinder applyBinding: each ] ] ]",
  1101. messageSends: ["do:", "class:", "span", "with:", "asLowercase", "shortcut", "a", "displayLabel", "onClick:", "applyBinding:", "keyBinder", "sorted:", "<", "key", "activeBindings"],
  1102. referencedClasses: []
  1103. }),
  1104. smalltalk.HLKeyBinderHelper);
  1105. smalltalk.addMethod(
  1106. "_renderBindingOn_",
  1107. smalltalk.method({
  1108. selector: "renderBindingOn:",
  1109. category: 'rendering',
  1110. fn: function (html){
  1111. var self=this;
  1112. return smalltalk.withContext(function($ctx1) { _st(_st(self)._selectedBinding())._renderOn_html_(self,html);
  1113. return self}, function($ctx1) {$ctx1.fill(self,"renderBindingOn:",{html:html}, smalltalk.HLKeyBinderHelper)})},
  1114. args: ["html"],
  1115. source: "renderBindingOn: html\x0a\x09self selectedBinding renderOn: self html: html",
  1116. messageSends: ["renderOn:html:", "selectedBinding"],
  1117. referencedClasses: []
  1118. }),
  1119. smalltalk.HLKeyBinderHelper);
  1120. smalltalk.addMethod(
  1121. "_renderContentOn_",
  1122. smalltalk.method({
  1123. selector: "renderContentOn:",
  1124. category: 'rendering',
  1125. fn: function (html){
  1126. var self=this;
  1127. return smalltalk.withContext(function($ctx1) { var $1,$3,$4,$2;
  1128. $1=_st(html)._div();
  1129. _st($1)._class_(_st(self)._cssClass());
  1130. $2=_st($1)._with_((function(){
  1131. return smalltalk.withContext(function($ctx2) { $3=self;
  1132. _st($3)._renderSelectionOn_(html);
  1133. $4=_st($3)._renderBindingOn_(html);
  1134. return $4;
  1135. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1136. return self}, function($ctx1) {$ctx1.fill(self,"renderContentOn:",{html:html}, smalltalk.HLKeyBinderHelper)})},
  1137. args: ["html"],
  1138. source: "renderContentOn: html\x0a\x09html div class: self cssClass; with: [\x0a \x09self \x0a \x09renderSelectionOn:html;\x0a \x09renderBindingOn: html ]",
  1139. messageSends: ["class:", "cssClass", "div", "with:", "renderSelectionOn:", "renderBindingOn:"],
  1140. referencedClasses: []
  1141. }),
  1142. smalltalk.HLKeyBinderHelper);
  1143. smalltalk.addMethod(
  1144. "_renderSelectionOn_",
  1145. smalltalk.method({
  1146. selector: "renderSelectionOn:",
  1147. category: 'rendering',
  1148. fn: function (html){
  1149. var self=this;
  1150. return smalltalk.withContext(function($ctx1) { var $1,$3,$5,$4,$2;
  1151. $1=_st(html)._span();
  1152. _st($1)._class_("selected");
  1153. $3=$1;
  1154. $5=_st(_st(self)._selectedBinding())._label();
  1155. if(($receiver = $5) == nil || $receiver == undefined){
  1156. $4="Action";
  1157. } else {
  1158. $4=$5;
  1159. };
  1160. $2=_st($3)._with_($4);
  1161. return self}, function($ctx1) {$ctx1.fill(self,"renderSelectionOn:",{html:html}, smalltalk.HLKeyBinderHelper)})},
  1162. args: ["html"],
  1163. source: "renderSelectionOn: html\x0a\x09\x09html span \x0a \x09class: 'selected'; \x0a with: (self selectedBinding label ifNil: [ 'Action' ])",
  1164. messageSends: ["class:", "span", "with:", "ifNil:", "label", "selectedBinding"],
  1165. referencedClasses: []
  1166. }),
  1167. smalltalk.HLKeyBinderHelper);
  1168. smalltalk.addMethod(
  1169. "_renderStart",
  1170. smalltalk.method({
  1171. selector: "renderStart",
  1172. category: 'rendering',
  1173. fn: function (){
  1174. var self=this;
  1175. return smalltalk.withContext(function($ctx1) { var $1,$2;
  1176. _st((function(html){
  1177. return smalltalk.withContext(function($ctx2) { $1=_st(html)._div();
  1178. _st($1)._id_("keybinding-start-helper");
  1179. $2=_st($1)._with_(_st(_st("Press ").__comma(_st(_st(self)._keyBinder())._activationKeyLabel())).__comma(" to start"));
  1180. return $2;
  1181. }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1)})}))._appendToJQuery_(_st("body")._asJQuery());
  1182. _st((function(){
  1183. return smalltalk.withContext(function($ctx2) { return _st(_st(window)._jQuery_("#keybinding-start-helper"))._fadeOut_((1000));
  1184. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._valueWithTimeout_((2000));
  1185. return self}, function($ctx1) {$ctx1.fill(self,"renderStart",{}, smalltalk.HLKeyBinderHelper)})},
  1186. args: [],
  1187. source: "renderStart\x0a\x09[ :html |\x0a\x09\x09html div \x0a\x09\x09\x09id: 'keybinding-start-helper';\x0a\x09\x09\x09with: 'Press ', self keyBinder activationKeyLabel, ' to start' ] appendToJQuery: 'body' asJQuery.\x0a\x09\x0a\x09[ (window jQuery: '#keybinding-start-helper') fadeOut: 1000 ] \x0a\x09\x09valueWithTimeout: 2000",
  1188. messageSends: ["appendToJQuery:", "asJQuery", "id:", "div", "with:", ",", "activationKeyLabel", "keyBinder", "valueWithTimeout:", "fadeOut:", "jQuery:"],
  1189. referencedClasses: []
  1190. }),
  1191. smalltalk.HLKeyBinderHelper);
  1192. smalltalk.addMethod(
  1193. "_selectedBinding",
  1194. smalltalk.method({
  1195. selector: "selectedBinding",
  1196. category: 'accessing',
  1197. fn: function (){
  1198. var self=this;
  1199. return smalltalk.withContext(function($ctx1) { var $1;
  1200. $1=_st(_st(self)._keyBinder())._selectedBinding();
  1201. return $1;
  1202. }, function($ctx1) {$ctx1.fill(self,"selectedBinding",{}, smalltalk.HLKeyBinderHelper)})},
  1203. args: [],
  1204. source: "selectedBinding\x0a\x09^ self keyBinder selectedBinding",
  1205. messageSends: ["selectedBinding", "keyBinder"],
  1206. referencedClasses: []
  1207. }),
  1208. smalltalk.HLKeyBinderHelper);
  1209. smalltalk.addMethod(
  1210. "_show",
  1211. smalltalk.method({
  1212. selector: "show",
  1213. category: 'actions',
  1214. fn: function (){
  1215. var self=this;
  1216. return smalltalk.withContext(function($ctx1) { _st(self)._appendToJQuery_(_st("body")._asJQuery());
  1217. return self}, function($ctx1) {$ctx1.fill(self,"show",{}, smalltalk.HLKeyBinderHelper)})},
  1218. args: [],
  1219. source: "show\x0a\x09self appendToJQuery: 'body' asJQuery",
  1220. messageSends: ["appendToJQuery:", "asJQuery"],
  1221. referencedClasses: []
  1222. }),
  1223. smalltalk.HLKeyBinderHelper);
  1224. smalltalk.addMethod(
  1225. "_on_",
  1226. smalltalk.method({
  1227. selector: "on:",
  1228. category: 'instance creation',
  1229. fn: function (aKeyBinder){
  1230. var self=this;
  1231. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  1232. $2=_st(self)._new();
  1233. _st($2)._keyBinder_(aKeyBinder);
  1234. $3=_st($2)._yourself();
  1235. $1=$3;
  1236. return $1;
  1237. }, function($ctx1) {$ctx1.fill(self,"on:",{aKeyBinder:aKeyBinder}, smalltalk.HLKeyBinderHelper.klass)})},
  1238. args: ["aKeyBinder"],
  1239. source: "on: aKeyBinder\x0a\x09^ self new\x0a \x09keyBinder: aKeyBinder;\x0a yourself",
  1240. messageSends: ["keyBinder:", "new", "yourself"],
  1241. referencedClasses: []
  1242. }),
  1243. smalltalk.HLKeyBinderHelper.klass);