Helios-KeyBindings.js 73 KB

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