2
0

Helios-KeyBindings.js 79 KB

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