Helios-KeyBindings.js 78 KB

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