Helios-KeyBindings.js 76 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356
  1. define("amber_core/Helios-KeyBindings", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Objects", "amber_core/Helios-Core"], function(smalltalk,nil,_st, globals){
  2. smalltalk.addPackage('Helios-KeyBindings');
  3. smalltalk.packages["Helios-KeyBindings"].transport = {"type":"amd","amdNamespace":"amber_core"};
  4. smalltalk.addClass('HLBinding', globals.Object, ['key', 'label'], 'Helios-KeyBindings');
  5. globals.HLBinding.comment="I am the abstract representation of a keybinding in Helios. My instances hold a key (integer value) and a label. \x0a\x0aBindings are built into a tree of keys, so pressing a key may result in more key choices (for example, to open a workspace, 'o' is pressed first then 'w' is pressed).\x0a\x0aBinding action handling and selection is handled by the `current` instance of `HLKeyBinder`.\x0a\x0aSubclasses implement specific behavior like evaluating actions or (sub-)grouping other bindings.";
  6. smalltalk.addMethod(
  7. smalltalk.method({
  8. selector: "apply",
  9. protocol: 'actions',
  10. fn: function (){
  11. var self=this;
  12. return self},
  13. args: [],
  14. source: "apply",
  15. messageSends: [],
  16. referencedClasses: []
  17. }),
  18. globals.HLBinding);
  19. smalltalk.addMethod(
  20. smalltalk.method({
  21. selector: "atKey:",
  22. protocol: 'accessing',
  23. fn: function (aKey){
  24. var self=this;
  25. return nil;
  26. },
  27. args: ["aKey"],
  28. source: "atKey: aKey\x0a\x09\x22Answer the sub-binding at key aKey.\x0a\x09Always answer nil here. See HLBindingGroup for more.\x22\x0a\x09\x0a\x09^ nil",
  29. messageSends: [],
  30. referencedClasses: []
  31. }),
  32. globals.HLBinding);
  33. smalltalk.addMethod(
  34. smalltalk.method({
  35. selector: "displayLabel",
  36. protocol: 'accessing',
  37. fn: function (){
  38. var self=this;
  39. return smalltalk.withContext(function($ctx1) {
  40. var $1;
  41. $1=self._label();
  42. return $1;
  43. }, function($ctx1) {$ctx1.fill(self,"displayLabel",{},globals.HLBinding)})},
  44. args: [],
  45. source: "displayLabel\x0a\x09^ self label",
  46. messageSends: ["label"],
  47. referencedClasses: []
  48. }),
  49. globals.HLBinding);
  50. smalltalk.addMethod(
  51. smalltalk.method({
  52. selector: "isActive",
  53. protocol: 'testing',
  54. fn: function (){
  55. var self=this;
  56. return smalltalk.withContext(function($ctx1) {
  57. var $1;
  58. $1=self._subclassResponsibility();
  59. return $1;
  60. }, function($ctx1) {$ctx1.fill(self,"isActive",{},globals.HLBinding)})},
  61. args: [],
  62. source: "isActive\x0a\x09^ self subclassResponsibility",
  63. messageSends: ["subclassResponsibility"],
  64. referencedClasses: []
  65. }),
  66. globals.HLBinding);
  67. smalltalk.addMethod(
  68. smalltalk.method({
  69. selector: "key",
  70. protocol: 'accessing',
  71. fn: function (){
  72. var self=this;
  73. var $1;
  74. $1=self["@key"];
  75. return $1;
  76. },
  77. args: [],
  78. source: "key\x0a\x09^ key",
  79. messageSends: [],
  80. referencedClasses: []
  81. }),
  82. globals.HLBinding);
  83. smalltalk.addMethod(
  84. smalltalk.method({
  85. selector: "key:",
  86. protocol: 'accessing',
  87. fn: function (anInteger){
  88. var self=this;
  89. self["@key"]=anInteger;
  90. return self},
  91. args: ["anInteger"],
  92. source: "key: anInteger\x0a\x09key := anInteger",
  93. messageSends: [],
  94. referencedClasses: []
  95. }),
  96. globals.HLBinding);
  97. smalltalk.addMethod(
  98. smalltalk.method({
  99. selector: "label",
  100. protocol: 'accessing',
  101. fn: function (){
  102. var self=this;
  103. var $1;
  104. $1=self["@label"];
  105. return $1;
  106. },
  107. args: [],
  108. source: "label\x0a\x09^ label",
  109. messageSends: [],
  110. referencedClasses: []
  111. }),
  112. globals.HLBinding);
  113. smalltalk.addMethod(
  114. smalltalk.method({
  115. selector: "label:",
  116. protocol: 'accessing',
  117. fn: function (aString){
  118. var self=this;
  119. self["@label"]=aString;
  120. return self},
  121. args: ["aString"],
  122. source: "label: aString\x0a\x09label := aString",
  123. messageSends: [],
  124. referencedClasses: []
  125. }),
  126. globals.HLBinding);
  127. smalltalk.addMethod(
  128. smalltalk.method({
  129. selector: "release",
  130. protocol: 'actions',
  131. fn: function (){
  132. var self=this;
  133. return self},
  134. args: [],
  135. source: "release",
  136. messageSends: [],
  137. referencedClasses: []
  138. }),
  139. globals.HLBinding);
  140. smalltalk.addMethod(
  141. smalltalk.method({
  142. selector: "renderOn:html:",
  143. protocol: 'rendering',
  144. fn: function (aBindingHelper,html){
  145. var self=this;
  146. return self},
  147. args: ["aBindingHelper", "html"],
  148. source: "renderOn: aBindingHelper html: html",
  149. messageSends: [],
  150. referencedClasses: []
  151. }),
  152. globals.HLBinding);
  153. smalltalk.addMethod(
  154. smalltalk.method({
  155. selector: "shortcut",
  156. protocol: 'accessing',
  157. fn: function (){
  158. var self=this;
  159. function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
  160. return smalltalk.withContext(function($ctx1) {
  161. var $1;
  162. $1=_st($String())._fromCharCode_(self._key());
  163. return $1;
  164. }, function($ctx1) {$ctx1.fill(self,"shortcut",{},globals.HLBinding)})},
  165. args: [],
  166. source: "shortcut\x0a\x09^ String fromCharCode: self key",
  167. messageSends: ["fromCharCode:", "key"],
  168. referencedClasses: ["String"]
  169. }),
  170. globals.HLBinding);
  171. smalltalk.addMethod(
  172. smalltalk.method({
  173. selector: "on:labelled:",
  174. protocol: 'instance creation',
  175. fn: function (anInteger,aString){
  176. var self=this;
  177. return smalltalk.withContext(function($ctx1) {
  178. var $2,$3,$1;
  179. $2=self._new();
  180. _st($2)._key_(anInteger);
  181. _st($2)._label_(aString);
  182. $3=_st($2)._yourself();
  183. $1=$3;
  184. return $1;
  185. }, function($ctx1) {$ctx1.fill(self,"on:labelled:",{anInteger:anInteger,aString:aString},globals.HLBinding.klass)})},
  186. args: ["anInteger", "aString"],
  187. source: "on: anInteger labelled: aString\x0a\x09^ self new\x0a \x09key: anInteger;\x0a label: aString;\x0a yourself",
  188. messageSends: ["key:", "new", "label:", "yourself"],
  189. referencedClasses: []
  190. }),
  191. globals.HLBinding.klass);
  192. smalltalk.addClass('HLBindingAction', globals.HLBinding, ['command'], 'Helios-KeyBindings');
  193. globals.HLBindingAction.comment="My instances are the leafs of the binding tree. They evaluate actions through commands, instances of concrete subclasses of `HLCommand`.\x0a\x0aThe `#apply` methods is used to evaluate the `command`. If the command requires user input, an `inputWidget` will be displayed to the user.";
  194. smalltalk.addMethod(
  195. smalltalk.method({
  196. selector: "apply",
  197. protocol: 'actions',
  198. fn: function (){
  199. var self=this;
  200. function $HLKeyBinder(){return globals.HLKeyBinder||(typeof HLKeyBinder=="undefined"?nil:HLKeyBinder)}
  201. return smalltalk.withContext(function($ctx1) {
  202. var $1;
  203. $1=_st(self._command())._isInputRequired();
  204. if(smalltalk.assert($1)){
  205. _st(_st(_st($HLKeyBinder())._current())._helper())._showWidget_(self._inputWidget());
  206. } else {
  207. self._executeCommand();
  208. };
  209. return self}, function($ctx1) {$ctx1.fill(self,"apply",{},globals.HLBindingAction)})},
  210. args: [],
  211. source: "apply\x0a\x09self command isInputRequired\x0a\x09\x09ifTrue: [ HLKeyBinder current helper showWidget: self inputWidget ]\x0a\x09\x09ifFalse: [ self executeCommand ]",
  212. messageSends: ["ifTrue:ifFalse:", "isInputRequired", "command", "showWidget:", "helper", "current", "inputWidget", "executeCommand"],
  213. referencedClasses: ["HLKeyBinder"]
  214. }),
  215. globals.HLBindingAction);
  216. smalltalk.addMethod(
  217. smalltalk.method({
  218. selector: "command",
  219. protocol: 'accessing',
  220. fn: function (){
  221. var self=this;
  222. var $1;
  223. $1=self["@command"];
  224. return $1;
  225. },
  226. args: [],
  227. source: "command\x0a\x09^ command",
  228. messageSends: [],
  229. referencedClasses: []
  230. }),
  231. globals.HLBindingAction);
  232. smalltalk.addMethod(
  233. smalltalk.method({
  234. selector: "command:",
  235. protocol: 'accessing',
  236. fn: function (aCommand){
  237. var self=this;
  238. self["@command"]=aCommand;
  239. return self},
  240. args: ["aCommand"],
  241. source: "command: aCommand\x0a\x09command := aCommand",
  242. messageSends: [],
  243. referencedClasses: []
  244. }),
  245. globals.HLBindingAction);
  246. smalltalk.addMethod(
  247. smalltalk.method({
  248. selector: "executeCommand",
  249. protocol: 'actions',
  250. fn: function (){
  251. var self=this;
  252. function $HLKeyBinder(){return globals.HLKeyBinder||(typeof HLKeyBinder=="undefined"?nil:HLKeyBinder)}
  253. return smalltalk.withContext(function($ctx1) {
  254. _st(self._command())._execute();
  255. _st(_st($HLKeyBinder())._current())._deactivate();
  256. return self}, function($ctx1) {$ctx1.fill(self,"executeCommand",{},globals.HLBindingAction)})},
  257. args: [],
  258. source: "executeCommand\x0a\x09self command execute.\x0a\x09HLKeyBinder current deactivate",
  259. messageSends: ["execute", "command", "deactivate", "current"],
  260. referencedClasses: ["HLKeyBinder"]
  261. }),
  262. globals.HLBindingAction);
  263. smalltalk.addMethod(
  264. smalltalk.method({
  265. selector: "input:",
  266. protocol: 'accessing',
  267. fn: function (aString){
  268. var self=this;
  269. return smalltalk.withContext(function($ctx1) {
  270. _st(self._command())._input_(aString);
  271. return self}, function($ctx1) {$ctx1.fill(self,"input:",{aString:aString},globals.HLBindingAction)})},
  272. args: ["aString"],
  273. source: "input: aString\x0a\x09self command input: aString",
  274. messageSends: ["input:", "command"],
  275. referencedClasses: []
  276. }),
  277. globals.HLBindingAction);
  278. smalltalk.addMethod(
  279. smalltalk.method({
  280. selector: "inputBinding",
  281. protocol: 'accessing',
  282. fn: function (){
  283. var self=this;
  284. function $HLBindingInput(){return globals.HLBindingInput||(typeof HLBindingInput=="undefined"?nil:HLBindingInput)}
  285. return smalltalk.withContext(function($ctx1) {
  286. var $2,$3,$5,$4,$6,$8,$7,$9,$11,$10,$12,$14,$13,$15,$16,$17,$1;
  287. $2=_st($HLBindingInput())._new();
  288. $3=$2;
  289. $5=self._command();
  290. $ctx1.sendIdx["command"]=1;
  291. $4=_st($5)._inputLabel();
  292. _st($3)._label_($4);
  293. $6=$2;
  294. $8=self._command();
  295. $ctx1.sendIdx["command"]=2;
  296. $7=_st($8)._displayLabel();
  297. _st($6)._ghostText_($7);
  298. $9=$2;
  299. $11=self._command();
  300. $ctx1.sendIdx["command"]=3;
  301. $10=_st($11)._defaultInput();
  302. _st($9)._defaultValue_($10);
  303. $12=$2;
  304. $14=self._command();
  305. $ctx1.sendIdx["command"]=4;
  306. $13=_st($14)._inputCompletion();
  307. _st($12)._inputCompletion_($13);
  308. _st($2)._callback_((function(val){
  309. return smalltalk.withContext(function($ctx2) {
  310. $15=self._command();
  311. _st($15)._input_(val);
  312. $16=_st($15)._execute();
  313. return $16;
  314. }, function($ctx2) {$ctx2.fillBlock({val:val},$ctx1,1)})}));
  315. $17=_st($2)._yourself();
  316. $1=$17;
  317. return $1;
  318. }, function($ctx1) {$ctx1.fill(self,"inputBinding",{},globals.HLBindingAction)})},
  319. args: [],
  320. source: "inputBinding\x0a\x09^ HLBindingInput new\x0a\x09\x09label: self command inputLabel;\x0a\x09\x09ghostText: self command displayLabel;\x0a\x09\x09defaultValue: self command defaultInput;\x0a\x09\x09inputCompletion: self command inputCompletion;\x0a\x09\x09callback: [ :val | \x0a\x09\x09\x09self command \x0a\x09\x09\x09\x09input: val;\x0a\x09\x09\x09\x09execute ];\x0a\x09\x09yourself",
  321. messageSends: ["label:", "new", "inputLabel", "command", "ghostText:", "displayLabel", "defaultValue:", "defaultInput", "inputCompletion:", "inputCompletion", "callback:", "input:", "execute", "yourself"],
  322. referencedClasses: ["HLBindingInput"]
  323. }),
  324. globals.HLBindingAction);
  325. smalltalk.addMethod(
  326. smalltalk.method({
  327. selector: "inputWidget",
  328. protocol: 'accessing',
  329. fn: function (){
  330. var self=this;
  331. function $HLBindingActionInputWidget(){return globals.HLBindingActionInputWidget||(typeof HLBindingActionInputWidget=="undefined"?nil:HLBindingActionInputWidget)}
  332. return smalltalk.withContext(function($ctx1) {
  333. var $2,$3,$5,$4,$6,$8,$7,$9,$10,$1;
  334. $2=_st($HLBindingActionInputWidget())._new();
  335. $3=$2;
  336. $5=self._command();
  337. $ctx1.sendIdx["command"]=1;
  338. $4=_st($5)._displayLabel();
  339. _st($3)._ghostText_($4);
  340. $6=$2;
  341. $8=self._command();
  342. $ctx1.sendIdx["command"]=2;
  343. $7=_st($8)._defaultInput();
  344. _st($6)._defaultValue_($7);
  345. _st($2)._inputCompletion_(_st(self._command())._inputCompletion());
  346. _st($2)._callback_((function(value){
  347. return smalltalk.withContext(function($ctx2) {
  348. self._input_(value);
  349. $9=self._executeCommand();
  350. return $9;
  351. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1,1)})}));
  352. $10=_st($2)._yourself();
  353. $1=$10;
  354. return $1;
  355. }, function($ctx1) {$ctx1.fill(self,"inputWidget",{},globals.HLBindingAction)})},
  356. args: [],
  357. source: "inputWidget\x0a\x09^ HLBindingActionInputWidget new\x0a\x09\x09ghostText: self command displayLabel;\x0a\x09\x09defaultValue: self command defaultInput;\x0a\x09\x09inputCompletion: self command inputCompletion;\x0a\x09\x09callback: [ :value | \x0a\x09\x09\x09self \x0a\x09\x09\x09\x09input: value;\x0a\x09\x09\x09\x09executeCommand ];\x0a\x09\x09yourself",
  358. messageSends: ["ghostText:", "new", "displayLabel", "command", "defaultValue:", "defaultInput", "inputCompletion:", "inputCompletion", "callback:", "input:", "executeCommand", "yourself"],
  359. referencedClasses: ["HLBindingActionInputWidget"]
  360. }),
  361. globals.HLBindingAction);
  362. smalltalk.addMethod(
  363. smalltalk.method({
  364. selector: "isActive",
  365. protocol: 'testing',
  366. fn: function (){
  367. var self=this;
  368. return smalltalk.withContext(function($ctx1) {
  369. var $1;
  370. $1=_st(self._command())._isActive();
  371. return $1;
  372. }, function($ctx1) {$ctx1.fill(self,"isActive",{},globals.HLBindingAction)})},
  373. args: [],
  374. source: "isActive\x0a\x09^ self command isActive",
  375. messageSends: ["isActive", "command"],
  376. referencedClasses: []
  377. }),
  378. globals.HLBindingAction);
  379. smalltalk.addClass('HLBindingGroup', globals.HLBinding, ['bindings'], 'Helios-KeyBindings');
  380. globals.HLBindingGroup.comment="My instances hold other bindings, either actions or groups, and do not have actions by themselves.\x0a\x0aChildren are accessed with `atKey:` and added with the `add*` methods.";
  381. smalltalk.addMethod(
  382. smalltalk.method({
  383. selector: "activeBindings",
  384. protocol: 'accessing',
  385. fn: function (){
  386. var self=this;
  387. return smalltalk.withContext(function($ctx1) {
  388. var $1;
  389. $1=_st(self._bindings())._select_((function(each){
  390. return smalltalk.withContext(function($ctx2) {
  391. return _st(each)._isActive();
  392. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  393. return $1;
  394. }, function($ctx1) {$ctx1.fill(self,"activeBindings",{},globals.HLBindingGroup)})},
  395. args: [],
  396. source: "activeBindings\x0a\x09^ self bindings select: [ :each | each isActive ]",
  397. messageSends: ["select:", "bindings", "isActive"],
  398. referencedClasses: []
  399. }),
  400. globals.HLBindingGroup);
  401. smalltalk.addMethod(
  402. smalltalk.method({
  403. selector: "add:",
  404. protocol: 'adding',
  405. fn: function (aBinding){
  406. var self=this;
  407. return smalltalk.withContext(function($ctx1) {
  408. var $1;
  409. $1=_st(self._bindings())._add_(aBinding);
  410. return $1;
  411. }, function($ctx1) {$ctx1.fill(self,"add:",{aBinding:aBinding},globals.HLBindingGroup)})},
  412. args: ["aBinding"],
  413. source: "add: aBinding\x0a\x09^ self bindings add: aBinding",
  414. messageSends: ["add:", "bindings"],
  415. referencedClasses: []
  416. }),
  417. globals.HLBindingGroup);
  418. smalltalk.addMethod(
  419. smalltalk.method({
  420. selector: "addActionKey:labelled:callback:",
  421. protocol: 'adding',
  422. fn: function (anInteger,aString,aBlock){
  423. var self=this;
  424. function $HLBindingAction(){return globals.HLBindingAction||(typeof HLBindingAction=="undefined"?nil:HLBindingAction)}
  425. return smalltalk.withContext(function($ctx1) {
  426. var $1,$2;
  427. $1=_st($HLBindingAction())._on_labelled_(anInteger,aString);
  428. _st($1)._callback_(aBlock);
  429. $2=_st($1)._yourself();
  430. self._add_($2);
  431. return self}, function($ctx1) {$ctx1.fill(self,"addActionKey:labelled:callback:",{anInteger:anInteger,aString:aString,aBlock:aBlock},globals.HLBindingGroup)})},
  432. args: ["anInteger", "aString", "aBlock"],
  433. source: "addActionKey: anInteger labelled: aString callback: aBlock\x0a\x09self add: ((HLBindingAction on: anInteger labelled: aString)\x0a \x09callback: aBlock;\x0a yourself)",
  434. messageSends: ["add:", "callback:", "on:labelled:", "yourself"],
  435. referencedClasses: ["HLBindingAction"]
  436. }),
  437. globals.HLBindingGroup);
  438. smalltalk.addMethod(
  439. smalltalk.method({
  440. selector: "addGroupKey:labelled:",
  441. protocol: 'add',
  442. fn: function (anInteger,aString){
  443. var self=this;
  444. function $HLBindingGroup(){return globals.HLBindingGroup||(typeof HLBindingGroup=="undefined"?nil:HLBindingGroup)}
  445. return smalltalk.withContext(function($ctx1) {
  446. self._add_(_st($HLBindingGroup())._on_labelled_(anInteger,aString));
  447. return self}, function($ctx1) {$ctx1.fill(self,"addGroupKey:labelled:",{anInteger:anInteger,aString:aString},globals.HLBindingGroup)})},
  448. args: ["anInteger", "aString"],
  449. source: "addGroupKey: anInteger labelled: aString\x0a\x09self add: (HLBindingGroup on: anInteger labelled: aString)",
  450. messageSends: ["add:", "on:labelled:"],
  451. referencedClasses: ["HLBindingGroup"]
  452. }),
  453. globals.HLBindingGroup);
  454. smalltalk.addMethod(
  455. smalltalk.method({
  456. selector: "at:",
  457. protocol: 'accessing',
  458. fn: function (aString){
  459. var self=this;
  460. return smalltalk.withContext(function($ctx1) {
  461. var $1;
  462. $1=_st(self._bindings())._detect_ifNone_((function(each){
  463. return smalltalk.withContext(function($ctx2) {
  464. return _st(_st(each)._label()).__eq(aString);
  465. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),(function(){
  466. return smalltalk.withContext(function($ctx2) {
  467. return nil;
  468. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  469. return $1;
  470. }, function($ctx1) {$ctx1.fill(self,"at:",{aString:aString},globals.HLBindingGroup)})},
  471. args: ["aString"],
  472. source: "at: aString\x0a\x09^ self bindings \x0a \x09detect: [ :each | each label = aString ]\x0a \x09ifNone: [ nil ]",
  473. messageSends: ["detect:ifNone:", "bindings", "=", "label"],
  474. referencedClasses: []
  475. }),
  476. globals.HLBindingGroup);
  477. smalltalk.addMethod(
  478. smalltalk.method({
  479. selector: "at:add:",
  480. protocol: 'accessing',
  481. fn: function (aString,aBinding){
  482. var self=this;
  483. var binding;
  484. return smalltalk.withContext(function($ctx1) {
  485. var $1;
  486. binding=self._at_(aString);
  487. $1=binding;
  488. if(($receiver = $1) == nil || $receiver == null){
  489. return self;
  490. } else {
  491. $1;
  492. };
  493. _st(binding)._add_(aBinding);
  494. return self}, function($ctx1) {$ctx1.fill(self,"at:add:",{aString:aString,aBinding:aBinding,binding:binding},globals.HLBindingGroup)})},
  495. args: ["aString", "aBinding"],
  496. 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",
  497. messageSends: ["at:", "ifNil:", "add:"],
  498. referencedClasses: []
  499. }),
  500. globals.HLBindingGroup);
  501. smalltalk.addMethod(
  502. smalltalk.method({
  503. selector: "atKey:",
  504. protocol: 'accessing',
  505. fn: function (anInteger){
  506. var self=this;
  507. return smalltalk.withContext(function($ctx1) {
  508. var $1;
  509. $1=_st(self._bindings())._detect_ifNone_((function(each){
  510. return smalltalk.withContext(function($ctx2) {
  511. return _st(_st(each)._key()).__eq(anInteger);
  512. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),(function(){
  513. return smalltalk.withContext(function($ctx2) {
  514. return nil;
  515. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  516. return $1;
  517. }, function($ctx1) {$ctx1.fill(self,"atKey:",{anInteger:anInteger},globals.HLBindingGroup)})},
  518. args: ["anInteger"],
  519. source: "atKey: anInteger\x0a\x09^ self bindings \x0a \x09detect: [ :each | each key = anInteger ]\x0a \x09ifNone: [ nil ]",
  520. messageSends: ["detect:ifNone:", "bindings", "=", "key"],
  521. referencedClasses: []
  522. }),
  523. globals.HLBindingGroup);
  524. smalltalk.addMethod(
  525. smalltalk.method({
  526. selector: "bindings",
  527. protocol: 'accessing',
  528. fn: function (){
  529. var self=this;
  530. function $OrderedCollection(){return globals.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  531. return smalltalk.withContext(function($ctx1) {
  532. var $2,$1;
  533. $2=self["@bindings"];
  534. if(($receiver = $2) == nil || $receiver == null){
  535. self["@bindings"]=_st($OrderedCollection())._new();
  536. $1=self["@bindings"];
  537. } else {
  538. $1=$2;
  539. };
  540. return $1;
  541. }, function($ctx1) {$ctx1.fill(self,"bindings",{},globals.HLBindingGroup)})},
  542. args: [],
  543. source: "bindings\x0a\x09^ bindings ifNil: [ bindings := OrderedCollection new ]",
  544. messageSends: ["ifNil:", "new"],
  545. referencedClasses: ["OrderedCollection"]
  546. }),
  547. globals.HLBindingGroup);
  548. smalltalk.addMethod(
  549. smalltalk.method({
  550. selector: "displayLabel",
  551. protocol: 'accessing',
  552. fn: function (){
  553. var self=this;
  554. return smalltalk.withContext(function($ctx1) {
  555. var $1;
  556. $1=_st(globals.HLBindingGroup.superclass.fn.prototype._displayLabel.apply(_st(self), [])).__comma("...");
  557. return $1;
  558. }, function($ctx1) {$ctx1.fill(self,"displayLabel",{},globals.HLBindingGroup)})},
  559. args: [],
  560. source: "displayLabel\x0a\x09^ super displayLabel, '...'",
  561. messageSends: [",", "displayLabel"],
  562. referencedClasses: []
  563. }),
  564. globals.HLBindingGroup);
  565. smalltalk.addMethod(
  566. smalltalk.method({
  567. selector: "isActive",
  568. protocol: 'testing',
  569. fn: function (){
  570. var self=this;
  571. return smalltalk.withContext(function($ctx1) {
  572. var $1;
  573. $1=_st(self._activeBindings())._notEmpty();
  574. return $1;
  575. }, function($ctx1) {$ctx1.fill(self,"isActive",{},globals.HLBindingGroup)})},
  576. args: [],
  577. source: "isActive\x0a\x09^ self activeBindings notEmpty",
  578. messageSends: ["notEmpty", "activeBindings"],
  579. referencedClasses: []
  580. }),
  581. globals.HLBindingGroup);
  582. smalltalk.addMethod(
  583. smalltalk.method({
  584. selector: "release",
  585. protocol: 'actions',
  586. fn: function (){
  587. var self=this;
  588. return smalltalk.withContext(function($ctx1) {
  589. _st(self._bindings())._do_((function(each){
  590. return smalltalk.withContext(function($ctx2) {
  591. return _st(each)._release();
  592. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  593. return self}, function($ctx1) {$ctx1.fill(self,"release",{},globals.HLBindingGroup)})},
  594. args: [],
  595. source: "release\x0a\x09self bindings do: [ :each | each release ]",
  596. messageSends: ["do:", "bindings", "release"],
  597. referencedClasses: []
  598. }),
  599. globals.HLBindingGroup);
  600. smalltalk.addMethod(
  601. smalltalk.method({
  602. selector: "renderOn:html:",
  603. protocol: 'rendering',
  604. fn: function (aBindingHelper,html){
  605. var self=this;
  606. return smalltalk.withContext(function($ctx1) {
  607. var $1;
  608. $1=self._isActive();
  609. if(smalltalk.assert($1)){
  610. _st(aBindingHelper)._renderBindingGroup_on_(self,html);
  611. };
  612. return self}, function($ctx1) {$ctx1.fill(self,"renderOn:html:",{aBindingHelper:aBindingHelper,html:html},globals.HLBindingGroup)})},
  613. args: ["aBindingHelper", "html"],
  614. source: "renderOn: aBindingHelper html: html\x0a\x09self isActive ifTrue: [\x0a\x09\x09aBindingHelper renderBindingGroup: self on: html ]",
  615. messageSends: ["ifTrue:", "isActive", "renderBindingGroup:on:"],
  616. referencedClasses: []
  617. }),
  618. globals.HLBindingGroup);
  619. smalltalk.addClass('HLBindingActionInputWidget', globals.HLWidget, ['input', 'callback', 'status', 'wrapper', 'ghostText', 'message', 'inputCompletion', 'defaultValue', 'messageTag'], 'Helios-KeyBindings');
  620. globals.HLBindingActionInputWidget.comment="My instances are built when a `HLBindingAction` that requires user input is applied.";
  621. smalltalk.addMethod(
  622. smalltalk.method({
  623. selector: "callback",
  624. protocol: 'accessing',
  625. fn: function (){
  626. var self=this;
  627. return smalltalk.withContext(function($ctx1) {
  628. var $2,$1;
  629. $2=self["@callback"];
  630. if(($receiver = $2) == nil || $receiver == null){
  631. self["@callback"]=(function(value){
  632. return smalltalk.withContext(function($ctx2) {
  633. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1,2)})});
  634. $1=self["@callback"];
  635. } else {
  636. $1=$2;
  637. };
  638. return $1;
  639. }, function($ctx1) {$ctx1.fill(self,"callback",{},globals.HLBindingActionInputWidget)})},
  640. args: [],
  641. source: "callback\x0a\x09^ callback ifNil: [ callback := [ :value | ] ]",
  642. messageSends: ["ifNil:"],
  643. referencedClasses: []
  644. }),
  645. globals.HLBindingActionInputWidget);
  646. smalltalk.addMethod(
  647. smalltalk.method({
  648. selector: "callback:",
  649. protocol: 'accessing',
  650. fn: function (aBlock){
  651. var self=this;
  652. self["@callback"]=aBlock;
  653. return self},
  654. args: ["aBlock"],
  655. source: "callback: aBlock\x0a\x09callback := aBlock",
  656. messageSends: [],
  657. referencedClasses: []
  658. }),
  659. globals.HLBindingActionInputWidget);
  660. smalltalk.addMethod(
  661. smalltalk.method({
  662. selector: "clearStatus",
  663. protocol: 'actions',
  664. fn: function (){
  665. var self=this;
  666. return smalltalk.withContext(function($ctx1) {
  667. self._status_("info");
  668. self._message_("");
  669. self._refresh();
  670. return self}, function($ctx1) {$ctx1.fill(self,"clearStatus",{},globals.HLBindingActionInputWidget)})},
  671. args: [],
  672. source: "clearStatus\x0a\x09self status: 'info'.\x0a\x09self message: ''.\x0a\x09self refresh",
  673. messageSends: ["status:", "message:", "refresh"],
  674. referencedClasses: []
  675. }),
  676. globals.HLBindingActionInputWidget);
  677. smalltalk.addMethod(
  678. smalltalk.method({
  679. selector: "defaultValue",
  680. protocol: 'accessing',
  681. fn: function (){
  682. var self=this;
  683. return smalltalk.withContext(function($ctx1) {
  684. var $2,$1;
  685. $2=self["@defaultValue"];
  686. if(($receiver = $2) == nil || $receiver == null){
  687. $1="";
  688. } else {
  689. $1=$2;
  690. };
  691. return $1;
  692. }, function($ctx1) {$ctx1.fill(self,"defaultValue",{},globals.HLBindingActionInputWidget)})},
  693. args: [],
  694. source: "defaultValue\x0a\x09^ defaultValue ifNil: [ '' ]",
  695. messageSends: ["ifNil:"],
  696. referencedClasses: []
  697. }),
  698. globals.HLBindingActionInputWidget);
  699. smalltalk.addMethod(
  700. smalltalk.method({
  701. selector: "defaultValue:",
  702. protocol: 'accessing',
  703. fn: function (aString){
  704. var self=this;
  705. self["@defaultValue"]=aString;
  706. return self},
  707. args: ["aString"],
  708. source: "defaultValue: aString\x0a\x09defaultValue := aString",
  709. messageSends: [],
  710. referencedClasses: []
  711. }),
  712. globals.HLBindingActionInputWidget);
  713. smalltalk.addMethod(
  714. smalltalk.method({
  715. selector: "errorStatus",
  716. protocol: 'actions',
  717. fn: function (){
  718. var self=this;
  719. return smalltalk.withContext(function($ctx1) {
  720. self._status_("error");
  721. self._refresh();
  722. return self}, function($ctx1) {$ctx1.fill(self,"errorStatus",{},globals.HLBindingActionInputWidget)})},
  723. args: [],
  724. source: "errorStatus\x0a\x09self status: 'error'.\x0a\x09self refresh",
  725. messageSends: ["status:", "refresh"],
  726. referencedClasses: []
  727. }),
  728. globals.HLBindingActionInputWidget);
  729. smalltalk.addMethod(
  730. smalltalk.method({
  731. selector: "evaluate:",
  732. protocol: 'actions',
  733. fn: function (aString){
  734. var self=this;
  735. function $Error(){return globals.Error||(typeof Error=="undefined"?nil:Error)}
  736. return smalltalk.withContext(function($ctx1) {
  737. _st((function(){
  738. return smalltalk.withContext(function($ctx2) {
  739. return _st(self._callback())._value_(aString);
  740. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._on_do_($Error(),(function(ex){
  741. return smalltalk.withContext(function($ctx2) {
  742. _st(_st(self._input())._asJQuery())._one_do_("keydown",(function(){
  743. return smalltalk.withContext(function($ctx3) {
  744. return self._clearStatus();
  745. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
  746. self._message_(_st(ex)._messageText());
  747. return self._errorStatus();
  748. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1,2)})}));
  749. return self}, function($ctx1) {$ctx1.fill(self,"evaluate:",{aString:aString},globals.HLBindingActionInputWidget)})},
  750. args: ["aString"],
  751. source: "evaluate: aString\x09\x0a\x09[ self callback value: aString ]\x0a\x09\x09on: Error\x0a\x09\x09do: [ :ex |\x0a\x09\x09\x09self input asJQuery \x0a\x09\x09\x09\x09one: 'keydown' \x0a\x09\x09\x09\x09do: [ self clearStatus ].\x0a\x09\x09\x09self message: ex messageText.\x0a\x09\x09\x09self errorStatus ]",
  752. messageSends: ["on:do:", "value:", "callback", "one:do:", "asJQuery", "input", "clearStatus", "message:", "messageText", "errorStatus"],
  753. referencedClasses: ["Error"]
  754. }),
  755. globals.HLBindingActionInputWidget);
  756. smalltalk.addMethod(
  757. smalltalk.method({
  758. selector: "ghostText",
  759. protocol: 'accessing',
  760. fn: function (){
  761. var self=this;
  762. var $1;
  763. $1=self["@ghostText"];
  764. return $1;
  765. },
  766. args: [],
  767. source: "ghostText\x0a\x09^ ghostText",
  768. messageSends: [],
  769. referencedClasses: []
  770. }),
  771. globals.HLBindingActionInputWidget);
  772. smalltalk.addMethod(
  773. smalltalk.method({
  774. selector: "ghostText:",
  775. protocol: 'accessing',
  776. fn: function (aText){
  777. var self=this;
  778. self["@ghostText"]=aText;
  779. return self},
  780. args: ["aText"],
  781. source: "ghostText: aText\x0a\x09ghostText := aText",
  782. messageSends: [],
  783. referencedClasses: []
  784. }),
  785. globals.HLBindingActionInputWidget);
  786. smalltalk.addMethod(
  787. smalltalk.method({
  788. selector: "input",
  789. protocol: 'accessing',
  790. fn: function (){
  791. var self=this;
  792. var $1;
  793. $1=self["@input"];
  794. return $1;
  795. },
  796. args: [],
  797. source: "input\x0a\x09^ input",
  798. messageSends: [],
  799. referencedClasses: []
  800. }),
  801. globals.HLBindingActionInputWidget);
  802. smalltalk.addMethod(
  803. smalltalk.method({
  804. selector: "inputCompletion",
  805. protocol: 'accessing',
  806. fn: function (){
  807. var self=this;
  808. return smalltalk.withContext(function($ctx1) {
  809. var $2,$1;
  810. $2=self["@inputCompletion"];
  811. if(($receiver = $2) == nil || $receiver == null){
  812. $1=[];
  813. } else {
  814. $1=$2;
  815. };
  816. return $1;
  817. }, function($ctx1) {$ctx1.fill(self,"inputCompletion",{},globals.HLBindingActionInputWidget)})},
  818. args: [],
  819. source: "inputCompletion\x0a\x09^ inputCompletion ifNil: [ #() ]",
  820. messageSends: ["ifNil:"],
  821. referencedClasses: []
  822. }),
  823. globals.HLBindingActionInputWidget);
  824. smalltalk.addMethod(
  825. smalltalk.method({
  826. selector: "inputCompletion:",
  827. protocol: 'accessing',
  828. fn: function (aCollection){
  829. var self=this;
  830. self["@inputCompletion"]=aCollection;
  831. return self},
  832. args: ["aCollection"],
  833. source: "inputCompletion: aCollection\x0a\x09inputCompletion := aCollection",
  834. messageSends: [],
  835. referencedClasses: []
  836. }),
  837. globals.HLBindingActionInputWidget);
  838. smalltalk.addMethod(
  839. smalltalk.method({
  840. selector: "message",
  841. protocol: 'accessing',
  842. fn: function (){
  843. var self=this;
  844. return smalltalk.withContext(function($ctx1) {
  845. var $2,$1;
  846. $2=self["@message"];
  847. if(($receiver = $2) == nil || $receiver == null){
  848. self["@message"]="";
  849. $1=self["@message"];
  850. } else {
  851. $1=$2;
  852. };
  853. return $1;
  854. }, function($ctx1) {$ctx1.fill(self,"message",{},globals.HLBindingActionInputWidget)})},
  855. args: [],
  856. source: "message\x0a\x09^ message ifNil: [ message := '' ]",
  857. messageSends: ["ifNil:"],
  858. referencedClasses: []
  859. }),
  860. globals.HLBindingActionInputWidget);
  861. smalltalk.addMethod(
  862. smalltalk.method({
  863. selector: "message:",
  864. protocol: 'accessing',
  865. fn: function (aString){
  866. var self=this;
  867. self["@message"]=aString;
  868. return self},
  869. args: ["aString"],
  870. source: "message: aString\x0a\x09message := aString",
  871. messageSends: [],
  872. referencedClasses: []
  873. }),
  874. globals.HLBindingActionInputWidget);
  875. smalltalk.addMethod(
  876. smalltalk.method({
  877. selector: "refresh",
  878. protocol: 'actions',
  879. fn: function (){
  880. var self=this;
  881. return smalltalk.withContext(function($ctx1) {
  882. var $1;
  883. $1=self["@wrapper"];
  884. if(($receiver = $1) == nil || $receiver == null){
  885. return self;
  886. } else {
  887. $1;
  888. };
  889. _st(self["@wrapper"])._class_(self._status());
  890. _st(self["@messageTag"])._contents_(self._message());
  891. return self}, function($ctx1) {$ctx1.fill(self,"refresh",{},globals.HLBindingActionInputWidget)})},
  892. args: [],
  893. source: "refresh\x0a\x09wrapper ifNil: [ ^ self ].\x0a \x0a\x09wrapper class: self status.\x0a\x09messageTag contents: self message",
  894. messageSends: ["ifNil:", "class:", "status", "contents:", "message"],
  895. referencedClasses: []
  896. }),
  897. globals.HLBindingActionInputWidget);
  898. smalltalk.addMethod(
  899. smalltalk.method({
  900. selector: "renderOn:",
  901. protocol: 'rendering',
  902. fn: function (html){
  903. var self=this;
  904. return smalltalk.withContext(function($ctx1) {
  905. var $1,$2,$4,$6,$8,$10,$9,$7,$5,$11,$12,$13,$3;
  906. $1=self["@wrapper"];
  907. if(($receiver = $1) == nil || $receiver == null){
  908. self["@wrapper"]=_st(html)._span();
  909. $ctx1.sendIdx["span"]=1;
  910. self["@wrapper"];
  911. } else {
  912. $1;
  913. };
  914. $2=self["@wrapper"];
  915. _st($2)._class_(self._status());
  916. $ctx1.sendIdx["class:"]=1;
  917. $3=_st($2)._with_((function(){
  918. return smalltalk.withContext(function($ctx2) {
  919. $4=_st(html)._input();
  920. _st($4)._placeholder_(self._ghostText());
  921. _st($4)._value_(self._defaultValue());
  922. $6=$4;
  923. $7=_st((function(event){
  924. return smalltalk.withContext(function($ctx3) {
  925. $8=_st(_st(event)._which()).__eq((13));
  926. if(smalltalk.assert($8)){
  927. $10=_st(self["@input"])._asJQuery();
  928. $ctx3.sendIdx["asJQuery"]=1;
  929. $9=_st($10)._val();
  930. return self._evaluate_($9);
  931. };
  932. }, function($ctx3) {$ctx3.fillBlock({event:event},$ctx2,3)})}))._yourself();
  933. $ctx2.sendIdx["yourself"]=1;
  934. $5=_st($6)._onKeyDown_($7);
  935. self["@input"]=$5;
  936. self["@input"];
  937. $11=_st(self["@input"])._asJQuery();
  938. $ctx2.sendIdx["asJQuery"]=2;
  939. _st($11)._typeahead_(globals.HashedCollection._from_(["source".__minus_gt(self._inputCompletion())]));
  940. $12=_st(html)._span();
  941. _st($12)._class_("help-inline");
  942. _st($12)._with_(self._message());
  943. $13=_st($12)._yourself();
  944. self["@messageTag"]=$13;
  945. return self["@messageTag"];
  946. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  947. $ctx1.sendIdx["with:"]=1;
  948. _st((function(){
  949. return smalltalk.withContext(function($ctx2) {
  950. return _st(_st(self["@input"])._asJQuery())._focus();
  951. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,5)})}))._valueWithTimeout_((10));
  952. return self}, function($ctx1) {$ctx1.fill(self,"renderOn:",{html:html},globals.HLBindingActionInputWidget)})},
  953. args: ["html"],
  954. source: "renderOn: html\x0a\x09wrapper ifNil: [ wrapper := html span ].\x0a\x0a\x09wrapper \x0a\x09\x09class: self status;\x0a\x09\x09with: [\x0a\x09\x09\x09input := html input\x0a\x09\x09\x09\x09placeholder: self ghostText;\x0a\x09\x09\x09\x09value: self defaultValue;\x0a\x09\x09\x09\x09onKeyDown: [ :event | \x0a\x09\x09\x09\x09\x09event which = 13 ifTrue: [\x0a\x09\x09\x09\x09\x09\x09self evaluate: input asJQuery val ] ]\x0a\x09\x09\x09\x09yourself.\x0a\x09\x09\x09input asJQuery \x0a\x09\x09\x09\x09typeahead: #{ 'source' -> self inputCompletion }.\x0a\x09\x09\x09messageTag := (html span\x0a\x09\x09\x09\x09class: 'help-inline';\x0a\x09\x09\x09\x09with: self message;\x0a\x09\x09\x09\x09yourself) ].\x0a\x09\x0a\x09\x22Evaluate with a timeout to ensure focus.\x0a\x09Commands can be executed from a menu, clicking on the menu to\x0a\x09evaluate the command would give it the focus otherwise\x22\x0a\x09\x0a\x09[ input asJQuery focus ] valueWithTimeout: 10",
  955. messageSends: ["ifNil:", "span", "class:", "status", "with:", "placeholder:", "input", "ghostText", "value:", "defaultValue", "onKeyDown:", "yourself", "ifTrue:", "=", "which", "evaluate:", "val", "asJQuery", "typeahead:", "->", "inputCompletion", "message", "valueWithTimeout:", "focus"],
  956. referencedClasses: []
  957. }),
  958. globals.HLBindingActionInputWidget);
  959. smalltalk.addMethod(
  960. smalltalk.method({
  961. selector: "status",
  962. protocol: 'accessing',
  963. fn: function (){
  964. var self=this;
  965. return smalltalk.withContext(function($ctx1) {
  966. var $2,$1;
  967. $2=self["@status"];
  968. if(($receiver = $2) == nil || $receiver == null){
  969. self["@status"]="info";
  970. $1=self["@status"];
  971. } else {
  972. $1=$2;
  973. };
  974. return $1;
  975. }, function($ctx1) {$ctx1.fill(self,"status",{},globals.HLBindingActionInputWidget)})},
  976. args: [],
  977. source: "status\x0a\x09^ status ifNil: [ status := 'info' ]",
  978. messageSends: ["ifNil:"],
  979. referencedClasses: []
  980. }),
  981. globals.HLBindingActionInputWidget);
  982. smalltalk.addMethod(
  983. smalltalk.method({
  984. selector: "status:",
  985. protocol: 'accessing',
  986. fn: function (aStatus){
  987. var self=this;
  988. self["@status"]=aStatus;
  989. return self},
  990. args: ["aStatus"],
  991. source: "status: aStatus\x0a\x09status := aStatus",
  992. messageSends: [],
  993. referencedClasses: []
  994. }),
  995. globals.HLBindingActionInputWidget);
  996. smalltalk.addClass('HLKeyBinder', globals.Object, ['modifierKey', 'helper', 'bindings', 'selectedBinding'], 'Helios-KeyBindings');
  997. globals.HLKeyBinder.comment="My `current` instance holds keybindings for Helios actions and evaluate them.\x0a\x0aBindings can be nested by groups. The `bindings` instance variable holds the root of the key bindings tree.\x0a\x0aBindings are instances of a concrete subclass of `HLBinding`.\x0a\x0aI am always either in 'active' or 'inactive' state. In active state I capture key down events and my `helper` widget is displayed at the bottom of the window. My `selectedBinding`, if any, is displayed by the helper.\x0a\x0aBindings are evaluated through `applyBinding:`. If a binding is final (not a group of other bindings), evaluating it will result in deactivating the binder, and hiding the `helper` widget.";
  998. smalltalk.addMethod(
  999. smalltalk.method({
  1000. selector: "activate",
  1001. protocol: 'actions',
  1002. fn: function (){
  1003. var self=this;
  1004. return smalltalk.withContext(function($ctx1) {
  1005. _st(self._helper())._show();
  1006. return self}, function($ctx1) {$ctx1.fill(self,"activate",{},globals.HLKeyBinder)})},
  1007. args: [],
  1008. source: "activate\x0a\x09self helper show",
  1009. messageSends: ["show", "helper"],
  1010. referencedClasses: []
  1011. }),
  1012. globals.HLKeyBinder);
  1013. smalltalk.addMethod(
  1014. smalltalk.method({
  1015. selector: "activationKey",
  1016. protocol: 'accessing',
  1017. fn: function (){
  1018. var self=this;
  1019. return (32);
  1020. },
  1021. args: [],
  1022. source: "activationKey\x0a\x09\x22SPACE\x22\x0a\x09^ 32",
  1023. messageSends: [],
  1024. referencedClasses: []
  1025. }),
  1026. globals.HLKeyBinder);
  1027. smalltalk.addMethod(
  1028. smalltalk.method({
  1029. selector: "activationKeyLabel",
  1030. protocol: 'accessing',
  1031. fn: function (){
  1032. var self=this;
  1033. return "ctrl + space";
  1034. },
  1035. args: [],
  1036. source: "activationKeyLabel\x0a\x09^ 'ctrl + space'",
  1037. messageSends: [],
  1038. referencedClasses: []
  1039. }),
  1040. globals.HLKeyBinder);
  1041. smalltalk.addMethod(
  1042. smalltalk.method({
  1043. selector: "applyBinding:",
  1044. protocol: 'actions',
  1045. fn: function (aBinding){
  1046. var self=this;
  1047. return smalltalk.withContext(function($ctx1) {
  1048. var $1;
  1049. $1=_st(aBinding)._isActive();
  1050. if(! smalltalk.assert($1)){
  1051. return self;
  1052. };
  1053. self._selectBinding_(aBinding);
  1054. _st(aBinding)._apply();
  1055. return self}, function($ctx1) {$ctx1.fill(self,"applyBinding:",{aBinding:aBinding},globals.HLKeyBinder)})},
  1056. args: ["aBinding"],
  1057. source: "applyBinding: aBinding\x0a\x09aBinding isActive ifFalse: [ ^ self ].\x0a\x09\x0a\x09self selectBinding: aBinding.\x0a aBinding apply",
  1058. messageSends: ["ifFalse:", "isActive", "selectBinding:", "apply"],
  1059. referencedClasses: []
  1060. }),
  1061. globals.HLKeyBinder);
  1062. smalltalk.addMethod(
  1063. smalltalk.method({
  1064. selector: "bindings",
  1065. protocol: 'accessing',
  1066. fn: function (){
  1067. var self=this;
  1068. return smalltalk.withContext(function($ctx1) {
  1069. var $2,$1;
  1070. $2=self["@bindings"];
  1071. if(($receiver = $2) == nil || $receiver == null){
  1072. self["@bindings"]=self._defaultBindings();
  1073. $1=self["@bindings"];
  1074. } else {
  1075. $1=$2;
  1076. };
  1077. return $1;
  1078. }, function($ctx1) {$ctx1.fill(self,"bindings",{},globals.HLKeyBinder)})},
  1079. args: [],
  1080. source: "bindings\x0a\x09^ bindings ifNil: [ bindings := self defaultBindings ]",
  1081. messageSends: ["ifNil:", "defaultBindings"],
  1082. referencedClasses: []
  1083. }),
  1084. globals.HLKeyBinder);
  1085. smalltalk.addMethod(
  1086. smalltalk.method({
  1087. selector: "deactivate",
  1088. protocol: 'actions',
  1089. fn: function (){
  1090. var self=this;
  1091. return smalltalk.withContext(function($ctx1) {
  1092. var $1;
  1093. $1=self["@selectedBinding"];
  1094. if(($receiver = $1) == nil || $receiver == null){
  1095. $1;
  1096. } else {
  1097. _st(self["@selectedBinding"])._release();
  1098. };
  1099. self["@selectedBinding"]=nil;
  1100. _st(self._helper())._hide();
  1101. return self}, function($ctx1) {$ctx1.fill(self,"deactivate",{},globals.HLKeyBinder)})},
  1102. args: [],
  1103. source: "deactivate\x0a\x09selectedBinding ifNotNil: [ selectedBinding release ].\x0a selectedBinding := nil.\x0a\x09self helper hide",
  1104. messageSends: ["ifNotNil:", "release", "hide", "helper"],
  1105. referencedClasses: []
  1106. }),
  1107. globals.HLKeyBinder);
  1108. smalltalk.addMethod(
  1109. smalltalk.method({
  1110. selector: "defaultBindings",
  1111. protocol: 'defaults',
  1112. fn: function (){
  1113. var self=this;
  1114. var group;
  1115. function $HLBindingGroup(){return globals.HLBindingGroup||(typeof HLBindingGroup=="undefined"?nil:HLBindingGroup)}
  1116. function $HLCloseTabCommand(){return globals.HLCloseTabCommand||(typeof HLCloseTabCommand=="undefined"?nil:HLCloseTabCommand)}
  1117. function $HLSwitchTabCommand(){return globals.HLSwitchTabCommand||(typeof HLSwitchTabCommand=="undefined"?nil:HLSwitchTabCommand)}
  1118. function $HLOpenCommand(){return globals.HLOpenCommand||(typeof HLOpenCommand=="undefined"?nil:HLOpenCommand)}
  1119. return smalltalk.withContext(function($ctx1) {
  1120. var $1,$2,$4,$3,$5,$6;
  1121. $1=_st($HLBindingGroup())._new();
  1122. $ctx1.sendIdx["new"]=1;
  1123. $2=$1;
  1124. $4=_st($HLCloseTabCommand())._new();
  1125. $ctx1.sendIdx["new"]=2;
  1126. $3=_st($4)._asBinding();
  1127. $ctx1.sendIdx["asBinding"]=1;
  1128. _st($2)._add_($3);
  1129. $ctx1.sendIdx["add:"]=1;
  1130. _st($1)._add_(_st(_st($HLSwitchTabCommand())._new())._asBinding());
  1131. $5=_st($1)._yourself();
  1132. group=$5;
  1133. _st($HLOpenCommand())._registerConcreteClassesOn_(group);
  1134. $6=group;
  1135. return $6;
  1136. }, function($ctx1) {$ctx1.fill(self,"defaultBindings",{group:group},globals.HLKeyBinder)})},
  1137. args: [],
  1138. source: "defaultBindings\x0a\x09| group |\x0a\x09\x0a\x09group := HLBindingGroup new\x0a\x09\x09add: HLCloseTabCommand new asBinding;\x0a\x09\x09add: HLSwitchTabCommand new asBinding;\x0a\x09\x09yourself.\x0a\x09\x09\x0a\x09HLOpenCommand registerConcreteClassesOn: group.\x0a\x09\x09\x09\x09\x0a\x09^ group",
  1139. messageSends: ["add:", "new", "asBinding", "yourself", "registerConcreteClassesOn:"],
  1140. referencedClasses: ["HLBindingGroup", "HLCloseTabCommand", "HLSwitchTabCommand", "HLOpenCommand"]
  1141. }),
  1142. globals.HLKeyBinder);
  1143. smalltalk.addMethod(
  1144. smalltalk.method({
  1145. selector: "escapeKey",
  1146. protocol: 'accessing',
  1147. fn: function (){
  1148. var self=this;
  1149. return (27);
  1150. },
  1151. args: [],
  1152. source: "escapeKey\x0a\x09\x22ESC\x22\x0a\x09^ 27",
  1153. messageSends: [],
  1154. referencedClasses: []
  1155. }),
  1156. globals.HLKeyBinder);
  1157. smalltalk.addMethod(
  1158. smalltalk.method({
  1159. selector: "flushBindings",
  1160. protocol: 'actions',
  1161. fn: function (){
  1162. var self=this;
  1163. self["@bindings"]=nil;
  1164. return self},
  1165. args: [],
  1166. source: "flushBindings\x0a\x09bindings := nil",
  1167. messageSends: [],
  1168. referencedClasses: []
  1169. }),
  1170. globals.HLKeyBinder);
  1171. smalltalk.addMethod(
  1172. smalltalk.method({
  1173. selector: "handleActiveKeyDown:",
  1174. protocol: 'events',
  1175. fn: function (event){
  1176. var self=this;
  1177. return smalltalk.withContext(function($ctx1) {
  1178. var $3,$2,$1,$4;
  1179. $3=_st(event)._which();
  1180. $ctx1.sendIdx["which"]=1;
  1181. $2=_st($3).__eq(self._escapeKey());
  1182. $ctx1.sendIdx["="]=1;
  1183. $1=_st($2)._or_((function(){
  1184. return smalltalk.withContext(function($ctx2) {
  1185. return _st(_st(_st(event)._which()).__eq((71)))._and_((function(){
  1186. return smalltalk.withContext(function($ctx3) {
  1187. return _st(event)._ctrlKey();
  1188. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
  1189. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1190. if(smalltalk.assert($1)){
  1191. self._deactivate();
  1192. _st(event)._preventDefault();
  1193. return false;
  1194. };
  1195. $4=self._handleBindingFor_(event);
  1196. return $4;
  1197. }, function($ctx1) {$ctx1.fill(self,"handleActiveKeyDown:",{event:event},globals.HLKeyBinder)})},
  1198. args: ["event"],
  1199. 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",
  1200. messageSends: ["ifTrue:", "or:", "=", "which", "escapeKey", "and:", "ctrlKey", "deactivate", "preventDefault", "handleBindingFor:"],
  1201. referencedClasses: []
  1202. }),
  1203. globals.HLKeyBinder);
  1204. smalltalk.addMethod(
  1205. smalltalk.method({
  1206. selector: "handleBindingFor:",
  1207. protocol: 'events',
  1208. fn: function (anEvent){
  1209. var self=this;
  1210. var binding;
  1211. return smalltalk.withContext(function($ctx1) {
  1212. var $1;
  1213. binding=_st(self._selectedBinding())._atKey_(_st(anEvent)._which());
  1214. $1=binding;
  1215. if(($receiver = $1) == nil || $receiver == null){
  1216. $1;
  1217. } else {
  1218. self._applyBinding_(binding);
  1219. _st(anEvent)._preventDefault();
  1220. return false;
  1221. };
  1222. return self}, function($ctx1) {$ctx1.fill(self,"handleBindingFor:",{anEvent:anEvent,binding:binding},globals.HLKeyBinder)})},
  1223. args: ["anEvent"],
  1224. 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 ]",
  1225. messageSends: ["atKey:", "selectedBinding", "which", "ifNotNil:", "applyBinding:", "preventDefault"],
  1226. referencedClasses: []
  1227. }),
  1228. globals.HLKeyBinder);
  1229. smalltalk.addMethod(
  1230. smalltalk.method({
  1231. selector: "handleInactiveKeyDown:",
  1232. protocol: 'events',
  1233. fn: function (event){
  1234. var self=this;
  1235. return smalltalk.withContext(function($ctx1) {
  1236. var $1,$2;
  1237. $1=_st(_st(event)._which()).__eq(self._activationKey());
  1238. if(smalltalk.assert($1)){
  1239. $2=_st(event)._ctrlKey();
  1240. if(smalltalk.assert($2)){
  1241. self._activate();
  1242. _st(event)._preventDefault();
  1243. return false;
  1244. };
  1245. };
  1246. return self}, function($ctx1) {$ctx1.fill(self,"handleInactiveKeyDown:",{event:event},globals.HLKeyBinder)})},
  1247. args: ["event"],
  1248. source: "handleInactiveKeyDown: event\x0a\x09event which = self activationKey ifTrue: [\x0a \x09event ctrlKey ifTrue: [\x0a\x09\x09\x09self activate. \x0a event preventDefault. \x0a ^ false ] ]",
  1249. messageSends: ["ifTrue:", "=", "which", "activationKey", "ctrlKey", "activate", "preventDefault"],
  1250. referencedClasses: []
  1251. }),
  1252. globals.HLKeyBinder);
  1253. smalltalk.addMethod(
  1254. smalltalk.method({
  1255. selector: "handleKeyDown:",
  1256. protocol: 'events',
  1257. fn: function (event){
  1258. var self=this;
  1259. return smalltalk.withContext(function($ctx1) {
  1260. var $2,$1;
  1261. $2=self._isActive();
  1262. if(smalltalk.assert($2)){
  1263. $1=self._handleActiveKeyDown_(event);
  1264. } else {
  1265. $1=self._handleInactiveKeyDown_(event);
  1266. };
  1267. return $1;
  1268. }, function($ctx1) {$ctx1.fill(self,"handleKeyDown:",{event:event},globals.HLKeyBinder)})},
  1269. args: ["event"],
  1270. source: "handleKeyDown: event\x0a\x09^ self isActive\x0a \x09ifTrue: [ self handleActiveKeyDown: event ]\x0a \x09ifFalse: [ self handleInactiveKeyDown: event ]",
  1271. messageSends: ["ifTrue:ifFalse:", "isActive", "handleActiveKeyDown:", "handleInactiveKeyDown:"],
  1272. referencedClasses: []
  1273. }),
  1274. globals.HLKeyBinder);
  1275. smalltalk.addMethod(
  1276. smalltalk.method({
  1277. selector: "helper",
  1278. protocol: 'accessing',
  1279. fn: function (){
  1280. var self=this;
  1281. var $1;
  1282. $1=self["@helper"];
  1283. return $1;
  1284. },
  1285. args: [],
  1286. source: "helper\x0a\x09^ helper",
  1287. messageSends: [],
  1288. referencedClasses: []
  1289. }),
  1290. globals.HLKeyBinder);
  1291. smalltalk.addMethod(
  1292. smalltalk.method({
  1293. selector: "initialize",
  1294. protocol: 'initialization',
  1295. fn: function (){
  1296. var self=this;
  1297. function $HLKeyBinderHelperWidget(){return globals.HLKeyBinderHelperWidget||(typeof HLKeyBinderHelperWidget=="undefined"?nil:HLKeyBinderHelperWidget)}
  1298. return smalltalk.withContext(function($ctx1) {
  1299. globals.HLKeyBinder.superclass.fn.prototype._initialize.apply(_st(self), []);
  1300. self["@helper"]=_st($HLKeyBinderHelperWidget())._on_(self);
  1301. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.HLKeyBinder)})},
  1302. args: [],
  1303. source: "initialize\x0a\x09super initialize.\x0a\x09helper := HLKeyBinderHelperWidget on: self",
  1304. messageSends: ["initialize", "on:"],
  1305. referencedClasses: ["HLKeyBinderHelperWidget"]
  1306. }),
  1307. globals.HLKeyBinder);
  1308. smalltalk.addMethod(
  1309. smalltalk.method({
  1310. selector: "isActive",
  1311. protocol: 'testing',
  1312. fn: function (){
  1313. var self=this;
  1314. return smalltalk.withContext(function($ctx1) {
  1315. var $1;
  1316. $1=_st(_st(".".__comma(_st(self._helper())._cssClass()))._asJQuery())._is_(":visible");
  1317. return $1;
  1318. }, function($ctx1) {$ctx1.fill(self,"isActive",{},globals.HLKeyBinder)})},
  1319. args: [],
  1320. source: "isActive\x0a\x09^ ('.', self helper cssClass) asJQuery is: ':visible'",
  1321. messageSends: ["is:", "asJQuery", ",", "cssClass", "helper"],
  1322. referencedClasses: []
  1323. }),
  1324. globals.HLKeyBinder);
  1325. smalltalk.addMethod(
  1326. smalltalk.method({
  1327. selector: "selectBinding:",
  1328. protocol: 'actions',
  1329. fn: function (aBinding){
  1330. var self=this;
  1331. return smalltalk.withContext(function($ctx1) {
  1332. var $1;
  1333. $1=_st(aBinding).__eq(self["@selectedBinding"]);
  1334. if(smalltalk.assert($1)){
  1335. return self;
  1336. };
  1337. self["@selectedBinding"]=aBinding;
  1338. _st(self._helper())._refresh();
  1339. return self}, function($ctx1) {$ctx1.fill(self,"selectBinding:",{aBinding:aBinding},globals.HLKeyBinder)})},
  1340. args: ["aBinding"],
  1341. source: "selectBinding: aBinding\x0a\x09aBinding = selectedBinding ifTrue: [ ^ self ].\x0a\x09\x0a\x09selectedBinding := aBinding.\x0a\x09self helper refresh",
  1342. messageSends: ["ifTrue:", "=", "refresh", "helper"],
  1343. referencedClasses: []
  1344. }),
  1345. globals.HLKeyBinder);
  1346. smalltalk.addMethod(
  1347. smalltalk.method({
  1348. selector: "selectedBinding",
  1349. protocol: 'accessing',
  1350. fn: function (){
  1351. var self=this;
  1352. return smalltalk.withContext(function($ctx1) {
  1353. var $2,$1;
  1354. $2=self["@selectedBinding"];
  1355. if(($receiver = $2) == nil || $receiver == null){
  1356. $1=self._bindings();
  1357. } else {
  1358. $1=$2;
  1359. };
  1360. return $1;
  1361. }, function($ctx1) {$ctx1.fill(self,"selectedBinding",{},globals.HLKeyBinder)})},
  1362. args: [],
  1363. source: "selectedBinding\x0a\x09^ selectedBinding ifNil: [ self bindings ]",
  1364. messageSends: ["ifNil:", "bindings"],
  1365. referencedClasses: []
  1366. }),
  1367. globals.HLKeyBinder);
  1368. smalltalk.addMethod(
  1369. smalltalk.method({
  1370. selector: "setupEvents",
  1371. protocol: 'events',
  1372. fn: function (){
  1373. var self=this;
  1374. return smalltalk.withContext(function($ctx1) {
  1375. _st("body"._asJQuery())._keydown_((function(event){
  1376. return smalltalk.withContext(function($ctx2) {
  1377. return self._handleKeyDown_(event);
  1378. }, function($ctx2) {$ctx2.fillBlock({event:event},$ctx1,1)})}));
  1379. return self}, function($ctx1) {$ctx1.fill(self,"setupEvents",{},globals.HLKeyBinder)})},
  1380. args: [],
  1381. source: "setupEvents\x0a\x09'body' asJQuery keydown: [ :event | self handleKeyDown: event ]",
  1382. messageSends: ["keydown:", "asJQuery", "handleKeyDown:"],
  1383. referencedClasses: []
  1384. }),
  1385. globals.HLKeyBinder);
  1386. smalltalk.addMethod(
  1387. smalltalk.method({
  1388. selector: "setupHelper",
  1389. protocol: 'initialization',
  1390. fn: function (){
  1391. var self=this;
  1392. return smalltalk.withContext(function($ctx1) {
  1393. var $1,$2;
  1394. $1=self["@helper"];
  1395. _st($1)._renderStart();
  1396. $2=_st($1)._renderCog();
  1397. return self}, function($ctx1) {$ctx1.fill(self,"setupHelper",{},globals.HLKeyBinder)})},
  1398. args: [],
  1399. source: "setupHelper\x0a\x09helper \x09\x0a\x09\x09renderStart;\x0a\x09\x09renderCog",
  1400. messageSends: ["renderStart", "renderCog"],
  1401. referencedClasses: []
  1402. }),
  1403. globals.HLKeyBinder);
  1404. smalltalk.addMethod(
  1405. smalltalk.method({
  1406. selector: "systemIsMac",
  1407. protocol: 'testing',
  1408. fn: function (){
  1409. var self=this;
  1410. return smalltalk.withContext(function($ctx1) {
  1411. var $1;
  1412. $1=_st(_st(navigator)._platform())._match_("Mac");
  1413. return $1;
  1414. }, function($ctx1) {$ctx1.fill(self,"systemIsMac",{},globals.HLKeyBinder)})},
  1415. args: [],
  1416. source: "systemIsMac\x0a\x09^ navigator platform match: 'Mac'",
  1417. messageSends: ["match:", "platform"],
  1418. referencedClasses: []
  1419. }),
  1420. globals.HLKeyBinder);
  1421. globals.HLKeyBinder.klass.iVarNames = ['current'];
  1422. smalltalk.addMethod(
  1423. smalltalk.method({
  1424. selector: "current",
  1425. protocol: 'instance creation',
  1426. fn: function (){
  1427. var self=this;
  1428. return smalltalk.withContext(function($ctx1) {
  1429. var $2,$1;
  1430. $2=self["@current"];
  1431. if(($receiver = $2) == nil || $receiver == null){
  1432. self["@current"]=globals.HLKeyBinder.klass.superclass.fn.prototype._new.apply(_st(self), []);
  1433. $1=self["@current"];
  1434. } else {
  1435. $1=$2;
  1436. };
  1437. return $1;
  1438. }, function($ctx1) {$ctx1.fill(self,"current",{},globals.HLKeyBinder.klass)})},
  1439. args: [],
  1440. source: "current\x0a\x09^ current ifNil: [ current := super new ]",
  1441. messageSends: ["ifNil:", "new"],
  1442. referencedClasses: []
  1443. }),
  1444. globals.HLKeyBinder.klass);
  1445. smalltalk.addMethod(
  1446. smalltalk.method({
  1447. selector: "new",
  1448. protocol: 'instance creation',
  1449. fn: function (){
  1450. var self=this;
  1451. return smalltalk.withContext(function($ctx1) {
  1452. self._shouldNotImplement();
  1453. return self}, function($ctx1) {$ctx1.fill(self,"new",{},globals.HLKeyBinder.klass)})},
  1454. args: [],
  1455. source: "new\x0a\x09self shouldNotImplement",
  1456. messageSends: ["shouldNotImplement"],
  1457. referencedClasses: []
  1458. }),
  1459. globals.HLKeyBinder.klass);
  1460. smalltalk.addClass('HLKeyBinderHelperWidget', globals.HLWidget, ['keyBinder'], 'Helios-KeyBindings');
  1461. globals.HLKeyBinderHelperWidget.comment="I am the widget responsible for displaying active keybindings in a bar at the bottom of the window. Each keybinding is an instance of `HLBinding`. \x0a\x0aRendering is done through a double dispatch, see `#renderSelectedBindingOn:`.";
  1462. smalltalk.addMethod(
  1463. smalltalk.method({
  1464. selector: "cssClass",
  1465. protocol: 'accessing',
  1466. fn: function (){
  1467. var self=this;
  1468. return "key_helper";
  1469. },
  1470. args: [],
  1471. source: "cssClass\x0a\x09^ 'key_helper'",
  1472. messageSends: [],
  1473. referencedClasses: []
  1474. }),
  1475. globals.HLKeyBinderHelperWidget);
  1476. smalltalk.addMethod(
  1477. smalltalk.method({
  1478. selector: "deactivate",
  1479. protocol: 'actions',
  1480. fn: function (){
  1481. var self=this;
  1482. return smalltalk.withContext(function($ctx1) {
  1483. _st(self._keyBinder())._deactivate();
  1484. return self}, function($ctx1) {$ctx1.fill(self,"deactivate",{},globals.HLKeyBinderHelperWidget)})},
  1485. args: [],
  1486. source: "deactivate\x0a\x09self keyBinder deactivate",
  1487. messageSends: ["deactivate", "keyBinder"],
  1488. referencedClasses: []
  1489. }),
  1490. globals.HLKeyBinderHelperWidget);
  1491. smalltalk.addMethod(
  1492. smalltalk.method({
  1493. selector: "hide",
  1494. protocol: 'actions',
  1495. fn: function (){
  1496. var self=this;
  1497. return smalltalk.withContext(function($ctx1) {
  1498. var $1;
  1499. $1=_st(".".__comma(self._cssClass()))._asJQuery();
  1500. $ctx1.sendIdx["asJQuery"]=1;
  1501. _st($1)._remove();
  1502. $ctx1.sendIdx["remove"]=1;
  1503. _st("#overlay"._asJQuery())._remove();
  1504. self._showCog();
  1505. return self}, function($ctx1) {$ctx1.fill(self,"hide",{},globals.HLKeyBinderHelperWidget)})},
  1506. args: [],
  1507. source: "hide\x0a\x09('.', self cssClass) asJQuery remove.\x0a\x09'#overlay' asJQuery remove.\x0a\x09self showCog",
  1508. messageSends: ["remove", "asJQuery", ",", "cssClass", "showCog"],
  1509. referencedClasses: []
  1510. }),
  1511. globals.HLKeyBinderHelperWidget);
  1512. smalltalk.addMethod(
  1513. smalltalk.method({
  1514. selector: "hideCog",
  1515. protocol: 'actions',
  1516. fn: function (){
  1517. var self=this;
  1518. return smalltalk.withContext(function($ctx1) {
  1519. _st("#cog-helper"._asJQuery())._hide();
  1520. return self}, function($ctx1) {$ctx1.fill(self,"hideCog",{},globals.HLKeyBinderHelperWidget)})},
  1521. args: [],
  1522. source: "hideCog\x0a\x09'#cog-helper' asJQuery hide",
  1523. messageSends: ["hide", "asJQuery"],
  1524. referencedClasses: []
  1525. }),
  1526. globals.HLKeyBinderHelperWidget);
  1527. smalltalk.addMethod(
  1528. smalltalk.method({
  1529. selector: "keyBinder",
  1530. protocol: 'accessing',
  1531. fn: function (){
  1532. var self=this;
  1533. var $1;
  1534. $1=self["@keyBinder"];
  1535. return $1;
  1536. },
  1537. args: [],
  1538. source: "keyBinder\x0a\x09^ keyBinder",
  1539. messageSends: [],
  1540. referencedClasses: []
  1541. }),
  1542. globals.HLKeyBinderHelperWidget);
  1543. smalltalk.addMethod(
  1544. smalltalk.method({
  1545. selector: "keyBinder:",
  1546. protocol: 'accessing',
  1547. fn: function (aKeyBinder){
  1548. var self=this;
  1549. self["@keyBinder"]=aKeyBinder;
  1550. return self},
  1551. args: ["aKeyBinder"],
  1552. source: "keyBinder: aKeyBinder\x0a\x09keyBinder := aKeyBinder",
  1553. messageSends: [],
  1554. referencedClasses: []
  1555. }),
  1556. globals.HLKeyBinderHelperWidget);
  1557. smalltalk.addMethod(
  1558. smalltalk.method({
  1559. selector: "mainId",
  1560. protocol: 'accessing',
  1561. fn: function (){
  1562. var self=this;
  1563. return "binding-helper-main";
  1564. },
  1565. args: [],
  1566. source: "mainId\x0a\x09^ 'binding-helper-main'",
  1567. messageSends: [],
  1568. referencedClasses: []
  1569. }),
  1570. globals.HLKeyBinderHelperWidget);
  1571. smalltalk.addMethod(
  1572. smalltalk.method({
  1573. selector: "renderBindingActionFor:on:",
  1574. protocol: 'rendering',
  1575. fn: function (aBinding,html){
  1576. var self=this;
  1577. return smalltalk.withContext(function($ctx1) {
  1578. var $1,$3,$4,$5,$6,$2;
  1579. $1=_st(html)._span();
  1580. $ctx1.sendIdx["span"]=1;
  1581. _st($1)._class_("command");
  1582. $ctx1.sendIdx["class:"]=1;
  1583. $2=_st($1)._with_((function(){
  1584. return smalltalk.withContext(function($ctx2) {
  1585. $3=_st(html)._span();
  1586. _st($3)._class_("label");
  1587. $ctx2.sendIdx["class:"]=2;
  1588. $4=_st($3)._with_(_st(_st(aBinding)._shortcut())._asLowercase());
  1589. $ctx2.sendIdx["with:"]=2;
  1590. $4;
  1591. $5=_st(html)._a();
  1592. _st($5)._class_("action");
  1593. _st($5)._with_(_st(aBinding)._displayLabel());
  1594. $6=_st($5)._onClick_((function(){
  1595. return smalltalk.withContext(function($ctx3) {
  1596. return _st(self._keyBinder())._applyBinding_(aBinding);
  1597. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
  1598. return $6;
  1599. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1600. $ctx1.sendIdx["with:"]=1;
  1601. return self}, function($ctx1) {$ctx1.fill(self,"renderBindingActionFor:on:",{aBinding:aBinding,html:html},globals.HLKeyBinderHelperWidget)})},
  1602. args: ["aBinding", "html"],
  1603. source: "renderBindingActionFor: aBinding on: html\x0a\x09html span class: 'command'; with: [\x0a\x09\x09html span \x0a\x09\x09\x09class: 'label'; \x0a\x09\x09\x09with: aBinding shortcut asLowercase.\x0a \x09\x09html a \x0a \x09class: 'action'; \x0a with: aBinding displayLabel;\x0a \x09\x09\x09onClick: [ self keyBinder applyBinding: aBinding ] ]",
  1604. messageSends: ["class:", "span", "with:", "asLowercase", "shortcut", "a", "displayLabel", "onClick:", "applyBinding:", "keyBinder"],
  1605. referencedClasses: []
  1606. }),
  1607. globals.HLKeyBinderHelperWidget);
  1608. smalltalk.addMethod(
  1609. smalltalk.method({
  1610. selector: "renderBindingGroup:on:",
  1611. protocol: 'rendering',
  1612. fn: function (aBindingGroup,html){
  1613. var self=this;
  1614. return smalltalk.withContext(function($ctx1) {
  1615. var $1;
  1616. _st(_st(_st(aBindingGroup)._activeBindings())._sorted_((function(a,b){
  1617. return smalltalk.withContext(function($ctx2) {
  1618. $1=_st(a)._key();
  1619. $ctx2.sendIdx["key"]=1;
  1620. return _st($1).__lt(_st(b)._key());
  1621. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1,1)})})))._do_((function(each){
  1622. return smalltalk.withContext(function($ctx2) {
  1623. return self._renderBindingActionFor_on_(each,html);
  1624. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
  1625. return self}, function($ctx1) {$ctx1.fill(self,"renderBindingGroup:on:",{aBindingGroup:aBindingGroup,html:html},globals.HLKeyBinderHelperWidget)})},
  1626. args: ["aBindingGroup", "html"],
  1627. source: "renderBindingGroup: aBindingGroup on: html\x0a\x09(aBindingGroup activeBindings \x0a \x09sorted: [ :a :b | a key < b key ])\x0a do: [ :each | self renderBindingActionFor: each on: html ]",
  1628. messageSends: ["do:", "sorted:", "activeBindings", "<", "key", "renderBindingActionFor:on:"],
  1629. referencedClasses: []
  1630. }),
  1631. globals.HLKeyBinderHelperWidget);
  1632. smalltalk.addMethod(
  1633. smalltalk.method({
  1634. selector: "renderCloseOn:",
  1635. protocol: 'rendering',
  1636. fn: function (html){
  1637. var self=this;
  1638. return smalltalk.withContext(function($ctx1) {
  1639. var $1,$2;
  1640. $1=_st(html)._a();
  1641. _st($1)._class_("close");
  1642. $ctx1.sendIdx["class:"]=1;
  1643. _st($1)._with_((function(){
  1644. return smalltalk.withContext(function($ctx2) {
  1645. return _st(_st(html)._tag_("i"))._class_("icon-remove");
  1646. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1647. $2=_st($1)._onClick_((function(){
  1648. return smalltalk.withContext(function($ctx2) {
  1649. return _st(self._keyBinder())._deactivate();
  1650. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  1651. return self}, function($ctx1) {$ctx1.fill(self,"renderCloseOn:",{html:html},globals.HLKeyBinderHelperWidget)})},
  1652. args: ["html"],
  1653. source: "renderCloseOn: html\x0a\x09html a\x0a\x09\x09class: 'close';\x0a\x09\x09with: [ (html tag: 'i') class: 'icon-remove' ];\x0a\x09\x09onClick: [ self keyBinder deactivate ]",
  1654. messageSends: ["class:", "a", "with:", "tag:", "onClick:", "deactivate", "keyBinder"],
  1655. referencedClasses: []
  1656. }),
  1657. globals.HLKeyBinderHelperWidget);
  1658. smalltalk.addMethod(
  1659. smalltalk.method({
  1660. selector: "renderCog",
  1661. protocol: 'rendering',
  1662. fn: function (){
  1663. var self=this;
  1664. return smalltalk.withContext(function($ctx1) {
  1665. var $1,$3,$4,$2;
  1666. _st((function(html){
  1667. return smalltalk.withContext(function($ctx2) {
  1668. $1=_st(html)._div();
  1669. _st($1)._id_("cog-helper");
  1670. $2=_st($1)._with_((function(){
  1671. return smalltalk.withContext(function($ctx3) {
  1672. $3=_st(html)._a();
  1673. _st($3)._with_((function(){
  1674. return smalltalk.withContext(function($ctx4) {
  1675. return _st(_st(html)._tag_("i"))._class_("icon-cog");
  1676. }, function($ctx4) {$ctx4.fillBlock({},$ctx3,3)})}));
  1677. $4=_st($3)._onClick_((function(){
  1678. return smalltalk.withContext(function($ctx4) {
  1679. return _st(self._keyBinder())._activate();
  1680. }, function($ctx4) {$ctx4.fillBlock({},$ctx3,4)})}));
  1681. return $4;
  1682. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
  1683. $ctx2.sendIdx["with:"]=1;
  1684. return $2;
  1685. }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1,1)})}))._appendToJQuery_("body"._asJQuery());
  1686. return self}, function($ctx1) {$ctx1.fill(self,"renderCog",{},globals.HLKeyBinderHelperWidget)})},
  1687. args: [],
  1688. source: "renderCog\x0a\x09[ :html |\x0a\x09\x09html \x0a\x09\x09\x09div id: 'cog-helper'; \x0a\x09\x09\x09with: [\x0a\x09\x09\x09\x09html a \x0a\x09\x09\x09\x09\x09with: [ (html tag: 'i') class: 'icon-cog' ];\x0a\x09\x09\x09\x09\x09onClick: [ self keyBinder activate ] ] ]\x0a\x09\x09appendToJQuery: 'body' asJQuery",
  1689. messageSends: ["appendToJQuery:", "id:", "div", "with:", "a", "class:", "tag:", "onClick:", "activate", "keyBinder", "asJQuery"],
  1690. referencedClasses: []
  1691. }),
  1692. globals.HLKeyBinderHelperWidget);
  1693. smalltalk.addMethod(
  1694. smalltalk.method({
  1695. selector: "renderContentOn:",
  1696. protocol: 'rendering',
  1697. fn: function (html){
  1698. var self=this;
  1699. return smalltalk.withContext(function($ctx1) {
  1700. var $1,$2,$3,$5,$6,$4;
  1701. $1=_st(html)._div();
  1702. $ctx1.sendIdx["div"]=1;
  1703. _st($1)._id_("overlay");
  1704. $ctx1.sendIdx["id:"]=1;
  1705. $2=_st($1)._onClick_((function(){
  1706. return smalltalk.withContext(function($ctx2) {
  1707. return self._deactivate();
  1708. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1709. $3=_st(html)._div();
  1710. $ctx1.sendIdx["div"]=2;
  1711. _st($3)._class_(self._cssClass());
  1712. $4=_st($3)._with_((function(){
  1713. return smalltalk.withContext(function($ctx2) {
  1714. self._renderLabelOn_(html);
  1715. $5=_st(html)._div();
  1716. _st($5)._id_(self._mainId());
  1717. $6=_st($5)._with_((function(){
  1718. return smalltalk.withContext(function($ctx3) {
  1719. return self._renderSelectedBindingOn_(html);
  1720. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
  1721. $6;
  1722. return self._renderCloseOn_(html);
  1723. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  1724. $ctx1.sendIdx["with:"]=1;
  1725. return self}, function($ctx1) {$ctx1.fill(self,"renderContentOn:",{html:html},globals.HLKeyBinderHelperWidget)})},
  1726. args: ["html"],
  1727. source: "renderContentOn: html\x0a\x09html div \x0a\x09\x09id: 'overlay';\x0a\x09\x09onClick: [ self deactivate ].\x0a\x09html div class: self cssClass; with: [\x0a \x09self renderLabelOn:html.\x0a\x09\x09html div\x0a\x09\x09\x09id: self mainId;\x0a\x09\x09\x09with: [ self renderSelectedBindingOn: html ].\x0a\x09\x09self renderCloseOn: html ]",
  1728. messageSends: ["id:", "div", "onClick:", "deactivate", "class:", "cssClass", "with:", "renderLabelOn:", "mainId", "renderSelectedBindingOn:", "renderCloseOn:"],
  1729. referencedClasses: []
  1730. }),
  1731. globals.HLKeyBinderHelperWidget);
  1732. smalltalk.addMethod(
  1733. smalltalk.method({
  1734. selector: "renderLabelOn:",
  1735. protocol: 'rendering',
  1736. fn: function (html){
  1737. var self=this;
  1738. return smalltalk.withContext(function($ctx1) {
  1739. var $1,$3,$5,$4,$2;
  1740. $1=_st(html)._span();
  1741. _st($1)._class_("selected");
  1742. $3=$1;
  1743. $5=_st(self._selectedBinding())._label();
  1744. if(($receiver = $5) == nil || $receiver == null){
  1745. $4="Action";
  1746. } else {
  1747. $4=$5;
  1748. };
  1749. $2=_st($3)._with_($4);
  1750. return self}, function($ctx1) {$ctx1.fill(self,"renderLabelOn:",{html:html},globals.HLKeyBinderHelperWidget)})},
  1751. args: ["html"],
  1752. source: "renderLabelOn: html\x0a\x09\x09html span \x0a \x09class: 'selected'; \x0a with: (self selectedBinding label ifNil: [ 'Action' ])",
  1753. messageSends: ["class:", "span", "with:", "ifNil:", "label", "selectedBinding"],
  1754. referencedClasses: []
  1755. }),
  1756. globals.HLKeyBinderHelperWidget);
  1757. smalltalk.addMethod(
  1758. smalltalk.method({
  1759. selector: "renderSelectedBindingOn:",
  1760. protocol: 'rendering',
  1761. fn: function (html){
  1762. var self=this;
  1763. return smalltalk.withContext(function($ctx1) {
  1764. _st(self._selectedBinding())._renderOn_html_(self,html);
  1765. return self}, function($ctx1) {$ctx1.fill(self,"renderSelectedBindingOn:",{html:html},globals.HLKeyBinderHelperWidget)})},
  1766. args: ["html"],
  1767. source: "renderSelectedBindingOn: html\x0a\x09self selectedBinding renderOn: self html: html",
  1768. messageSends: ["renderOn:html:", "selectedBinding"],
  1769. referencedClasses: []
  1770. }),
  1771. globals.HLKeyBinderHelperWidget);
  1772. smalltalk.addMethod(
  1773. smalltalk.method({
  1774. selector: "renderStart",
  1775. protocol: 'rendering',
  1776. fn: function (){
  1777. var self=this;
  1778. return smalltalk.withContext(function($ctx1) {
  1779. var $1,$3,$5,$6,$4,$2,$7;
  1780. $1="#helper"._asJQuery();
  1781. $ctx1.sendIdx["asJQuery"]=1;
  1782. _st($1)._remove();
  1783. $2=(function(html){
  1784. return smalltalk.withContext(function($ctx2) {
  1785. $3=_st(html)._div();
  1786. _st($3)._id_("helper");
  1787. $5=$3;
  1788. $6=_st("Press ".__comma(_st(self._keyBinder())._activationKeyLabel())).__comma(" to start");
  1789. $ctx2.sendIdx[","]=1;
  1790. $4=_st($5)._with_($6);
  1791. return $4;
  1792. }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1,1)})});
  1793. $7="body"._asJQuery();
  1794. $ctx1.sendIdx["asJQuery"]=2;
  1795. _st($2)._appendToJQuery_($7);
  1796. _st((function(){
  1797. return smalltalk.withContext(function($ctx2) {
  1798. return _st("#helper"._asJQuery())._fadeOut_((1000));
  1799. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}))._valueWithTimeout_((2000));
  1800. return self}, function($ctx1) {$ctx1.fill(self,"renderStart",{},globals.HLKeyBinderHelperWidget)})},
  1801. args: [],
  1802. source: "renderStart\x0a\x09'#helper' asJQuery remove.\x0a\x0a\x09[ :html |\x0a\x09\x09html div \x0a\x09\x09\x09id: 'helper';\x0a\x09\x09\x09with: 'Press ', self keyBinder activationKeyLabel, ' to start' ] appendToJQuery: 'body' asJQuery.\x0a\x09\x0a\x09[ '#helper' asJQuery fadeOut: 1000 ] \x0a\x09\x09valueWithTimeout: 2000",
  1803. messageSends: ["remove", "asJQuery", "appendToJQuery:", "id:", "div", "with:", ",", "activationKeyLabel", "keyBinder", "valueWithTimeout:", "fadeOut:"],
  1804. referencedClasses: []
  1805. }),
  1806. globals.HLKeyBinderHelperWidget);
  1807. smalltalk.addMethod(
  1808. smalltalk.method({
  1809. selector: "selectedBinding",
  1810. protocol: 'accessing',
  1811. fn: function (){
  1812. var self=this;
  1813. return smalltalk.withContext(function($ctx1) {
  1814. var $1;
  1815. $1=_st(self._keyBinder())._selectedBinding();
  1816. return $1;
  1817. }, function($ctx1) {$ctx1.fill(self,"selectedBinding",{},globals.HLKeyBinderHelperWidget)})},
  1818. args: [],
  1819. source: "selectedBinding\x0a\x09^ self keyBinder selectedBinding",
  1820. messageSends: ["selectedBinding", "keyBinder"],
  1821. referencedClasses: []
  1822. }),
  1823. globals.HLKeyBinderHelperWidget);
  1824. smalltalk.addMethod(
  1825. smalltalk.method({
  1826. selector: "show",
  1827. protocol: 'actions',
  1828. fn: function (){
  1829. var self=this;
  1830. return smalltalk.withContext(function($ctx1) {
  1831. self._hideCog();
  1832. self._appendToJQuery_("body"._asJQuery());
  1833. return self}, function($ctx1) {$ctx1.fill(self,"show",{},globals.HLKeyBinderHelperWidget)})},
  1834. args: [],
  1835. source: "show\x0a\x09self hideCog.\x0a\x09self appendToJQuery: 'body' asJQuery",
  1836. messageSends: ["hideCog", "appendToJQuery:", "asJQuery"],
  1837. referencedClasses: []
  1838. }),
  1839. globals.HLKeyBinderHelperWidget);
  1840. smalltalk.addMethod(
  1841. smalltalk.method({
  1842. selector: "showCog",
  1843. protocol: 'actions',
  1844. fn: function (){
  1845. var self=this;
  1846. return smalltalk.withContext(function($ctx1) {
  1847. _st("#cog-helper"._asJQuery())._show();
  1848. return self}, function($ctx1) {$ctx1.fill(self,"showCog",{},globals.HLKeyBinderHelperWidget)})},
  1849. args: [],
  1850. source: "showCog\x0a\x09'#cog-helper' asJQuery show",
  1851. messageSends: ["show", "asJQuery"],
  1852. referencedClasses: []
  1853. }),
  1854. globals.HLKeyBinderHelperWidget);
  1855. smalltalk.addMethod(
  1856. smalltalk.method({
  1857. selector: "showWidget:",
  1858. protocol: 'actions',
  1859. fn: function (aWidget){
  1860. var self=this;
  1861. return smalltalk.withContext(function($ctx1) {
  1862. var $3,$2,$1;
  1863. $3=self._mainId();
  1864. $ctx1.sendIdx["mainId"]=1;
  1865. $2="#".__comma($3);
  1866. $ctx1.sendIdx[","]=1;
  1867. $1=_st($2)._asJQuery();
  1868. $ctx1.sendIdx["asJQuery"]=1;
  1869. _st($1)._empty();
  1870. _st(aWidget)._appendToJQuery_(_st("#".__comma(self._mainId()))._asJQuery());
  1871. return self}, function($ctx1) {$ctx1.fill(self,"showWidget:",{aWidget:aWidget},globals.HLKeyBinderHelperWidget)})},
  1872. args: ["aWidget"],
  1873. source: "showWidget: aWidget\x0a\x09\x22Some actions need to display more info to the user or request input.\x0a\x09This method is the right place for that\x22\x0a\x09\x0a\x09('#', self mainId) asJQuery empty.\x0a\x09aWidget appendToJQuery: ('#', self mainId) asJQuery",
  1874. messageSends: ["empty", "asJQuery", ",", "mainId", "appendToJQuery:"],
  1875. referencedClasses: []
  1876. }),
  1877. globals.HLKeyBinderHelperWidget);
  1878. smalltalk.addMethod(
  1879. smalltalk.method({
  1880. selector: "on:",
  1881. protocol: 'instance creation',
  1882. fn: function (aKeyBinder){
  1883. var self=this;
  1884. return smalltalk.withContext(function($ctx1) {
  1885. var $2,$3,$1;
  1886. $2=self._new();
  1887. _st($2)._keyBinder_(aKeyBinder);
  1888. $3=_st($2)._yourself();
  1889. $1=$3;
  1890. return $1;
  1891. }, function($ctx1) {$ctx1.fill(self,"on:",{aKeyBinder:aKeyBinder},globals.HLKeyBinderHelperWidget.klass)})},
  1892. args: ["aKeyBinder"],
  1893. source: "on: aKeyBinder\x0a\x09^ self new\x0a \x09keyBinder: aKeyBinder;\x0a yourself",
  1894. messageSends: ["keyBinder:", "new", "yourself"],
  1895. referencedClasses: []
  1896. }),
  1897. globals.HLKeyBinderHelperWidget.klass);
  1898. smalltalk.addClass('HLRepeatedKeyDownHandler', globals.Object, ['repeatInterval', 'delay', 'interval', 'keyBindings', 'widget', 'keyDown'], 'Helios-KeyBindings');
  1899. globals.HLRepeatedKeyDownHandler.comment="I am responsible for handling repeated key down actions for widgets.\x0a\x0a##Usage\x0a\x0a (self on: aWidget)\x0a whileKeyDown: 38 do: aBlock;\x0a whileKeyDown: 40 do: anotherBlock;\x0a bindKeys\x0a\x0aI perform an action block on a key press, wait for 300 ms and then preform the same action block every `repeatInterval` milliseconds until the key is released.";
  1900. smalltalk.addMethod(
  1901. smalltalk.method({
  1902. selector: "bindKeys",
  1903. protocol: 'binding',
  1904. fn: function (){
  1905. var self=this;
  1906. return smalltalk.withContext(function($ctx1) {
  1907. _st(self._widget())._bindKeyDown_keyUp_((function(e){
  1908. return smalltalk.withContext(function($ctx2) {
  1909. return self._handleKeyDown_(e);
  1910. }, function($ctx2) {$ctx2.fillBlock({e:e},$ctx1,1)})}),(function(e){
  1911. return smalltalk.withContext(function($ctx2) {
  1912. return self._handleKeyUp();
  1913. }, function($ctx2) {$ctx2.fillBlock({e:e},$ctx1,2)})}));
  1914. return self}, function($ctx1) {$ctx1.fill(self,"bindKeys",{},globals.HLRepeatedKeyDownHandler)})},
  1915. args: [],
  1916. source: "bindKeys\x0a\x09self widget \x0a\x09\x09bindKeyDown: [ :e | self handleKeyDown: e ] \x0a\x09\x09keyUp: [ :e | self handleKeyUp ]",
  1917. messageSends: ["bindKeyDown:keyUp:", "widget", "handleKeyDown:", "handleKeyUp"],
  1918. referencedClasses: []
  1919. }),
  1920. globals.HLRepeatedKeyDownHandler);
  1921. smalltalk.addMethod(
  1922. smalltalk.method({
  1923. selector: "defaultRepeatInterval",
  1924. protocol: 'defaults',
  1925. fn: function (){
  1926. var self=this;
  1927. return (70);
  1928. },
  1929. args: [],
  1930. source: "defaultRepeatInterval\x0a\x09^ 70",
  1931. messageSends: [],
  1932. referencedClasses: []
  1933. }),
  1934. globals.HLRepeatedKeyDownHandler);
  1935. smalltalk.addMethod(
  1936. smalltalk.method({
  1937. selector: "handleEvent:forKey:action:",
  1938. protocol: 'events handling',
  1939. fn: function (anEvent,anInteger,aBlock){
  1940. var self=this;
  1941. return smalltalk.withContext(function($ctx1) {
  1942. var $1;
  1943. $1=_st(_st(_st(anEvent)._which()).__eq(anInteger))._and_((function(){
  1944. return smalltalk.withContext(function($ctx2) {
  1945. return _st(self._isKeyDown())._not();
  1946. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1947. if(smalltalk.assert($1)){
  1948. self._whileKeyDownDo_(aBlock);
  1949. };
  1950. return self}, function($ctx1) {$ctx1.fill(self,"handleEvent:forKey:action:",{anEvent:anEvent,anInteger:anInteger,aBlock:aBlock},globals.HLRepeatedKeyDownHandler)})},
  1951. args: ["anEvent", "anInteger", "aBlock"],
  1952. source: "handleEvent: anEvent forKey: anInteger action: aBlock\x0a\x09(anEvent which = anInteger and: [ self isKeyDown not ])\x0a\x09\x09ifTrue: [ self whileKeyDownDo: aBlock ]",
  1953. messageSends: ["ifTrue:", "and:", "=", "which", "not", "isKeyDown", "whileKeyDownDo:"],
  1954. referencedClasses: []
  1955. }),
  1956. globals.HLRepeatedKeyDownHandler);
  1957. smalltalk.addMethod(
  1958. smalltalk.method({
  1959. selector: "handleKeyDown:",
  1960. protocol: 'events handling',
  1961. fn: function (anEvent){
  1962. var self=this;
  1963. return smalltalk.withContext(function($ctx1) {
  1964. _st(self._keyBindings())._keysAndValuesDo_((function(key,action){
  1965. return smalltalk.withContext(function($ctx2) {
  1966. return self._handleEvent_forKey_action_(anEvent,key,action);
  1967. }, function($ctx2) {$ctx2.fillBlock({key:key,action:action},$ctx1,1)})}));
  1968. return self}, function($ctx1) {$ctx1.fill(self,"handleKeyDown:",{anEvent:anEvent},globals.HLRepeatedKeyDownHandler)})},
  1969. args: ["anEvent"],
  1970. source: "handleKeyDown: anEvent\x0a\x09self keyBindings keysAndValuesDo: [ :key :action | \x0a\x09\x09self handleEvent: anEvent forKey: key action: action ]",
  1971. messageSends: ["keysAndValuesDo:", "keyBindings", "handleEvent:forKey:action:"],
  1972. referencedClasses: []
  1973. }),
  1974. globals.HLRepeatedKeyDownHandler);
  1975. smalltalk.addMethod(
  1976. smalltalk.method({
  1977. selector: "handleKeyUp",
  1978. protocol: 'events handling',
  1979. fn: function (){
  1980. var self=this;
  1981. return smalltalk.withContext(function($ctx1) {
  1982. var $1,$2,$3;
  1983. $1=self._isKeyDown();
  1984. if(smalltalk.assert($1)){
  1985. self["@keyDown"]=false;
  1986. self["@keyDown"];
  1987. $2=self["@interval"];
  1988. if(($receiver = $2) == nil || $receiver == null){
  1989. $2;
  1990. } else {
  1991. _st(self["@interval"])._clearInterval();
  1992. };
  1993. $3=self["@delay"];
  1994. if(($receiver = $3) == nil || $receiver == null){
  1995. $3;
  1996. } else {
  1997. _st(self["@delay"])._clearTimeout();
  1998. };
  1999. };
  2000. return self}, function($ctx1) {$ctx1.fill(self,"handleKeyUp",{},globals.HLRepeatedKeyDownHandler)})},
  2001. args: [],
  2002. source: "handleKeyUp\x0a\x09self isKeyDown ifTrue: [\x0a\x09\x09keyDown := false.\x0a\x09\x09interval ifNotNil: [ interval clearInterval ].\x0a\x09\x09delay ifNotNil: [ delay clearTimeout ] ]",
  2003. messageSends: ["ifTrue:", "isKeyDown", "ifNotNil:", "clearInterval", "clearTimeout"],
  2004. referencedClasses: []
  2005. }),
  2006. globals.HLRepeatedKeyDownHandler);
  2007. smalltalk.addMethod(
  2008. smalltalk.method({
  2009. selector: "isKeyDown",
  2010. protocol: 'testing',
  2011. fn: function (){
  2012. var self=this;
  2013. return smalltalk.withContext(function($ctx1) {
  2014. var $2,$1;
  2015. $2=self["@keyDown"];
  2016. if(($receiver = $2) == nil || $receiver == null){
  2017. $1=false;
  2018. } else {
  2019. $1=$2;
  2020. };
  2021. return $1;
  2022. }, function($ctx1) {$ctx1.fill(self,"isKeyDown",{},globals.HLRepeatedKeyDownHandler)})},
  2023. args: [],
  2024. source: "isKeyDown\x0a\x09^ keyDown ifNil: [ false ]",
  2025. messageSends: ["ifNil:"],
  2026. referencedClasses: []
  2027. }),
  2028. globals.HLRepeatedKeyDownHandler);
  2029. smalltalk.addMethod(
  2030. smalltalk.method({
  2031. selector: "keyBindings",
  2032. protocol: 'accessing',
  2033. fn: function (){
  2034. var self=this;
  2035. function $Dictionary(){return globals.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  2036. return smalltalk.withContext(function($ctx1) {
  2037. var $2,$1;
  2038. $2=self["@keyBindings"];
  2039. if(($receiver = $2) == nil || $receiver == null){
  2040. self["@keyBindings"]=_st($Dictionary())._new();
  2041. $1=self["@keyBindings"];
  2042. } else {
  2043. $1=$2;
  2044. };
  2045. return $1;
  2046. }, function($ctx1) {$ctx1.fill(self,"keyBindings",{},globals.HLRepeatedKeyDownHandler)})},
  2047. args: [],
  2048. source: "keyBindings\x0a\x09^ keyBindings ifNil: [ keyBindings := Dictionary new ]",
  2049. messageSends: ["ifNil:", "new"],
  2050. referencedClasses: ["Dictionary"]
  2051. }),
  2052. globals.HLRepeatedKeyDownHandler);
  2053. smalltalk.addMethod(
  2054. smalltalk.method({
  2055. selector: "rebindKeys",
  2056. protocol: 'binding',
  2057. fn: function (){
  2058. var self=this;
  2059. return smalltalk.withContext(function($ctx1) {
  2060. var $1;
  2061. self._unbindKeys();
  2062. $1=self._bindKeys();
  2063. return self}, function($ctx1) {$ctx1.fill(self,"rebindKeys",{},globals.HLRepeatedKeyDownHandler)})},
  2064. args: [],
  2065. source: "rebindKeys\x0a\x09self \x0a\x09\x09unbindKeys;\x0a\x09\x09bindKeys",
  2066. messageSends: ["unbindKeys", "bindKeys"],
  2067. referencedClasses: []
  2068. }),
  2069. globals.HLRepeatedKeyDownHandler);
  2070. smalltalk.addMethod(
  2071. smalltalk.method({
  2072. selector: "repeatInterval",
  2073. protocol: 'accessing',
  2074. fn: function (){
  2075. var self=this;
  2076. return smalltalk.withContext(function($ctx1) {
  2077. var $2,$1;
  2078. $2=self["@repeatInterval"];
  2079. if(($receiver = $2) == nil || $receiver == null){
  2080. $1=self._defaultRepeatInterval();
  2081. } else {
  2082. $1=$2;
  2083. };
  2084. return $1;
  2085. }, function($ctx1) {$ctx1.fill(self,"repeatInterval",{},globals.HLRepeatedKeyDownHandler)})},
  2086. args: [],
  2087. source: "repeatInterval\x0a\x09^ repeatInterval ifNil: [ self defaultRepeatInterval ]",
  2088. messageSends: ["ifNil:", "defaultRepeatInterval"],
  2089. referencedClasses: []
  2090. }),
  2091. globals.HLRepeatedKeyDownHandler);
  2092. smalltalk.addMethod(
  2093. smalltalk.method({
  2094. selector: "repeatInterval:",
  2095. protocol: 'accessing',
  2096. fn: function (anInteger){
  2097. var self=this;
  2098. self["@repeatInterval"]=anInteger;
  2099. return self},
  2100. args: ["anInteger"],
  2101. source: "repeatInterval: anInteger\x0a\x09repeatInterval := anInteger",
  2102. messageSends: [],
  2103. referencedClasses: []
  2104. }),
  2105. globals.HLRepeatedKeyDownHandler);
  2106. smalltalk.addMethod(
  2107. smalltalk.method({
  2108. selector: "startRepeatingAction:",
  2109. protocol: 'actions',
  2110. fn: function (aBlock){
  2111. var self=this;
  2112. return smalltalk.withContext(function($ctx1) {
  2113. var $2,$1;
  2114. $1=_st((function(){
  2115. return smalltalk.withContext(function($ctx2) {
  2116. $2=_st(self._widget())._hasFocus();
  2117. if(smalltalk.assert($2)){
  2118. return _st(aBlock)._value();
  2119. } else {
  2120. return self._handleKeyUp();
  2121. };
  2122. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._valueWithInterval_(self._repeatInterval());
  2123. return $1;
  2124. }, function($ctx1) {$ctx1.fill(self,"startRepeatingAction:",{aBlock:aBlock},globals.HLRepeatedKeyDownHandler)})},
  2125. args: ["aBlock"],
  2126. source: "startRepeatingAction: aBlock\x0a\x09^ [ (self widget hasFocus)\x0a\x09\x09ifTrue: [ aBlock value ]\x0a\x09\x09ifFalse: [ self handleKeyUp ] ] valueWithInterval: self repeatInterval",
  2127. messageSends: ["valueWithInterval:", "ifTrue:ifFalse:", "hasFocus", "widget", "value", "handleKeyUp", "repeatInterval"],
  2128. referencedClasses: []
  2129. }),
  2130. globals.HLRepeatedKeyDownHandler);
  2131. smalltalk.addMethod(
  2132. smalltalk.method({
  2133. selector: "unbindKeys",
  2134. protocol: 'binding',
  2135. fn: function (){
  2136. var self=this;
  2137. return smalltalk.withContext(function($ctx1) {
  2138. _st(self._widget())._unbindKeyDownKeyUp();
  2139. return self}, function($ctx1) {$ctx1.fill(self,"unbindKeys",{},globals.HLRepeatedKeyDownHandler)})},
  2140. args: [],
  2141. source: "unbindKeys\x0a\x09self widget unbindKeyDownKeyUp",
  2142. messageSends: ["unbindKeyDownKeyUp", "widget"],
  2143. referencedClasses: []
  2144. }),
  2145. globals.HLRepeatedKeyDownHandler);
  2146. smalltalk.addMethod(
  2147. smalltalk.method({
  2148. selector: "whileKeyDown:do:",
  2149. protocol: 'actions',
  2150. fn: function (aKey,aBlock){
  2151. var self=this;
  2152. return smalltalk.withContext(function($ctx1) {
  2153. _st(self._keyBindings())._at_put_(aKey,aBlock);
  2154. return self}, function($ctx1) {$ctx1.fill(self,"whileKeyDown:do:",{aKey:aKey,aBlock:aBlock},globals.HLRepeatedKeyDownHandler)})},
  2155. args: ["aKey", "aBlock"],
  2156. source: "whileKeyDown: aKey do: aBlock\x0a\x09self keyBindings at: aKey put: aBlock",
  2157. messageSends: ["at:put:", "keyBindings"],
  2158. referencedClasses: []
  2159. }),
  2160. globals.HLRepeatedKeyDownHandler);
  2161. smalltalk.addMethod(
  2162. smalltalk.method({
  2163. selector: "whileKeyDownDo:",
  2164. protocol: 'events handling',
  2165. fn: function (aBlock){
  2166. var self=this;
  2167. return smalltalk.withContext(function($ctx1) {
  2168. self["@keyDown"]=true;
  2169. _st(aBlock)._value();
  2170. self["@delay"]=_st((function(){
  2171. return smalltalk.withContext(function($ctx2) {
  2172. self["@interval"]=self._startRepeatingAction_(aBlock);
  2173. return self["@interval"];
  2174. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._valueWithTimeout_((300));
  2175. return self}, function($ctx1) {$ctx1.fill(self,"whileKeyDownDo:",{aBlock:aBlock},globals.HLRepeatedKeyDownHandler)})},
  2176. args: ["aBlock"],
  2177. source: "whileKeyDownDo: aBlock\x0a\x09keyDown := true.\x0a\x09aBlock value.\x0a\x09delay := [ interval := self startRepeatingAction: aBlock ] \x0a\x09\x09valueWithTimeout: 300",
  2178. messageSends: ["value", "valueWithTimeout:", "startRepeatingAction:"],
  2179. referencedClasses: []
  2180. }),
  2181. globals.HLRepeatedKeyDownHandler);
  2182. smalltalk.addMethod(
  2183. smalltalk.method({
  2184. selector: "widget",
  2185. protocol: 'accessing',
  2186. fn: function (){
  2187. var self=this;
  2188. var $1;
  2189. $1=self["@widget"];
  2190. return $1;
  2191. },
  2192. args: [],
  2193. source: "widget\x0a\x09^ widget",
  2194. messageSends: [],
  2195. referencedClasses: []
  2196. }),
  2197. globals.HLRepeatedKeyDownHandler);
  2198. smalltalk.addMethod(
  2199. smalltalk.method({
  2200. selector: "widget:",
  2201. protocol: 'accessing',
  2202. fn: function (aWidget){
  2203. var self=this;
  2204. self["@widget"]=aWidget;
  2205. return self},
  2206. args: ["aWidget"],
  2207. source: "widget: aWidget\x0a\x09widget := aWidget",
  2208. messageSends: [],
  2209. referencedClasses: []
  2210. }),
  2211. globals.HLRepeatedKeyDownHandler);
  2212. smalltalk.addMethod(
  2213. smalltalk.method({
  2214. selector: "on:",
  2215. protocol: 'instance creation',
  2216. fn: function (aWidget){
  2217. var self=this;
  2218. return smalltalk.withContext(function($ctx1) {
  2219. var $2,$3,$1;
  2220. $2=self._new();
  2221. _st($2)._widget_(aWidget);
  2222. $3=_st($2)._yourself();
  2223. $1=$3;
  2224. return $1;
  2225. }, function($ctx1) {$ctx1.fill(self,"on:",{aWidget:aWidget},globals.HLRepeatedKeyDownHandler.klass)})},
  2226. args: ["aWidget"],
  2227. source: "on: aWidget\x0a\x09^ self new\x0a\x09\x09widget: aWidget;\x0a\x09\x09yourself",
  2228. messageSends: ["widget:", "new", "yourself"],
  2229. referencedClasses: []
  2230. }),
  2231. globals.HLRepeatedKeyDownHandler.klass);
  2232. });