Helios-KeyBindings.js 77 KB

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