Helios-KeyBindings.js 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281
  1. define("helios/Helios-KeyBindings", ["amber/boot", "amber_core/Kernel-Objects", "helios/Helios-Core"], function($boot){
  2. var smalltalk=$boot.vm,nil=$boot.nil,_st=$boot.asReceiver,globals=$boot.globals;
  3. smalltalk.addPackage('Helios-KeyBindings');
  4. smalltalk.packages["Helios-KeyBindings"].transport = {"type":"amd","amdNamespace":"helios"};
  5. smalltalk.addClass('HLBinding', globals.Object, ['key', 'label'], 'Helios-KeyBindings');
  6. 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.";
  7. smalltalk.addMethod(
  8. smalltalk.method({
  9. selector: "apply",
  10. protocol: 'actions',
  11. fn: function (){
  12. var self=this;
  13. return self},
  14. args: [],
  15. source: "apply",
  16. messageSends: [],
  17. referencedClasses: []
  18. }),
  19. globals.HLBinding);
  20. smalltalk.addMethod(
  21. smalltalk.method({
  22. selector: "atKey:",
  23. protocol: 'accessing',
  24. fn: function (aKey){
  25. var self=this;
  26. return nil;
  27. },
  28. args: ["aKey"],
  29. 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",
  30. messageSends: [],
  31. referencedClasses: []
  32. }),
  33. globals.HLBinding);
  34. smalltalk.addMethod(
  35. smalltalk.method({
  36. selector: "displayLabel",
  37. protocol: 'accessing',
  38. fn: function (){
  39. var self=this;
  40. return smalltalk.withContext(function($ctx1) {
  41. var $1;
  42. $1=self._label();
  43. return $1;
  44. }, function($ctx1) {$ctx1.fill(self,"displayLabel",{},globals.HLBinding)})},
  45. args: [],
  46. source: "displayLabel\x0a\x09^ self label",
  47. messageSends: ["label"],
  48. referencedClasses: []
  49. }),
  50. globals.HLBinding);
  51. smalltalk.addMethod(
  52. smalltalk.method({
  53. selector: "isActive",
  54. protocol: 'testing',
  55. fn: function (){
  56. var self=this;
  57. return smalltalk.withContext(function($ctx1) {
  58. var $1;
  59. $1=self._subclassResponsibility();
  60. return $1;
  61. }, function($ctx1) {$ctx1.fill(self,"isActive",{},globals.HLBinding)})},
  62. args: [],
  63. source: "isActive\x0a\x09^ self subclassResponsibility",
  64. messageSends: ["subclassResponsibility"],
  65. referencedClasses: []
  66. }),
  67. globals.HLBinding);
  68. smalltalk.addMethod(
  69. smalltalk.method({
  70. selector: "key",
  71. protocol: 'accessing',
  72. fn: function (){
  73. var self=this;
  74. var $1;
  75. $1=self["@key"];
  76. return $1;
  77. },
  78. args: [],
  79. source: "key\x0a\x09^ key",
  80. messageSends: [],
  81. referencedClasses: []
  82. }),
  83. globals.HLBinding);
  84. smalltalk.addMethod(
  85. smalltalk.method({
  86. selector: "key:",
  87. protocol: 'accessing',
  88. fn: function (anInteger){
  89. var self=this;
  90. self["@key"]=anInteger;
  91. return self},
  92. args: ["anInteger"],
  93. source: "key: anInteger\x0a\x09key := anInteger",
  94. messageSends: [],
  95. referencedClasses: []
  96. }),
  97. globals.HLBinding);
  98. smalltalk.addMethod(
  99. smalltalk.method({
  100. selector: "label",
  101. protocol: 'accessing',
  102. fn: function (){
  103. var self=this;
  104. var $1;
  105. $1=self["@label"];
  106. return $1;
  107. },
  108. args: [],
  109. source: "label\x0a\x09^ label",
  110. messageSends: [],
  111. referencedClasses: []
  112. }),
  113. globals.HLBinding);
  114. smalltalk.addMethod(
  115. smalltalk.method({
  116. selector: "label:",
  117. protocol: 'accessing',
  118. fn: function (aString){
  119. var self=this;
  120. self["@label"]=aString;
  121. return self},
  122. args: ["aString"],
  123. source: "label: aString\x0a\x09label := aString",
  124. messageSends: [],
  125. referencedClasses: []
  126. }),
  127. globals.HLBinding);
  128. smalltalk.addMethod(
  129. smalltalk.method({
  130. selector: "release",
  131. protocol: 'actions',
  132. fn: function (){
  133. var self=this;
  134. return self},
  135. args: [],
  136. source: "release",
  137. messageSends: [],
  138. referencedClasses: []
  139. }),
  140. globals.HLBinding);
  141. smalltalk.addMethod(
  142. smalltalk.method({
  143. selector: "renderOn:html:",
  144. protocol: 'rendering',
  145. fn: function (aBindingHelper,html){
  146. var self=this;
  147. return self},
  148. args: ["aBindingHelper", "html"],
  149. source: "renderOn: aBindingHelper html: html",
  150. messageSends: [],
  151. referencedClasses: []
  152. }),
  153. globals.HLBinding);
  154. smalltalk.addMethod(
  155. smalltalk.method({
  156. selector: "shortcut",
  157. protocol: 'accessing',
  158. fn: function (){
  159. var self=this;
  160. function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
  161. return smalltalk.withContext(function($ctx1) {
  162. var $1;
  163. $1=_st($String())._fromCharCode_(self._key());
  164. return $1;
  165. }, function($ctx1) {$ctx1.fill(self,"shortcut",{},globals.HLBinding)})},
  166. args: [],
  167. source: "shortcut\x0a\x09^ String fromCharCode: self key",
  168. messageSends: ["fromCharCode:", "key"],
  169. referencedClasses: ["String"]
  170. }),
  171. globals.HLBinding);
  172. smalltalk.addMethod(
  173. smalltalk.method({
  174. selector: "on:labelled:",
  175. protocol: 'instance creation',
  176. fn: function (anInteger,aString){
  177. var self=this;
  178. return smalltalk.withContext(function($ctx1) {
  179. var $2,$3,$1;
  180. $2=self._new();
  181. _st($2)._key_(anInteger);
  182. _st($2)._label_(aString);
  183. $3=_st($2)._yourself();
  184. $1=$3;
  185. return $1;
  186. }, function($ctx1) {$ctx1.fill(self,"on:labelled:",{anInteger:anInteger,aString:aString},globals.HLBinding.klass)})},
  187. args: ["anInteger", "aString"],
  188. source: "on: anInteger labelled: aString\x0a\x09^ self new\x0a \x09key: anInteger;\x0a label: aString;\x0a yourself",
  189. messageSends: ["key:", "new", "label:", "yourself"],
  190. referencedClasses: []
  191. }),
  192. globals.HLBinding.klass);
  193. smalltalk.addClass('HLBindingAction', globals.HLBinding, ['command'], 'Helios-KeyBindings');
  194. 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.";
  195. smalltalk.addMethod(
  196. smalltalk.method({
  197. selector: "apply",
  198. protocol: 'actions',
  199. fn: function (){
  200. var self=this;
  201. function $HLKeyBinder(){return globals.HLKeyBinder||(typeof HLKeyBinder=="undefined"?nil:HLKeyBinder)}
  202. return smalltalk.withContext(function($ctx1) {
  203. var $1;
  204. $1=_st(self._command())._isInputRequired();
  205. if(smalltalk.assert($1)){
  206. _st(_st(_st($HLKeyBinder())._current())._helper())._showWidget_(self._inputWidget());
  207. } else {
  208. self._executeCommand();
  209. };
  210. return self}, function($ctx1) {$ctx1.fill(self,"apply",{},globals.HLBindingAction)})},
  211. args: [],
  212. source: "apply\x0a\x09self command isInputRequired\x0a\x09\x09ifTrue: [ HLKeyBinder current helper showWidget: self inputWidget ]\x0a\x09\x09ifFalse: [ self executeCommand ]",
  213. messageSends: ["ifTrue:ifFalse:", "isInputRequired", "command", "showWidget:", "helper", "current", "inputWidget", "executeCommand"],
  214. referencedClasses: ["HLKeyBinder"]
  215. }),
  216. globals.HLBindingAction);
  217. smalltalk.addMethod(
  218. smalltalk.method({
  219. selector: "command",
  220. protocol: 'accessing',
  221. fn: function (){
  222. var self=this;
  223. var $1;
  224. $1=self["@command"];
  225. return $1;
  226. },
  227. args: [],
  228. source: "command\x0a\x09^ command",
  229. messageSends: [],
  230. referencedClasses: []
  231. }),
  232. globals.HLBindingAction);
  233. smalltalk.addMethod(
  234. smalltalk.method({
  235. selector: "command:",
  236. protocol: 'accessing',
  237. fn: function (aCommand){
  238. var self=this;
  239. self["@command"]=aCommand;
  240. return self},
  241. args: ["aCommand"],
  242. source: "command: aCommand\x0a\x09command := aCommand",
  243. messageSends: [],
  244. referencedClasses: []
  245. }),
  246. globals.HLBindingAction);
  247. smalltalk.addMethod(
  248. smalltalk.method({
  249. selector: "executeCommand",
  250. protocol: 'actions',
  251. fn: function (){
  252. var self=this;
  253. function $HLKeyBinder(){return globals.HLKeyBinder||(typeof HLKeyBinder=="undefined"?nil:HLKeyBinder)}
  254. return smalltalk.withContext(function($ctx1) {
  255. _st(self._command())._execute();
  256. _st(_st($HLKeyBinder())._current())._deactivate();
  257. return self}, function($ctx1) {$ctx1.fill(self,"executeCommand",{},globals.HLBindingAction)})},
  258. args: [],
  259. source: "executeCommand\x0a\x09self command execute.\x0a\x09HLKeyBinder current deactivate",
  260. messageSends: ["execute", "command", "deactivate", "current"],
  261. referencedClasses: ["HLKeyBinder"]
  262. }),
  263. globals.HLBindingAction);
  264. smalltalk.addMethod(
  265. smalltalk.method({
  266. selector: "input:",
  267. protocol: 'accessing',
  268. fn: function (aString){
  269. var self=this;
  270. return smalltalk.withContext(function($ctx1) {
  271. _st(self._command())._input_(aString);
  272. return self}, function($ctx1) {$ctx1.fill(self,"input:",{aString:aString},globals.HLBindingAction)})},
  273. args: ["aString"],
  274. source: "input: aString\x0a\x09self command input: aString",
  275. messageSends: ["input:", "command"],
  276. referencedClasses: []
  277. }),
  278. globals.HLBindingAction);
  279. smalltalk.addMethod(
  280. smalltalk.method({
  281. selector: "inputBinding",
  282. protocol: 'accessing',
  283. fn: function (){
  284. var self=this;
  285. function $HLBindingInput(){return globals.HLBindingInput||(typeof HLBindingInput=="undefined"?nil:HLBindingInput)}
  286. return smalltalk.withContext(function($ctx1) {
  287. var $2,$3,$5,$4,$6,$8,$7,$9,$11,$10,$12,$14,$13,$15,$16,$17,$1;
  288. $2=_st($HLBindingInput())._new();
  289. $3=$2;
  290. $5=self._command();
  291. $ctx1.sendIdx["command"]=1;
  292. $4=_st($5)._inputLabel();
  293. _st($3)._label_($4);
  294. $6=$2;
  295. $8=self._command();
  296. $ctx1.sendIdx["command"]=2;
  297. $7=_st($8)._displayLabel();
  298. _st($6)._ghostText_($7);
  299. $9=$2;
  300. $11=self._command();
  301. $ctx1.sendIdx["command"]=3;
  302. $10=_st($11)._defaultInput();
  303. _st($9)._defaultValue_($10);
  304. $12=$2;
  305. $14=self._command();
  306. $ctx1.sendIdx["command"]=4;
  307. $13=_st($14)._inputCompletion();
  308. _st($12)._inputCompletion_($13);
  309. _st($2)._callback_((function(val){
  310. return smalltalk.withContext(function($ctx2) {
  311. $15=self._command();
  312. _st($15)._input_(val);
  313. $16=_st($15)._execute();
  314. return $16;
  315. }, function($ctx2) {$ctx2.fillBlock({val:val},$ctx1,1)})}));
  316. $17=_st($2)._yourself();
  317. $1=$17;
  318. return $1;
  319. }, function($ctx1) {$ctx1.fill(self,"inputBinding",{},globals.HLBindingAction)})},
  320. args: [],
  321. 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",
  322. messageSends: ["label:", "new", "inputLabel", "command", "ghostText:", "displayLabel", "defaultValue:", "defaultInput", "inputCompletion:", "inputCompletion", "callback:", "input:", "execute", "yourself"],
  323. referencedClasses: ["HLBindingInput"]
  324. }),
  325. globals.HLBindingAction);
  326. smalltalk.addMethod(
  327. smalltalk.method({
  328. selector: "inputWidget",
  329. protocol: 'accessing',
  330. fn: function (){
  331. var self=this;
  332. function $HLBindingActionInputWidget(){return globals.HLBindingActionInputWidget||(typeof HLBindingActionInputWidget=="undefined"?nil:HLBindingActionInputWidget)}
  333. return smalltalk.withContext(function($ctx1) {
  334. var $2,$3,$5,$4,$6,$8,$7,$9,$10,$1;
  335. $2=_st($HLBindingActionInputWidget())._new();
  336. $3=$2;
  337. $5=self._command();
  338. $ctx1.sendIdx["command"]=1;
  339. $4=_st($5)._displayLabel();
  340. _st($3)._ghostText_($4);
  341. $6=$2;
  342. $8=self._command();
  343. $ctx1.sendIdx["command"]=2;
  344. $7=_st($8)._defaultInput();
  345. _st($6)._defaultValue_($7);
  346. _st($2)._inputCompletion_(_st(self._command())._inputCompletion());
  347. _st($2)._callback_((function(value){
  348. return smalltalk.withContext(function($ctx2) {
  349. self._input_(value);
  350. $9=self._executeCommand();
  351. return $9;
  352. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1,1)})}));
  353. $10=_st($2)._yourself();
  354. $1=$10;
  355. return $1;
  356. }, function($ctx1) {$ctx1.fill(self,"inputWidget",{},globals.HLBindingAction)})},
  357. args: [],
  358. 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",
  359. messageSends: ["ghostText:", "new", "displayLabel", "command", "defaultValue:", "defaultInput", "inputCompletion:", "inputCompletion", "callback:", "input:", "executeCommand", "yourself"],
  360. referencedClasses: ["HLBindingActionInputWidget"]
  361. }),
  362. globals.HLBindingAction);
  363. smalltalk.addMethod(
  364. smalltalk.method({
  365. selector: "isActive",
  366. protocol: 'testing',
  367. fn: function (){
  368. var self=this;
  369. return smalltalk.withContext(function($ctx1) {
  370. var $1;
  371. $1=_st(self._command())._isActive();
  372. return $1;
  373. }, function($ctx1) {$ctx1.fill(self,"isActive",{},globals.HLBindingAction)})},
  374. args: [],
  375. source: "isActive\x0a\x09^ self command isActive",
  376. messageSends: ["isActive", "command"],
  377. referencedClasses: []
  378. }),
  379. globals.HLBindingAction);
  380. smalltalk.addClass('HLBindingGroup', globals.HLBinding, ['bindings'], 'Helios-KeyBindings');
  381. 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.";
  382. smalltalk.addMethod(
  383. smalltalk.method({
  384. selector: "activeBindings",
  385. protocol: 'accessing',
  386. fn: function (){
  387. var self=this;
  388. return smalltalk.withContext(function($ctx1) {
  389. var $1;
  390. $1=_st(self._bindings())._select_((function(each){
  391. return smalltalk.withContext(function($ctx2) {
  392. return _st(each)._isActive();
  393. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  394. return $1;
  395. }, function($ctx1) {$ctx1.fill(self,"activeBindings",{},globals.HLBindingGroup)})},
  396. args: [],
  397. source: "activeBindings\x0a\x09^ self bindings select: [ :each | each isActive ]",
  398. messageSends: ["select:", "bindings", "isActive"],
  399. referencedClasses: []
  400. }),
  401. globals.HLBindingGroup);
  402. smalltalk.addMethod(
  403. smalltalk.method({
  404. selector: "add:",
  405. protocol: 'adding',
  406. fn: function (aBinding){
  407. var self=this;
  408. return smalltalk.withContext(function($ctx1) {
  409. var $1;
  410. $1=_st(self._bindings())._add_(aBinding);
  411. return $1;
  412. }, function($ctx1) {$ctx1.fill(self,"add:",{aBinding:aBinding},globals.HLBindingGroup)})},
  413. args: ["aBinding"],
  414. source: "add: aBinding\x0a\x09^ self bindings add: aBinding",
  415. messageSends: ["add:", "bindings"],
  416. referencedClasses: []
  417. }),
  418. globals.HLBindingGroup);
  419. smalltalk.addMethod(
  420. smalltalk.method({
  421. selector: "addActionKey:labelled:callback:",
  422. protocol: 'adding',
  423. fn: function (anInteger,aString,aBlock){
  424. var self=this;
  425. function $HLBindingAction(){return globals.HLBindingAction||(typeof HLBindingAction=="undefined"?nil:HLBindingAction)}
  426. return smalltalk.withContext(function($ctx1) {
  427. var $1,$2;
  428. $1=_st($HLBindingAction())._on_labelled_(anInteger,aString);
  429. _st($1)._callback_(aBlock);
  430. $2=_st($1)._yourself();
  431. self._add_($2);
  432. return self}, function($ctx1) {$ctx1.fill(self,"addActionKey:labelled:callback:",{anInteger:anInteger,aString:aString,aBlock:aBlock},globals.HLBindingGroup)})},
  433. args: ["anInteger", "aString", "aBlock"],
  434. source: "addActionKey: anInteger labelled: aString callback: aBlock\x0a\x09self add: ((HLBindingAction on: anInteger labelled: aString)\x0a \x09callback: aBlock;\x0a yourself)",
  435. messageSends: ["add:", "callback:", "on:labelled:", "yourself"],
  436. referencedClasses: ["HLBindingAction"]
  437. }),
  438. globals.HLBindingGroup);
  439. smalltalk.addMethod(
  440. smalltalk.method({
  441. selector: "addGroupKey:labelled:",
  442. protocol: 'add',
  443. fn: function (anInteger,aString){
  444. var self=this;
  445. function $HLBindingGroup(){return globals.HLBindingGroup||(typeof HLBindingGroup=="undefined"?nil:HLBindingGroup)}
  446. return smalltalk.withContext(function($ctx1) {
  447. self._add_(_st($HLBindingGroup())._on_labelled_(anInteger,aString));
  448. return self}, function($ctx1) {$ctx1.fill(self,"addGroupKey:labelled:",{anInteger:anInteger,aString:aString},globals.HLBindingGroup)})},
  449. args: ["anInteger", "aString"],
  450. source: "addGroupKey: anInteger labelled: aString\x0a\x09self add: (HLBindingGroup on: anInteger labelled: aString)",
  451. messageSends: ["add:", "on:labelled:"],
  452. referencedClasses: ["HLBindingGroup"]
  453. }),
  454. globals.HLBindingGroup);
  455. smalltalk.addMethod(
  456. smalltalk.method({
  457. selector: "at:",
  458. protocol: 'accessing',
  459. fn: function (aString){
  460. var self=this;
  461. return smalltalk.withContext(function($ctx1) {
  462. var $1;
  463. $1=_st(self._bindings())._detect_ifNone_((function(each){
  464. return smalltalk.withContext(function($ctx2) {
  465. return _st(_st(each)._label()).__eq(aString);
  466. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),(function(){
  467. return nil;
  468. }));
  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,$receiver;
  486. binding=self._at_(aString);
  487. $1=binding;
  488. if(($receiver = $1) == null || $receiver.isNil){
  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 nil;
  514. }));
  515. return $1;
  516. }, function($ctx1) {$ctx1.fill(self,"atKey:",{anInteger:anInteger},globals.HLBindingGroup)})},
  517. args: ["anInteger"],
  518. source: "atKey: anInteger\x0a\x09^ self bindings \x0a \x09detect: [ :each | each key = anInteger ]\x0a \x09ifNone: [ nil ]",
  519. messageSends: ["detect:ifNone:", "bindings", "=", "key"],
  520. referencedClasses: []
  521. }),
  522. globals.HLBindingGroup);
  523. smalltalk.addMethod(
  524. smalltalk.method({
  525. selector: "bindings",
  526. protocol: 'accessing',
  527. fn: function (){
  528. var self=this;
  529. function $OrderedCollection(){return globals.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  530. return smalltalk.withContext(function($ctx1) {
  531. var $2,$1,$receiver;
  532. $2=self["@bindings"];
  533. if(($receiver = $2) == null || $receiver.isNil){
  534. self["@bindings"]=_st($OrderedCollection())._new();
  535. $1=self["@bindings"];
  536. } else {
  537. $1=$2;
  538. };
  539. return $1;
  540. }, function($ctx1) {$ctx1.fill(self,"bindings",{},globals.HLBindingGroup)})},
  541. args: [],
  542. source: "bindings\x0a\x09^ bindings ifNil: [ bindings := OrderedCollection new ]",
  543. messageSends: ["ifNil:", "new"],
  544. referencedClasses: ["OrderedCollection"]
  545. }),
  546. globals.HLBindingGroup);
  547. smalltalk.addMethod(
  548. smalltalk.method({
  549. selector: "displayLabel",
  550. protocol: 'accessing',
  551. fn: function (){
  552. var self=this;
  553. return smalltalk.withContext(function($ctx1) {
  554. var $2,$1;
  555. $2=($ctx1.supercall = true, globals.HLBindingGroup.superclass.fn.prototype._displayLabel.apply(_st(self), []));
  556. $ctx1.supercall = false;
  557. $1=_st($2).__comma("...");
  558. return $1;
  559. }, function($ctx1) {$ctx1.fill(self,"displayLabel",{},globals.HLBindingGroup)})},
  560. args: [],
  561. source: "displayLabel\x0a\x09^ super displayLabel, '...'",
  562. messageSends: [",", "displayLabel"],
  563. referencedClasses: []
  564. }),
  565. globals.HLBindingGroup);
  566. smalltalk.addMethod(
  567. smalltalk.method({
  568. selector: "isActive",
  569. protocol: 'testing',
  570. fn: function (){
  571. var self=this;
  572. return smalltalk.withContext(function($ctx1) {
  573. var $1;
  574. $1=_st(self._activeBindings())._notEmpty();
  575. return $1;
  576. }, function($ctx1) {$ctx1.fill(self,"isActive",{},globals.HLBindingGroup)})},
  577. args: [],
  578. source: "isActive\x0a\x09^ self activeBindings notEmpty",
  579. messageSends: ["notEmpty", "activeBindings"],
  580. referencedClasses: []
  581. }),
  582. globals.HLBindingGroup);
  583. smalltalk.addMethod(
  584. smalltalk.method({
  585. selector: "release",
  586. protocol: 'actions',
  587. fn: function (){
  588. var self=this;
  589. return smalltalk.withContext(function($ctx1) {
  590. _st(self._bindings())._do_((function(each){
  591. return smalltalk.withContext(function($ctx2) {
  592. return _st(each)._release();
  593. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  594. return self}, function($ctx1) {$ctx1.fill(self,"release",{},globals.HLBindingGroup)})},
  595. args: [],
  596. source: "release\x0a\x09self bindings do: [ :each | each release ]",
  597. messageSends: ["do:", "bindings", "release"],
  598. referencedClasses: []
  599. }),
  600. globals.HLBindingGroup);
  601. smalltalk.addMethod(
  602. smalltalk.method({
  603. selector: "renderOn:html:",
  604. protocol: 'rendering',
  605. fn: function (aBindingHelper,html){
  606. var self=this;
  607. return smalltalk.withContext(function($ctx1) {
  608. var $1;
  609. $1=self._isActive();
  610. if(smalltalk.assert($1)){
  611. _st(aBindingHelper)._renderBindingGroup_on_(self,html);
  612. };
  613. return self}, function($ctx1) {$ctx1.fill(self,"renderOn:html:",{aBindingHelper:aBindingHelper,html:html},globals.HLBindingGroup)})},
  614. args: ["aBindingHelper", "html"],
  615. source: "renderOn: aBindingHelper html: html\x0a\x09self isActive ifTrue: [\x0a\x09\x09aBindingHelper renderBindingGroup: self on: html ]",
  616. messageSends: ["ifTrue:", "isActive", "renderBindingGroup:on:"],
  617. referencedClasses: []
  618. }),
  619. globals.HLBindingGroup);
  620. smalltalk.addClass('HLBindingActionInputWidget', globals.HLWidget, ['input', 'callback', 'status', 'wrapper', 'ghostText', 'message', 'inputCompletion', 'defaultValue', 'messageTag'], 'Helios-KeyBindings');
  621. globals.HLBindingActionInputWidget.comment="My instances are built when a `HLBindingAction` that requires user input is applied.";
  622. smalltalk.addMethod(
  623. smalltalk.method({
  624. selector: "callback",
  625. protocol: 'accessing',
  626. fn: function (){
  627. var self=this;
  628. return smalltalk.withContext(function($ctx1) {
  629. var $2,$1,$receiver;
  630. $2=self["@callback"];
  631. if(($receiver = $2) == null || $receiver.isNil){
  632. self["@callback"]=(function(value){
  633. });
  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,$receiver;
  685. $2=self["@defaultValue"];
  686. if(($receiver = $2) == null || $receiver.isNil){
  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,$receiver;
  810. $2=self["@inputCompletion"];
  811. if(($receiver = $2) == null || $receiver.isNil){
  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,$receiver;
  846. $2=self["@message"];
  847. if(($receiver = $2) == null || $receiver.isNil){
  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,$receiver;
  883. $1=self["@wrapper"];
  884. if(($receiver = $1) == null || $receiver.isNil){
  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,$14,$15,$receiver;
  906. $1=self["@wrapper"];
  907. if(($receiver = $1) == null || $receiver.isNil){
  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._newFromPairs_(["source",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. $14=_st(self["@input"])._asJQuery();
  951. _st($14)._focus();
  952. $15=_st($14)._select();
  953. return $15;
  954. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,5)})}))._valueWithTimeout_((10));
  955. return self}, function($ctx1) {$ctx1.fill(self,"renderOn:",{html:html},globals.HLBindingActionInputWidget)})},
  956. args: ["html"],
  957. 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; select ] valueWithTimeout: 10",
  958. messageSends: ["ifNil:", "span", "class:", "status", "with:", "placeholder:", "input", "ghostText", "value:", "defaultValue", "onKeyDown:", "yourself", "ifTrue:", "=", "which", "evaluate:", "val", "asJQuery", "typeahead:", "inputCompletion", "message", "valueWithTimeout:", "focus", "select"],
  959. referencedClasses: []
  960. }),
  961. globals.HLBindingActionInputWidget);
  962. smalltalk.addMethod(
  963. smalltalk.method({
  964. selector: "status",
  965. protocol: 'accessing',
  966. fn: function (){
  967. var self=this;
  968. return smalltalk.withContext(function($ctx1) {
  969. var $2,$1,$receiver;
  970. $2=self["@status"];
  971. if(($receiver = $2) == null || $receiver.isNil){
  972. self["@status"]="info";
  973. $1=self["@status"];
  974. } else {
  975. $1=$2;
  976. };
  977. return $1;
  978. }, function($ctx1) {$ctx1.fill(self,"status",{},globals.HLBindingActionInputWidget)})},
  979. args: [],
  980. source: "status\x0a\x09^ status ifNil: [ status := 'info' ]",
  981. messageSends: ["ifNil:"],
  982. referencedClasses: []
  983. }),
  984. globals.HLBindingActionInputWidget);
  985. smalltalk.addMethod(
  986. smalltalk.method({
  987. selector: "status:",
  988. protocol: 'accessing',
  989. fn: function (aStatus){
  990. var self=this;
  991. self["@status"]=aStatus;
  992. return self},
  993. args: ["aStatus"],
  994. source: "status: aStatus\x0a\x09status := aStatus",
  995. messageSends: [],
  996. referencedClasses: []
  997. }),
  998. globals.HLBindingActionInputWidget);
  999. smalltalk.addClass('HLKeyBinder', globals.Object, ['modifierKey', 'helper', 'bindings', 'selectedBinding'], 'Helios-KeyBindings');
  1000. 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.";
  1001. smalltalk.addMethod(
  1002. smalltalk.method({
  1003. selector: "activate",
  1004. protocol: 'actions',
  1005. fn: function (){
  1006. var self=this;
  1007. return smalltalk.withContext(function($ctx1) {
  1008. _st(self._helper())._show();
  1009. return self}, function($ctx1) {$ctx1.fill(self,"activate",{},globals.HLKeyBinder)})},
  1010. args: [],
  1011. source: "activate\x0a\x09self helper show",
  1012. messageSends: ["show", "helper"],
  1013. referencedClasses: []
  1014. }),
  1015. globals.HLKeyBinder);
  1016. smalltalk.addMethod(
  1017. smalltalk.method({
  1018. selector: "activationKey",
  1019. protocol: 'accessing',
  1020. fn: function (){
  1021. var self=this;
  1022. return (32);
  1023. },
  1024. args: [],
  1025. source: "activationKey\x0a\x09\x22SPACE\x22\x0a\x09^ 32",
  1026. messageSends: [],
  1027. referencedClasses: []
  1028. }),
  1029. globals.HLKeyBinder);
  1030. smalltalk.addMethod(
  1031. smalltalk.method({
  1032. selector: "activationKeyLabel",
  1033. protocol: 'accessing',
  1034. fn: function (){
  1035. var self=this;
  1036. return "ctrl + space";
  1037. },
  1038. args: [],
  1039. source: "activationKeyLabel\x0a\x09^ 'ctrl + space'",
  1040. messageSends: [],
  1041. referencedClasses: []
  1042. }),
  1043. globals.HLKeyBinder);
  1044. smalltalk.addMethod(
  1045. smalltalk.method({
  1046. selector: "applyBinding:",
  1047. protocol: 'actions',
  1048. fn: function (aBinding){
  1049. var self=this;
  1050. return smalltalk.withContext(function($ctx1) {
  1051. var $1;
  1052. $1=_st(aBinding)._isActive();
  1053. if(! smalltalk.assert($1)){
  1054. return self;
  1055. };
  1056. self._selectBinding_(aBinding);
  1057. _st(aBinding)._apply();
  1058. return self}, function($ctx1) {$ctx1.fill(self,"applyBinding:",{aBinding:aBinding},globals.HLKeyBinder)})},
  1059. args: ["aBinding"],
  1060. source: "applyBinding: aBinding\x0a\x09aBinding isActive ifFalse: [ ^ self ].\x0a\x09\x0a\x09self selectBinding: aBinding.\x0a aBinding apply",
  1061. messageSends: ["ifFalse:", "isActive", "selectBinding:", "apply"],
  1062. referencedClasses: []
  1063. }),
  1064. globals.HLKeyBinder);
  1065. smalltalk.addMethod(
  1066. smalltalk.method({
  1067. selector: "bindings",
  1068. protocol: 'accessing',
  1069. fn: function (){
  1070. var self=this;
  1071. return smalltalk.withContext(function($ctx1) {
  1072. var $2,$1,$receiver;
  1073. $2=self["@bindings"];
  1074. if(($receiver = $2) == null || $receiver.isNil){
  1075. self["@bindings"]=self._defaultBindings();
  1076. $1=self["@bindings"];
  1077. } else {
  1078. $1=$2;
  1079. };
  1080. return $1;
  1081. }, function($ctx1) {$ctx1.fill(self,"bindings",{},globals.HLKeyBinder)})},
  1082. args: [],
  1083. source: "bindings\x0a\x09^ bindings ifNil: [ bindings := self defaultBindings ]",
  1084. messageSends: ["ifNil:", "defaultBindings"],
  1085. referencedClasses: []
  1086. }),
  1087. globals.HLKeyBinder);
  1088. smalltalk.addMethod(
  1089. smalltalk.method({
  1090. selector: "deactivate",
  1091. protocol: 'actions',
  1092. fn: function (){
  1093. var self=this;
  1094. return smalltalk.withContext(function($ctx1) {
  1095. var $1,$receiver;
  1096. $1=self["@selectedBinding"];
  1097. if(($receiver = $1) == null || $receiver.isNil){
  1098. $1;
  1099. } else {
  1100. _st(self["@selectedBinding"])._release();
  1101. };
  1102. self["@selectedBinding"]=nil;
  1103. _st(self._helper())._hide();
  1104. return self}, function($ctx1) {$ctx1.fill(self,"deactivate",{},globals.HLKeyBinder)})},
  1105. args: [],
  1106. source: "deactivate\x0a\x09selectedBinding ifNotNil: [ selectedBinding release ].\x0a selectedBinding := nil.\x0a\x09self helper hide",
  1107. messageSends: ["ifNotNil:", "release", "hide", "helper"],
  1108. referencedClasses: []
  1109. }),
  1110. globals.HLKeyBinder);
  1111. smalltalk.addMethod(
  1112. smalltalk.method({
  1113. selector: "defaultBindings",
  1114. protocol: 'defaults',
  1115. fn: function (){
  1116. var self=this;
  1117. var group;
  1118. function $HLBindingGroup(){return globals.HLBindingGroup||(typeof HLBindingGroup=="undefined"?nil:HLBindingGroup)}
  1119. function $HLCloseTabCommand(){return globals.HLCloseTabCommand||(typeof HLCloseTabCommand=="undefined"?nil:HLCloseTabCommand)}
  1120. function $HLSwitchTabCommand(){return globals.HLSwitchTabCommand||(typeof HLSwitchTabCommand=="undefined"?nil:HLSwitchTabCommand)}
  1121. function $HLOpenCommand(){return globals.HLOpenCommand||(typeof HLOpenCommand=="undefined"?nil:HLOpenCommand)}
  1122. return smalltalk.withContext(function($ctx1) {
  1123. var $1,$2,$4,$3,$5,$6;
  1124. $1=_st($HLBindingGroup())._new();
  1125. $ctx1.sendIdx["new"]=1;
  1126. $2=$1;
  1127. $4=_st($HLCloseTabCommand())._new();
  1128. $ctx1.sendIdx["new"]=2;
  1129. $3=_st($4)._asBinding();
  1130. $ctx1.sendIdx["asBinding"]=1;
  1131. _st($2)._add_($3);
  1132. $ctx1.sendIdx["add:"]=1;
  1133. _st($1)._add_(_st(_st($HLSwitchTabCommand())._new())._asBinding());
  1134. $5=_st($1)._yourself();
  1135. group=$5;
  1136. _st($HLOpenCommand())._registerConcreteClassesOn_(group);
  1137. $6=group;
  1138. return $6;
  1139. }, function($ctx1) {$ctx1.fill(self,"defaultBindings",{group:group},globals.HLKeyBinder)})},
  1140. args: [],
  1141. 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",
  1142. messageSends: ["add:", "new", "asBinding", "yourself", "registerConcreteClassesOn:"],
  1143. referencedClasses: ["HLBindingGroup", "HLCloseTabCommand", "HLSwitchTabCommand", "HLOpenCommand"]
  1144. }),
  1145. globals.HLKeyBinder);
  1146. smalltalk.addMethod(
  1147. smalltalk.method({
  1148. selector: "escapeKey",
  1149. protocol: 'accessing',
  1150. fn: function (){
  1151. var self=this;
  1152. return (27);
  1153. },
  1154. args: [],
  1155. source: "escapeKey\x0a\x09\x22ESC\x22\x0a\x09^ 27",
  1156. messageSends: [],
  1157. referencedClasses: []
  1158. }),
  1159. globals.HLKeyBinder);
  1160. smalltalk.addMethod(
  1161. smalltalk.method({
  1162. selector: "flushBindings",
  1163. protocol: 'actions',
  1164. fn: function (){
  1165. var self=this;
  1166. self["@bindings"]=nil;
  1167. return self},
  1168. args: [],
  1169. source: "flushBindings\x0a\x09bindings := nil",
  1170. messageSends: [],
  1171. referencedClasses: []
  1172. }),
  1173. globals.HLKeyBinder);
  1174. smalltalk.addMethod(
  1175. smalltalk.method({
  1176. selector: "handleActiveKeyDown:",
  1177. protocol: 'events',
  1178. fn: function (event){
  1179. var self=this;
  1180. return smalltalk.withContext(function($ctx1) {
  1181. var $3,$2,$6,$5,$4,$1,$7;
  1182. $3=_st(event)._which();
  1183. $ctx1.sendIdx["which"]=1;
  1184. $2=_st($3).__eq(self._escapeKey());
  1185. $ctx1.sendIdx["="]=1;
  1186. $1=_st($2)._or_((function(){
  1187. return smalltalk.withContext(function($ctx2) {
  1188. $6=_st(event)._which();
  1189. $ctx2.sendIdx["which"]=2;
  1190. $5=_st($6).__eq((71));
  1191. $ctx2.sendIdx["="]=2;
  1192. $4=_st($5)._or_((function(){
  1193. return smalltalk.withContext(function($ctx3) {
  1194. return _st(_st(event)._which()).__eq(self._activationKey());
  1195. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
  1196. return _st($4)._and_((function(){
  1197. return smalltalk.withContext(function($ctx3) {
  1198. return _st(event)._ctrlKey();
  1199. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
  1200. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1201. $ctx1.sendIdx["or:"]=1;
  1202. if(smalltalk.assert($1)){
  1203. self._deactivate();
  1204. _st(event)._preventDefault();
  1205. return false;
  1206. };
  1207. $7=self._handleBindingFor_(event);
  1208. return $7;
  1209. }, function($ctx1) {$ctx1.fill(self,"handleActiveKeyDown:",{event:event},globals.HLKeyBinder)})},
  1210. args: ["event"],
  1211. source: "handleActiveKeyDown: event\x0a\x0a\x09\x22ESC, ctrl+g ctrl+space deactivate the keyBinder\x22\x0a\x09(event which = self escapeKey or: [\x0a\x09\x09(event which = 71 or: [ event which = self activationKey ]) \x0a\x09\x09\x09and: [ event ctrlKey ] ])\x0a \x09\x09ifTrue: [ \x0a \x09\x09\x09self deactivate.\x0a\x09\x09\x09\x09\x09event preventDefault.\x0a\x09\x09\x09\x09\x09^ false ].\x0a \x0a \x22Handle the keybinding\x22\x0a ^ self handleBindingFor: event",
  1212. messageSends: ["ifTrue:", "or:", "=", "which", "escapeKey", "and:", "activationKey", "ctrlKey", "deactivate", "preventDefault", "handleBindingFor:"],
  1213. referencedClasses: []
  1214. }),
  1215. globals.HLKeyBinder);
  1216. smalltalk.addMethod(
  1217. smalltalk.method({
  1218. selector: "handleBindingFor:",
  1219. protocol: 'events',
  1220. fn: function (anEvent){
  1221. var self=this;
  1222. var binding;
  1223. return smalltalk.withContext(function($ctx1) {
  1224. var $1,$receiver;
  1225. binding=_st(self._selectedBinding())._atKey_(_st(anEvent)._which());
  1226. $1=binding;
  1227. if(($receiver = $1) == null || $receiver.isNil){
  1228. $1;
  1229. } else {
  1230. self._applyBinding_(binding);
  1231. _st(anEvent)._preventDefault();
  1232. return false;
  1233. };
  1234. return self}, function($ctx1) {$ctx1.fill(self,"handleBindingFor:",{anEvent:anEvent,binding:binding},globals.HLKeyBinder)})},
  1235. args: ["anEvent"],
  1236. 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 ]",
  1237. messageSends: ["atKey:", "selectedBinding", "which", "ifNotNil:", "applyBinding:", "preventDefault"],
  1238. referencedClasses: []
  1239. }),
  1240. globals.HLKeyBinder);
  1241. smalltalk.addMethod(
  1242. smalltalk.method({
  1243. selector: "handleInactiveKeyDown:",
  1244. protocol: 'events',
  1245. fn: function (event){
  1246. var self=this;
  1247. return smalltalk.withContext(function($ctx1) {
  1248. var $1,$2;
  1249. $1=_st(_st(event)._which()).__eq(self._activationKey());
  1250. if(smalltalk.assert($1)){
  1251. $2=_st(event)._ctrlKey();
  1252. if(smalltalk.assert($2)){
  1253. self._activate();
  1254. _st(event)._preventDefault();
  1255. return false;
  1256. };
  1257. };
  1258. return self}, function($ctx1) {$ctx1.fill(self,"handleInactiveKeyDown:",{event:event},globals.HLKeyBinder)})},
  1259. args: ["event"],
  1260. source: "handleInactiveKeyDown: event\x0a\x09event which = self activationKey ifTrue: [\x0a \x09event ctrlKey ifTrue: [\x0a\x09\x09\x09self activate. \x0a event preventDefault. \x0a ^ false ] ]",
  1261. messageSends: ["ifTrue:", "=", "which", "activationKey", "ctrlKey", "activate", "preventDefault"],
  1262. referencedClasses: []
  1263. }),
  1264. globals.HLKeyBinder);
  1265. smalltalk.addMethod(
  1266. smalltalk.method({
  1267. selector: "handleKeyDown:",
  1268. protocol: 'events',
  1269. fn: function (event){
  1270. var self=this;
  1271. return smalltalk.withContext(function($ctx1) {
  1272. var $2,$1;
  1273. $2=self._isActive();
  1274. if(smalltalk.assert($2)){
  1275. $1=self._handleActiveKeyDown_(event);
  1276. } else {
  1277. $1=self._handleInactiveKeyDown_(event);
  1278. };
  1279. return $1;
  1280. }, function($ctx1) {$ctx1.fill(self,"handleKeyDown:",{event:event},globals.HLKeyBinder)})},
  1281. args: ["event"],
  1282. source: "handleKeyDown: event\x0a\x09^ self isActive\x0a \x09ifTrue: [ self handleActiveKeyDown: event ]\x0a \x09ifFalse: [ self handleInactiveKeyDown: event ]",
  1283. messageSends: ["ifTrue:ifFalse:", "isActive", "handleActiveKeyDown:", "handleInactiveKeyDown:"],
  1284. referencedClasses: []
  1285. }),
  1286. globals.HLKeyBinder);
  1287. smalltalk.addMethod(
  1288. smalltalk.method({
  1289. selector: "helper",
  1290. protocol: 'accessing',
  1291. fn: function (){
  1292. var self=this;
  1293. var $1;
  1294. $1=self["@helper"];
  1295. return $1;
  1296. },
  1297. args: [],
  1298. source: "helper\x0a\x09^ helper",
  1299. messageSends: [],
  1300. referencedClasses: []
  1301. }),
  1302. globals.HLKeyBinder);
  1303. smalltalk.addMethod(
  1304. smalltalk.method({
  1305. selector: "initialize",
  1306. protocol: 'initialization',
  1307. fn: function (){
  1308. var self=this;
  1309. function $HLKeyBinderHelperWidget(){return globals.HLKeyBinderHelperWidget||(typeof HLKeyBinderHelperWidget=="undefined"?nil:HLKeyBinderHelperWidget)}
  1310. return smalltalk.withContext(function($ctx1) {
  1311. ($ctx1.supercall = true, globals.HLKeyBinder.superclass.fn.prototype._initialize.apply(_st(self), []));
  1312. $ctx1.supercall = false;
  1313. self["@helper"]=_st($HLKeyBinderHelperWidget())._on_(self);
  1314. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.HLKeyBinder)})},
  1315. args: [],
  1316. source: "initialize\x0a\x09super initialize.\x0a\x09helper := HLKeyBinderHelperWidget on: self",
  1317. messageSends: ["initialize", "on:"],
  1318. referencedClasses: ["HLKeyBinderHelperWidget"]
  1319. }),
  1320. globals.HLKeyBinder);
  1321. smalltalk.addMethod(
  1322. smalltalk.method({
  1323. selector: "isActive",
  1324. protocol: 'testing',
  1325. fn: function (){
  1326. var self=this;
  1327. return smalltalk.withContext(function($ctx1) {
  1328. var $1;
  1329. $1=_st(_st(".".__comma(_st(self._helper())._cssClass()))._asJQuery())._is_(":visible");
  1330. return $1;
  1331. }, function($ctx1) {$ctx1.fill(self,"isActive",{},globals.HLKeyBinder)})},
  1332. args: [],
  1333. source: "isActive\x0a\x09^ ('.', self helper cssClass) asJQuery is: ':visible'",
  1334. messageSends: ["is:", "asJQuery", ",", "cssClass", "helper"],
  1335. referencedClasses: []
  1336. }),
  1337. globals.HLKeyBinder);
  1338. smalltalk.addMethod(
  1339. smalltalk.method({
  1340. selector: "selectBinding:",
  1341. protocol: 'actions',
  1342. fn: function (aBinding){
  1343. var self=this;
  1344. return smalltalk.withContext(function($ctx1) {
  1345. var $1;
  1346. $1=_st(aBinding).__eq(self["@selectedBinding"]);
  1347. if(smalltalk.assert($1)){
  1348. return self;
  1349. };
  1350. self["@selectedBinding"]=aBinding;
  1351. _st(self._helper())._refresh();
  1352. return self}, function($ctx1) {$ctx1.fill(self,"selectBinding:",{aBinding:aBinding},globals.HLKeyBinder)})},
  1353. args: ["aBinding"],
  1354. source: "selectBinding: aBinding\x0a\x09aBinding = selectedBinding ifTrue: [ ^ self ].\x0a\x09\x0a\x09selectedBinding := aBinding.\x0a\x09self helper refresh",
  1355. messageSends: ["ifTrue:", "=", "refresh", "helper"],
  1356. referencedClasses: []
  1357. }),
  1358. globals.HLKeyBinder);
  1359. smalltalk.addMethod(
  1360. smalltalk.method({
  1361. selector: "selectedBinding",
  1362. protocol: 'accessing',
  1363. fn: function (){
  1364. var self=this;
  1365. return smalltalk.withContext(function($ctx1) {
  1366. var $2,$1,$receiver;
  1367. $2=self["@selectedBinding"];
  1368. if(($receiver = $2) == null || $receiver.isNil){
  1369. $1=self._bindings();
  1370. } else {
  1371. $1=$2;
  1372. };
  1373. return $1;
  1374. }, function($ctx1) {$ctx1.fill(self,"selectedBinding",{},globals.HLKeyBinder)})},
  1375. args: [],
  1376. source: "selectedBinding\x0a\x09^ selectedBinding ifNil: [ self bindings ]",
  1377. messageSends: ["ifNil:", "bindings"],
  1378. referencedClasses: []
  1379. }),
  1380. globals.HLKeyBinder);
  1381. smalltalk.addMethod(
  1382. smalltalk.method({
  1383. selector: "setupEvents",
  1384. protocol: 'events',
  1385. fn: function (){
  1386. var self=this;
  1387. return smalltalk.withContext(function($ctx1) {
  1388. _st("body"._asJQuery())._keydown_((function(event){
  1389. return smalltalk.withContext(function($ctx2) {
  1390. return self._handleKeyDown_(event);
  1391. }, function($ctx2) {$ctx2.fillBlock({event:event},$ctx1,1)})}));
  1392. return self}, function($ctx1) {$ctx1.fill(self,"setupEvents",{},globals.HLKeyBinder)})},
  1393. args: [],
  1394. source: "setupEvents\x0a\x09'body' asJQuery keydown: [ :event | self handleKeyDown: event ]",
  1395. messageSends: ["keydown:", "asJQuery", "handleKeyDown:"],
  1396. referencedClasses: []
  1397. }),
  1398. globals.HLKeyBinder);
  1399. smalltalk.addMethod(
  1400. smalltalk.method({
  1401. selector: "systemIsMac",
  1402. protocol: 'testing',
  1403. fn: function (){
  1404. var self=this;
  1405. return smalltalk.withContext(function($ctx1) {
  1406. var $1;
  1407. $1=_st(_st(navigator)._platform())._match_("Mac");
  1408. return $1;
  1409. }, function($ctx1) {$ctx1.fill(self,"systemIsMac",{},globals.HLKeyBinder)})},
  1410. args: [],
  1411. source: "systemIsMac\x0a\x09^ navigator platform match: 'Mac'",
  1412. messageSends: ["match:", "platform"],
  1413. referencedClasses: []
  1414. }),
  1415. globals.HLKeyBinder);
  1416. globals.HLKeyBinder.klass.iVarNames = ['current'];
  1417. smalltalk.addMethod(
  1418. smalltalk.method({
  1419. selector: "current",
  1420. protocol: 'instance creation',
  1421. fn: function (){
  1422. var self=this;
  1423. return smalltalk.withContext(function($ctx1) {
  1424. var $2,$1,$receiver;
  1425. $2=self["@current"];
  1426. if(($receiver = $2) == null || $receiver.isNil){
  1427. self["@current"]=($ctx1.supercall = true, globals.HLKeyBinder.klass.superclass.fn.prototype._new.apply(_st(self), []));
  1428. $ctx1.supercall = false;
  1429. $1=self["@current"];
  1430. } else {
  1431. $1=$2;
  1432. };
  1433. return $1;
  1434. }, function($ctx1) {$ctx1.fill(self,"current",{},globals.HLKeyBinder.klass)})},
  1435. args: [],
  1436. source: "current\x0a\x09^ current ifNil: [ current := super new ]",
  1437. messageSends: ["ifNil:", "new"],
  1438. referencedClasses: []
  1439. }),
  1440. globals.HLKeyBinder.klass);
  1441. smalltalk.addMethod(
  1442. smalltalk.method({
  1443. selector: "new",
  1444. protocol: 'instance creation',
  1445. fn: function (){
  1446. var self=this;
  1447. return smalltalk.withContext(function($ctx1) {
  1448. self._shouldNotImplement();
  1449. return self}, function($ctx1) {$ctx1.fill(self,"new",{},globals.HLKeyBinder.klass)})},
  1450. args: [],
  1451. source: "new\x0a\x09self shouldNotImplement",
  1452. messageSends: ["shouldNotImplement"],
  1453. referencedClasses: []
  1454. }),
  1455. globals.HLKeyBinder.klass);
  1456. smalltalk.addClass('HLKeyBinderHelperWidget', globals.HLWidget, ['keyBinder'], 'Helios-KeyBindings');
  1457. 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:`.";
  1458. smalltalk.addMethod(
  1459. smalltalk.method({
  1460. selector: "cssClass",
  1461. protocol: 'accessing',
  1462. fn: function (){
  1463. var self=this;
  1464. return "key_helper";
  1465. },
  1466. args: [],
  1467. source: "cssClass\x0a\x09^ 'key_helper'",
  1468. messageSends: [],
  1469. referencedClasses: []
  1470. }),
  1471. globals.HLKeyBinderHelperWidget);
  1472. smalltalk.addMethod(
  1473. smalltalk.method({
  1474. selector: "deactivate",
  1475. protocol: 'actions',
  1476. fn: function (){
  1477. var self=this;
  1478. return smalltalk.withContext(function($ctx1) {
  1479. _st(self._keyBinder())._deactivate();
  1480. return self}, function($ctx1) {$ctx1.fill(self,"deactivate",{},globals.HLKeyBinderHelperWidget)})},
  1481. args: [],
  1482. source: "deactivate\x0a\x09self keyBinder deactivate",
  1483. messageSends: ["deactivate", "keyBinder"],
  1484. referencedClasses: []
  1485. }),
  1486. globals.HLKeyBinderHelperWidget);
  1487. smalltalk.addMethod(
  1488. smalltalk.method({
  1489. selector: "hide",
  1490. protocol: 'actions',
  1491. fn: function (){
  1492. var self=this;
  1493. return smalltalk.withContext(function($ctx1) {
  1494. var $1;
  1495. $1=_st(".".__comma(self._cssClass()))._asJQuery();
  1496. $ctx1.sendIdx["asJQuery"]=1;
  1497. _st($1)._remove();
  1498. $ctx1.sendIdx["remove"]=1;
  1499. _st(".helper_overlay"._asJQuery())._remove();
  1500. self._showCog();
  1501. return self}, function($ctx1) {$ctx1.fill(self,"hide",{},globals.HLKeyBinderHelperWidget)})},
  1502. args: [],
  1503. source: "hide\x0a\x09('.', self cssClass) asJQuery remove.\x0a\x09'.helper_overlay' asJQuery remove.\x0a\x09self showCog",
  1504. messageSends: ["remove", "asJQuery", ",", "cssClass", "showCog"],
  1505. referencedClasses: []
  1506. }),
  1507. globals.HLKeyBinderHelperWidget);
  1508. smalltalk.addMethod(
  1509. smalltalk.method({
  1510. selector: "hideCog",
  1511. protocol: 'actions',
  1512. fn: function (){
  1513. var self=this;
  1514. return smalltalk.withContext(function($ctx1) {
  1515. _st("#cog-helper"._asJQuery())._hide();
  1516. return self}, function($ctx1) {$ctx1.fill(self,"hideCog",{},globals.HLKeyBinderHelperWidget)})},
  1517. args: [],
  1518. source: "hideCog\x0a\x09'#cog-helper' asJQuery hide",
  1519. messageSends: ["hide", "asJQuery"],
  1520. referencedClasses: []
  1521. }),
  1522. globals.HLKeyBinderHelperWidget);
  1523. smalltalk.addMethod(
  1524. smalltalk.method({
  1525. selector: "keyBinder",
  1526. protocol: 'accessing',
  1527. fn: function (){
  1528. var self=this;
  1529. var $1;
  1530. $1=self["@keyBinder"];
  1531. return $1;
  1532. },
  1533. args: [],
  1534. source: "keyBinder\x0a\x09^ keyBinder",
  1535. messageSends: [],
  1536. referencedClasses: []
  1537. }),
  1538. globals.HLKeyBinderHelperWidget);
  1539. smalltalk.addMethod(
  1540. smalltalk.method({
  1541. selector: "keyBinder:",
  1542. protocol: 'accessing',
  1543. fn: function (aKeyBinder){
  1544. var self=this;
  1545. self["@keyBinder"]=aKeyBinder;
  1546. return self},
  1547. args: ["aKeyBinder"],
  1548. source: "keyBinder: aKeyBinder\x0a\x09keyBinder := aKeyBinder",
  1549. messageSends: [],
  1550. referencedClasses: []
  1551. }),
  1552. globals.HLKeyBinderHelperWidget);
  1553. smalltalk.addMethod(
  1554. smalltalk.method({
  1555. selector: "mainId",
  1556. protocol: 'accessing',
  1557. fn: function (){
  1558. var self=this;
  1559. return "binding-helper-main";
  1560. },
  1561. args: [],
  1562. source: "mainId\x0a\x09^ 'binding-helper-main'",
  1563. messageSends: [],
  1564. referencedClasses: []
  1565. }),
  1566. globals.HLKeyBinderHelperWidget);
  1567. smalltalk.addMethod(
  1568. smalltalk.method({
  1569. selector: "renderBindingActionFor:on:",
  1570. protocol: 'rendering',
  1571. fn: function (aBinding,html){
  1572. var self=this;
  1573. return smalltalk.withContext(function($ctx1) {
  1574. var $1,$3,$4,$5,$6,$2;
  1575. $1=_st(html)._span();
  1576. _st($1)._class_("command");
  1577. $ctx1.sendIdx["class:"]=1;
  1578. $2=_st($1)._with_((function(){
  1579. return smalltalk.withContext(function($ctx2) {
  1580. $3=_st(html)._strong();
  1581. _st($3)._class_("label");
  1582. $ctx2.sendIdx["class:"]=2;
  1583. $4=_st($3)._with_(_st(_st(aBinding)._shortcut())._asLowercase());
  1584. $ctx2.sendIdx["with:"]=2;
  1585. $4;
  1586. $5=_st(html)._a();
  1587. _st($5)._class_("action");
  1588. _st($5)._with_(_st(aBinding)._displayLabel());
  1589. $6=_st($5)._onClick_((function(){
  1590. return smalltalk.withContext(function($ctx3) {
  1591. return _st(self._keyBinder())._applyBinding_(aBinding);
  1592. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
  1593. return $6;
  1594. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1595. $ctx1.sendIdx["with:"]=1;
  1596. return self}, function($ctx1) {$ctx1.fill(self,"renderBindingActionFor:on:",{aBinding:aBinding,html:html},globals.HLKeyBinderHelperWidget)})},
  1597. args: ["aBinding", "html"],
  1598. source: "renderBindingActionFor: aBinding on: html\x0a\x09html span class: 'command'; with: [\x0a\x09\x09html strong \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 ] ]",
  1599. messageSends: ["class:", "span", "with:", "strong", "asLowercase", "shortcut", "a", "displayLabel", "onClick:", "applyBinding:", "keyBinder"],
  1600. referencedClasses: []
  1601. }),
  1602. globals.HLKeyBinderHelperWidget);
  1603. smalltalk.addMethod(
  1604. smalltalk.method({
  1605. selector: "renderBindingGroup:on:",
  1606. protocol: 'rendering',
  1607. fn: function (aBindingGroup,html){
  1608. var self=this;
  1609. return smalltalk.withContext(function($ctx1) {
  1610. var $1;
  1611. _st(_st(_st(aBindingGroup)._activeBindings())._sorted_((function(a,b){
  1612. return smalltalk.withContext(function($ctx2) {
  1613. $1=_st(a)._key();
  1614. $ctx2.sendIdx["key"]=1;
  1615. return _st($1).__lt(_st(b)._key());
  1616. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1,1)})})))._do_((function(each){
  1617. return smalltalk.withContext(function($ctx2) {
  1618. return self._renderBindingActionFor_on_(each,html);
  1619. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
  1620. return self}, function($ctx1) {$ctx1.fill(self,"renderBindingGroup:on:",{aBindingGroup:aBindingGroup,html:html},globals.HLKeyBinderHelperWidget)})},
  1621. args: ["aBindingGroup", "html"],
  1622. 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 ]",
  1623. messageSends: ["do:", "sorted:", "activeBindings", "<", "key", "renderBindingActionFor:on:"],
  1624. referencedClasses: []
  1625. }),
  1626. globals.HLKeyBinderHelperWidget);
  1627. smalltalk.addMethod(
  1628. smalltalk.method({
  1629. selector: "renderCloseOn:",
  1630. protocol: 'rendering',
  1631. fn: function (html){
  1632. var self=this;
  1633. return smalltalk.withContext(function($ctx1) {
  1634. var $1,$2;
  1635. $1=_st(html)._a();
  1636. _st($1)._class_("close");
  1637. $ctx1.sendIdx["class:"]=1;
  1638. _st($1)._with_((function(){
  1639. return smalltalk.withContext(function($ctx2) {
  1640. return _st(_st(html)._tag_("i"))._class_("icon-remove");
  1641. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1642. $2=_st($1)._onClick_((function(){
  1643. return smalltalk.withContext(function($ctx2) {
  1644. return _st(self._keyBinder())._deactivate();
  1645. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  1646. return self}, function($ctx1) {$ctx1.fill(self,"renderCloseOn:",{html:html},globals.HLKeyBinderHelperWidget)})},
  1647. args: ["html"],
  1648. 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 ]",
  1649. messageSends: ["class:", "a", "with:", "tag:", "onClick:", "deactivate", "keyBinder"],
  1650. referencedClasses: []
  1651. }),
  1652. globals.HLKeyBinderHelperWidget);
  1653. smalltalk.addMethod(
  1654. smalltalk.method({
  1655. selector: "renderContentOn:",
  1656. protocol: 'rendering',
  1657. fn: function (html){
  1658. var self=this;
  1659. return smalltalk.withContext(function($ctx1) {
  1660. var $1,$2,$3,$5,$6,$4;
  1661. $1=_st(html)._div();
  1662. $ctx1.sendIdx["div"]=1;
  1663. _st($1)._id_("overlay");
  1664. $ctx1.sendIdx["id:"]=1;
  1665. _st($1)._class_("helper_overlay");
  1666. $ctx1.sendIdx["class:"]=1;
  1667. $2=_st($1)._onClick_((function(){
  1668. return smalltalk.withContext(function($ctx2) {
  1669. return self._deactivate();
  1670. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1671. $3=_st(html)._div();
  1672. $ctx1.sendIdx["div"]=2;
  1673. _st($3)._class_(self._cssClass());
  1674. $4=_st($3)._with_((function(){
  1675. return smalltalk.withContext(function($ctx2) {
  1676. self._renderLabelOn_(html);
  1677. $5=_st(html)._div();
  1678. _st($5)._id_(self._mainId());
  1679. $6=_st($5)._with_((function(){
  1680. return smalltalk.withContext(function($ctx3) {
  1681. return self._renderSelectedBindingOn_(html);
  1682. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
  1683. $6;
  1684. return self._renderCloseOn_(html);
  1685. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  1686. $ctx1.sendIdx["with:"]=1;
  1687. _st(":focus"._asJQuery())._blur();
  1688. return self}, function($ctx1) {$ctx1.fill(self,"renderContentOn:",{html:html},globals.HLKeyBinderHelperWidget)})},
  1689. args: ["html"],
  1690. source: "renderContentOn: html\x0a\x09html div \x0a\x09\x09id: 'overlay';\x0a\x09\x09class: 'helper_overlay';\x0a\x09\x09onClick: [ self deactivate ].\x0a\x09\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 ].\x0a\x09\x09\x0a\x09':focus' asJQuery blur",
  1691. messageSends: ["id:", "div", "class:", "onClick:", "deactivate", "cssClass", "with:", "renderLabelOn:", "mainId", "renderSelectedBindingOn:", "renderCloseOn:", "blur", "asJQuery"],
  1692. referencedClasses: []
  1693. }),
  1694. globals.HLKeyBinderHelperWidget);
  1695. smalltalk.addMethod(
  1696. smalltalk.method({
  1697. selector: "renderLabelOn:",
  1698. protocol: 'rendering',
  1699. fn: function (html){
  1700. var self=this;
  1701. return smalltalk.withContext(function($ctx1) {
  1702. var $1,$3,$5,$4,$2,$receiver;
  1703. $1=_st(html)._span();
  1704. _st($1)._class_("selected");
  1705. $3=$1;
  1706. $5=_st(self._selectedBinding())._label();
  1707. if(($receiver = $5) == null || $receiver.isNil){
  1708. $4="Action";
  1709. } else {
  1710. $4=$5;
  1711. };
  1712. $2=_st($3)._with_($4);
  1713. return self}, function($ctx1) {$ctx1.fill(self,"renderLabelOn:",{html:html},globals.HLKeyBinderHelperWidget)})},
  1714. args: ["html"],
  1715. source: "renderLabelOn: html\x0a\x09\x09html span \x0a \x09class: 'selected'; \x0a with: (self selectedBinding label ifNil: [ 'Action' ])",
  1716. messageSends: ["class:", "span", "with:", "ifNil:", "label", "selectedBinding"],
  1717. referencedClasses: []
  1718. }),
  1719. globals.HLKeyBinderHelperWidget);
  1720. smalltalk.addMethod(
  1721. smalltalk.method({
  1722. selector: "renderSelectedBindingOn:",
  1723. protocol: 'rendering',
  1724. fn: function (html){
  1725. var self=this;
  1726. return smalltalk.withContext(function($ctx1) {
  1727. _st(self._selectedBinding())._renderOn_html_(self,html);
  1728. return self}, function($ctx1) {$ctx1.fill(self,"renderSelectedBindingOn:",{html:html},globals.HLKeyBinderHelperWidget)})},
  1729. args: ["html"],
  1730. source: "renderSelectedBindingOn: html\x0a\x09self selectedBinding renderOn: self html: html",
  1731. messageSends: ["renderOn:html:", "selectedBinding"],
  1732. referencedClasses: []
  1733. }),
  1734. globals.HLKeyBinderHelperWidget);
  1735. smalltalk.addMethod(
  1736. smalltalk.method({
  1737. selector: "selectedBinding",
  1738. protocol: 'accessing',
  1739. fn: function (){
  1740. var self=this;
  1741. return smalltalk.withContext(function($ctx1) {
  1742. var $1;
  1743. $1=_st(self._keyBinder())._selectedBinding();
  1744. return $1;
  1745. }, function($ctx1) {$ctx1.fill(self,"selectedBinding",{},globals.HLKeyBinderHelperWidget)})},
  1746. args: [],
  1747. source: "selectedBinding\x0a\x09^ self keyBinder selectedBinding",
  1748. messageSends: ["selectedBinding", "keyBinder"],
  1749. referencedClasses: []
  1750. }),
  1751. globals.HLKeyBinderHelperWidget);
  1752. smalltalk.addMethod(
  1753. smalltalk.method({
  1754. selector: "show",
  1755. protocol: 'actions',
  1756. fn: function (){
  1757. var self=this;
  1758. return smalltalk.withContext(function($ctx1) {
  1759. self._hideCog();
  1760. self._appendToJQuery_("body"._asJQuery());
  1761. return self}, function($ctx1) {$ctx1.fill(self,"show",{},globals.HLKeyBinderHelperWidget)})},
  1762. args: [],
  1763. source: "show\x0a\x09self hideCog.\x0a\x09self appendToJQuery: 'body' asJQuery",
  1764. messageSends: ["hideCog", "appendToJQuery:", "asJQuery"],
  1765. referencedClasses: []
  1766. }),
  1767. globals.HLKeyBinderHelperWidget);
  1768. smalltalk.addMethod(
  1769. smalltalk.method({
  1770. selector: "showCog",
  1771. protocol: 'actions',
  1772. fn: function (){
  1773. var self=this;
  1774. return smalltalk.withContext(function($ctx1) {
  1775. _st("#cog-helper"._asJQuery())._show();
  1776. return self}, function($ctx1) {$ctx1.fill(self,"showCog",{},globals.HLKeyBinderHelperWidget)})},
  1777. args: [],
  1778. source: "showCog\x0a\x09'#cog-helper' asJQuery show",
  1779. messageSends: ["show", "asJQuery"],
  1780. referencedClasses: []
  1781. }),
  1782. globals.HLKeyBinderHelperWidget);
  1783. smalltalk.addMethod(
  1784. smalltalk.method({
  1785. selector: "showWidget:",
  1786. protocol: 'actions',
  1787. fn: function (aWidget){
  1788. var self=this;
  1789. return smalltalk.withContext(function($ctx1) {
  1790. var $3,$2,$1;
  1791. $3=self._mainId();
  1792. $ctx1.sendIdx["mainId"]=1;
  1793. $2="#".__comma($3);
  1794. $ctx1.sendIdx[","]=1;
  1795. $1=_st($2)._asJQuery();
  1796. $ctx1.sendIdx["asJQuery"]=1;
  1797. _st($1)._empty();
  1798. _st(aWidget)._appendToJQuery_(_st("#".__comma(self._mainId()))._asJQuery());
  1799. return self}, function($ctx1) {$ctx1.fill(self,"showWidget:",{aWidget:aWidget},globals.HLKeyBinderHelperWidget)})},
  1800. args: ["aWidget"],
  1801. 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",
  1802. messageSends: ["empty", "asJQuery", ",", "mainId", "appendToJQuery:"],
  1803. referencedClasses: []
  1804. }),
  1805. globals.HLKeyBinderHelperWidget);
  1806. smalltalk.addMethod(
  1807. smalltalk.method({
  1808. selector: "on:",
  1809. protocol: 'instance creation',
  1810. fn: function (aKeyBinder){
  1811. var self=this;
  1812. return smalltalk.withContext(function($ctx1) {
  1813. var $2,$3,$1;
  1814. $2=self._new();
  1815. _st($2)._keyBinder_(aKeyBinder);
  1816. $3=_st($2)._yourself();
  1817. $1=$3;
  1818. return $1;
  1819. }, function($ctx1) {$ctx1.fill(self,"on:",{aKeyBinder:aKeyBinder},globals.HLKeyBinderHelperWidget.klass)})},
  1820. args: ["aKeyBinder"],
  1821. source: "on: aKeyBinder\x0a\x09^ self new\x0a \x09keyBinder: aKeyBinder;\x0a yourself",
  1822. messageSends: ["keyBinder:", "new", "yourself"],
  1823. referencedClasses: []
  1824. }),
  1825. globals.HLKeyBinderHelperWidget.klass);
  1826. smalltalk.addClass('HLRepeatedKeyDownHandler', globals.Object, ['repeatInterval', 'delay', 'interval', 'keyBindings', 'widget', 'keyDown'], 'Helios-KeyBindings');
  1827. 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.";
  1828. smalltalk.addMethod(
  1829. smalltalk.method({
  1830. selector: "bindKeys",
  1831. protocol: 'binding',
  1832. fn: function (){
  1833. var self=this;
  1834. return smalltalk.withContext(function($ctx1) {
  1835. _st(self._widget())._bindKeyDown_keyUp_((function(e){
  1836. return smalltalk.withContext(function($ctx2) {
  1837. return self._handleKeyDown_(e);
  1838. }, function($ctx2) {$ctx2.fillBlock({e:e},$ctx1,1)})}),(function(e){
  1839. return smalltalk.withContext(function($ctx2) {
  1840. return self._handleKeyUp();
  1841. }, function($ctx2) {$ctx2.fillBlock({e:e},$ctx1,2)})}));
  1842. return self}, function($ctx1) {$ctx1.fill(self,"bindKeys",{},globals.HLRepeatedKeyDownHandler)})},
  1843. args: [],
  1844. source: "bindKeys\x0a\x09self widget \x0a\x09\x09bindKeyDown: [ :e | self handleKeyDown: e ] \x0a\x09\x09keyUp: [ :e | self handleKeyUp ]",
  1845. messageSends: ["bindKeyDown:keyUp:", "widget", "handleKeyDown:", "handleKeyUp"],
  1846. referencedClasses: []
  1847. }),
  1848. globals.HLRepeatedKeyDownHandler);
  1849. smalltalk.addMethod(
  1850. smalltalk.method({
  1851. selector: "defaultRepeatInterval",
  1852. protocol: 'defaults',
  1853. fn: function (){
  1854. var self=this;
  1855. return (70);
  1856. },
  1857. args: [],
  1858. source: "defaultRepeatInterval\x0a\x09^ 70",
  1859. messageSends: [],
  1860. referencedClasses: []
  1861. }),
  1862. globals.HLRepeatedKeyDownHandler);
  1863. smalltalk.addMethod(
  1864. smalltalk.method({
  1865. selector: "handleEvent:forKey:action:",
  1866. protocol: 'events handling',
  1867. fn: function (anEvent,anInteger,aBlock){
  1868. var self=this;
  1869. return smalltalk.withContext(function($ctx1) {
  1870. var $1;
  1871. $1=_st(_st(_st(anEvent)._which()).__eq(anInteger))._and_((function(){
  1872. return smalltalk.withContext(function($ctx2) {
  1873. return _st(self._isKeyDown())._not();
  1874. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1875. if(smalltalk.assert($1)){
  1876. self._whileKeyDownDo_(aBlock);
  1877. };
  1878. return self}, function($ctx1) {$ctx1.fill(self,"handleEvent:forKey:action:",{anEvent:anEvent,anInteger:anInteger,aBlock:aBlock},globals.HLRepeatedKeyDownHandler)})},
  1879. args: ["anEvent", "anInteger", "aBlock"],
  1880. source: "handleEvent: anEvent forKey: anInteger action: aBlock\x0a\x09(anEvent which = anInteger and: [ self isKeyDown not ])\x0a\x09\x09ifTrue: [ self whileKeyDownDo: aBlock ]",
  1881. messageSends: ["ifTrue:", "and:", "=", "which", "not", "isKeyDown", "whileKeyDownDo:"],
  1882. referencedClasses: []
  1883. }),
  1884. globals.HLRepeatedKeyDownHandler);
  1885. smalltalk.addMethod(
  1886. smalltalk.method({
  1887. selector: "handleKeyDown:",
  1888. protocol: 'events handling',
  1889. fn: function (anEvent){
  1890. var self=this;
  1891. return smalltalk.withContext(function($ctx1) {
  1892. _st(self._keyBindings())._keysAndValuesDo_((function(key,action){
  1893. return smalltalk.withContext(function($ctx2) {
  1894. return self._handleEvent_forKey_action_(anEvent,key,action);
  1895. }, function($ctx2) {$ctx2.fillBlock({key:key,action:action},$ctx1,1)})}));
  1896. return self}, function($ctx1) {$ctx1.fill(self,"handleKeyDown:",{anEvent:anEvent},globals.HLRepeatedKeyDownHandler)})},
  1897. args: ["anEvent"],
  1898. source: "handleKeyDown: anEvent\x0a\x09self keyBindings keysAndValuesDo: [ :key :action | \x0a\x09\x09self handleEvent: anEvent forKey: key action: action ]",
  1899. messageSends: ["keysAndValuesDo:", "keyBindings", "handleEvent:forKey:action:"],
  1900. referencedClasses: []
  1901. }),
  1902. globals.HLRepeatedKeyDownHandler);
  1903. smalltalk.addMethod(
  1904. smalltalk.method({
  1905. selector: "handleKeyUp",
  1906. protocol: 'events handling',
  1907. fn: function (){
  1908. var self=this;
  1909. return smalltalk.withContext(function($ctx1) {
  1910. var $1,$2,$3,$receiver;
  1911. $1=self._isKeyDown();
  1912. if(smalltalk.assert($1)){
  1913. self["@keyDown"]=false;
  1914. self["@keyDown"];
  1915. $2=self["@interval"];
  1916. if(($receiver = $2) == null || $receiver.isNil){
  1917. $2;
  1918. } else {
  1919. _st(self["@interval"])._clearInterval();
  1920. };
  1921. $3=self["@delay"];
  1922. if(($receiver = $3) == null || $receiver.isNil){
  1923. $3;
  1924. } else {
  1925. _st(self["@delay"])._clearTimeout();
  1926. };
  1927. };
  1928. return self}, function($ctx1) {$ctx1.fill(self,"handleKeyUp",{},globals.HLRepeatedKeyDownHandler)})},
  1929. args: [],
  1930. source: "handleKeyUp\x0a\x09self isKeyDown ifTrue: [\x0a\x09\x09keyDown := false.\x0a\x09\x09interval ifNotNil: [ interval clearInterval ].\x0a\x09\x09delay ifNotNil: [ delay clearTimeout ] ]",
  1931. messageSends: ["ifTrue:", "isKeyDown", "ifNotNil:", "clearInterval", "clearTimeout"],
  1932. referencedClasses: []
  1933. }),
  1934. globals.HLRepeatedKeyDownHandler);
  1935. smalltalk.addMethod(
  1936. smalltalk.method({
  1937. selector: "isKeyDown",
  1938. protocol: 'testing',
  1939. fn: function (){
  1940. var self=this;
  1941. return smalltalk.withContext(function($ctx1) {
  1942. var $2,$1,$receiver;
  1943. $2=self["@keyDown"];
  1944. if(($receiver = $2) == null || $receiver.isNil){
  1945. $1=false;
  1946. } else {
  1947. $1=$2;
  1948. };
  1949. return $1;
  1950. }, function($ctx1) {$ctx1.fill(self,"isKeyDown",{},globals.HLRepeatedKeyDownHandler)})},
  1951. args: [],
  1952. source: "isKeyDown\x0a\x09^ keyDown ifNil: [ false ]",
  1953. messageSends: ["ifNil:"],
  1954. referencedClasses: []
  1955. }),
  1956. globals.HLRepeatedKeyDownHandler);
  1957. smalltalk.addMethod(
  1958. smalltalk.method({
  1959. selector: "keyBindings",
  1960. protocol: 'accessing',
  1961. fn: function (){
  1962. var self=this;
  1963. function $Dictionary(){return globals.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1964. return smalltalk.withContext(function($ctx1) {
  1965. var $2,$1,$receiver;
  1966. $2=self["@keyBindings"];
  1967. if(($receiver = $2) == null || $receiver.isNil){
  1968. self["@keyBindings"]=_st($Dictionary())._new();
  1969. $1=self["@keyBindings"];
  1970. } else {
  1971. $1=$2;
  1972. };
  1973. return $1;
  1974. }, function($ctx1) {$ctx1.fill(self,"keyBindings",{},globals.HLRepeatedKeyDownHandler)})},
  1975. args: [],
  1976. source: "keyBindings\x0a\x09^ keyBindings ifNil: [ keyBindings := Dictionary new ]",
  1977. messageSends: ["ifNil:", "new"],
  1978. referencedClasses: ["Dictionary"]
  1979. }),
  1980. globals.HLRepeatedKeyDownHandler);
  1981. smalltalk.addMethod(
  1982. smalltalk.method({
  1983. selector: "rebindKeys",
  1984. protocol: 'binding',
  1985. fn: function (){
  1986. var self=this;
  1987. return smalltalk.withContext(function($ctx1) {
  1988. var $1;
  1989. self._unbindKeys();
  1990. $1=self._bindKeys();
  1991. return self}, function($ctx1) {$ctx1.fill(self,"rebindKeys",{},globals.HLRepeatedKeyDownHandler)})},
  1992. args: [],
  1993. source: "rebindKeys\x0a\x09self \x0a\x09\x09unbindKeys;\x0a\x09\x09bindKeys",
  1994. messageSends: ["unbindKeys", "bindKeys"],
  1995. referencedClasses: []
  1996. }),
  1997. globals.HLRepeatedKeyDownHandler);
  1998. smalltalk.addMethod(
  1999. smalltalk.method({
  2000. selector: "repeatInterval",
  2001. protocol: 'accessing',
  2002. fn: function (){
  2003. var self=this;
  2004. return smalltalk.withContext(function($ctx1) {
  2005. var $2,$1,$receiver;
  2006. $2=self["@repeatInterval"];
  2007. if(($receiver = $2) == null || $receiver.isNil){
  2008. $1=self._defaultRepeatInterval();
  2009. } else {
  2010. $1=$2;
  2011. };
  2012. return $1;
  2013. }, function($ctx1) {$ctx1.fill(self,"repeatInterval",{},globals.HLRepeatedKeyDownHandler)})},
  2014. args: [],
  2015. source: "repeatInterval\x0a\x09^ repeatInterval ifNil: [ self defaultRepeatInterval ]",
  2016. messageSends: ["ifNil:", "defaultRepeatInterval"],
  2017. referencedClasses: []
  2018. }),
  2019. globals.HLRepeatedKeyDownHandler);
  2020. smalltalk.addMethod(
  2021. smalltalk.method({
  2022. selector: "repeatInterval:",
  2023. protocol: 'accessing',
  2024. fn: function (anInteger){
  2025. var self=this;
  2026. self["@repeatInterval"]=anInteger;
  2027. return self},
  2028. args: ["anInteger"],
  2029. source: "repeatInterval: anInteger\x0a\x09repeatInterval := anInteger",
  2030. messageSends: [],
  2031. referencedClasses: []
  2032. }),
  2033. globals.HLRepeatedKeyDownHandler);
  2034. smalltalk.addMethod(
  2035. smalltalk.method({
  2036. selector: "startRepeatingAction:",
  2037. protocol: 'actions',
  2038. fn: function (aBlock){
  2039. var self=this;
  2040. return smalltalk.withContext(function($ctx1) {
  2041. var $2,$1;
  2042. $1=_st((function(){
  2043. return smalltalk.withContext(function($ctx2) {
  2044. $2=_st(self._widget())._hasFocus();
  2045. if(smalltalk.assert($2)){
  2046. return _st(aBlock)._value();
  2047. } else {
  2048. return self._handleKeyUp();
  2049. };
  2050. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._valueWithInterval_(self._repeatInterval());
  2051. return $1;
  2052. }, function($ctx1) {$ctx1.fill(self,"startRepeatingAction:",{aBlock:aBlock},globals.HLRepeatedKeyDownHandler)})},
  2053. args: ["aBlock"],
  2054. source: "startRepeatingAction: aBlock\x0a\x09^ [ (self widget hasFocus)\x0a\x09\x09ifTrue: [ aBlock value ]\x0a\x09\x09ifFalse: [ self handleKeyUp ] ] valueWithInterval: self repeatInterval",
  2055. messageSends: ["valueWithInterval:", "ifTrue:ifFalse:", "hasFocus", "widget", "value", "handleKeyUp", "repeatInterval"],
  2056. referencedClasses: []
  2057. }),
  2058. globals.HLRepeatedKeyDownHandler);
  2059. smalltalk.addMethod(
  2060. smalltalk.method({
  2061. selector: "unbindKeys",
  2062. protocol: 'binding',
  2063. fn: function (){
  2064. var self=this;
  2065. return smalltalk.withContext(function($ctx1) {
  2066. _st(self._widget())._unbindKeyDownKeyUp();
  2067. return self}, function($ctx1) {$ctx1.fill(self,"unbindKeys",{},globals.HLRepeatedKeyDownHandler)})},
  2068. args: [],
  2069. source: "unbindKeys\x0a\x09self widget unbindKeyDownKeyUp",
  2070. messageSends: ["unbindKeyDownKeyUp", "widget"],
  2071. referencedClasses: []
  2072. }),
  2073. globals.HLRepeatedKeyDownHandler);
  2074. smalltalk.addMethod(
  2075. smalltalk.method({
  2076. selector: "whileKeyDown:do:",
  2077. protocol: 'actions',
  2078. fn: function (aKey,aBlock){
  2079. var self=this;
  2080. return smalltalk.withContext(function($ctx1) {
  2081. _st(self._keyBindings())._at_put_(aKey,aBlock);
  2082. return self}, function($ctx1) {$ctx1.fill(self,"whileKeyDown:do:",{aKey:aKey,aBlock:aBlock},globals.HLRepeatedKeyDownHandler)})},
  2083. args: ["aKey", "aBlock"],
  2084. source: "whileKeyDown: aKey do: aBlock\x0a\x09self keyBindings at: aKey put: aBlock",
  2085. messageSends: ["at:put:", "keyBindings"],
  2086. referencedClasses: []
  2087. }),
  2088. globals.HLRepeatedKeyDownHandler);
  2089. smalltalk.addMethod(
  2090. smalltalk.method({
  2091. selector: "whileKeyDownDo:",
  2092. protocol: 'events handling',
  2093. fn: function (aBlock){
  2094. var self=this;
  2095. return smalltalk.withContext(function($ctx1) {
  2096. self["@keyDown"]=true;
  2097. _st(aBlock)._value();
  2098. self["@delay"]=_st((function(){
  2099. return smalltalk.withContext(function($ctx2) {
  2100. self["@interval"]=self._startRepeatingAction_(aBlock);
  2101. return self["@interval"];
  2102. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._valueWithTimeout_((300));
  2103. return self}, function($ctx1) {$ctx1.fill(self,"whileKeyDownDo:",{aBlock:aBlock},globals.HLRepeatedKeyDownHandler)})},
  2104. args: ["aBlock"],
  2105. source: "whileKeyDownDo: aBlock\x0a\x09keyDown := true.\x0a\x09aBlock value.\x0a\x09delay := [ interval := self startRepeatingAction: aBlock ] \x0a\x09\x09valueWithTimeout: 300",
  2106. messageSends: ["value", "valueWithTimeout:", "startRepeatingAction:"],
  2107. referencedClasses: []
  2108. }),
  2109. globals.HLRepeatedKeyDownHandler);
  2110. smalltalk.addMethod(
  2111. smalltalk.method({
  2112. selector: "widget",
  2113. protocol: 'accessing',
  2114. fn: function (){
  2115. var self=this;
  2116. var $1;
  2117. $1=self["@widget"];
  2118. return $1;
  2119. },
  2120. args: [],
  2121. source: "widget\x0a\x09^ widget",
  2122. messageSends: [],
  2123. referencedClasses: []
  2124. }),
  2125. globals.HLRepeatedKeyDownHandler);
  2126. smalltalk.addMethod(
  2127. smalltalk.method({
  2128. selector: "widget:",
  2129. protocol: 'accessing',
  2130. fn: function (aWidget){
  2131. var self=this;
  2132. self["@widget"]=aWidget;
  2133. return self},
  2134. args: ["aWidget"],
  2135. source: "widget: aWidget\x0a\x09widget := aWidget",
  2136. messageSends: [],
  2137. referencedClasses: []
  2138. }),
  2139. globals.HLRepeatedKeyDownHandler);
  2140. smalltalk.addMethod(
  2141. smalltalk.method({
  2142. selector: "on:",
  2143. protocol: 'instance creation',
  2144. fn: function (aWidget){
  2145. var self=this;
  2146. return smalltalk.withContext(function($ctx1) {
  2147. var $2,$3,$1;
  2148. $2=self._new();
  2149. _st($2)._widget_(aWidget);
  2150. $3=_st($2)._yourself();
  2151. $1=$3;
  2152. return $1;
  2153. }, function($ctx1) {$ctx1.fill(self,"on:",{aWidget:aWidget},globals.HLRepeatedKeyDownHandler.klass)})},
  2154. args: ["aWidget"],
  2155. source: "on: aWidget\x0a\x09^ self new\x0a\x09\x09widget: aWidget;\x0a\x09\x09yourself",
  2156. messageSends: ["widget:", "new", "yourself"],
  2157. referencedClasses: []
  2158. }),
  2159. globals.HLRepeatedKeyDownHandler.klass);
  2160. });