Helios-KeyBindings.js 79 KB

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