1
0

Helios-KeyBindings.js 78 KB

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