Helios-KeyBindings.js 73 KB

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