Browse Source

pairing session with Ryan to add cmd-B and ctrl-B reaction of browsing the selected instVar in inspectors

Sebastian Sastre 9 years ago
parent
commit
9397395680
2 changed files with 141 additions and 3 deletions
  1. 120 2
      src/Helios-Inspector.js
  2. 21 1
      src/Helios-Inspector.st

+ 120 - 2
src/Helios-Inspector.js

@@ -553,6 +553,38 @@ messageSends: ["ifNil:", "new"]
 }),
 $globals.HLInspectorVariablesWidget);
 
+$core.addMethod(
+$core.method({
+selector: "bindKeys",
+protocol: 'actions',
+fn: function (){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) { 
+//>>excludeEnd("ctx");
+$recv($recv(self._wrapper())._asJQuery())._keydown_((function(e){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+return self._handleKeyDown_(e);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({e:e},$ctx1,1)});
+//>>excludeEnd("ctx");
+}));
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"bindKeys",{},$globals.HLInspectorVariablesWidget)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "bindKeys\x0a\x09self wrapper asJQuery\x0a\x09\x09keydown: [ :e | self handleKeyDown: e ] ",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["keydown:", "asJQuery", "wrapper", "handleKeyDown:"]
+}),
+$globals.HLInspectorVariablesWidget);
+
 $core.addMethod(
 $core.method({
 selector: "defaultItems",
@@ -603,6 +635,91 @@ messageSends: ["announce:", "announcer", "new"]
 }),
 $globals.HLInspectorVariablesWidget);
 
+$core.addMethod(
+$core.method({
+selector: "handleKeyDown:",
+protocol: 'reactions',
+fn: function (anEvent){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) { 
+//>>excludeEnd("ctx");
+var $3,$2,$4,$1,$5;
+$3=$recv(anEvent)._keyCode();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["keyCode"]=1;
+//>>excludeEnd("ctx");
+$2=$recv($3).__eq((66));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["="]=1;
+//>>excludeEnd("ctx");
+$1=$recv($2)._and_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+$4=$recv(anEvent)._ctrlKey();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx2.sendIdx["ctrlKey"]=1;
+//>>excludeEnd("ctx");
+return $recv($4)._or_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx3) {
+//>>excludeEnd("ctx");
+return $recv(anEvent)._metaKey();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx3.sendIdx["metaKey"]=1;
+//>>excludeEnd("ctx");
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
+//>>excludeEnd("ctx");
+}));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx2.sendIdx["or:"]=1;
+//>>excludeEnd("ctx");
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
+//>>excludeEnd("ctx");
+}));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["and:"]=1;
+//>>excludeEnd("ctx");
+if($core.assert($1)){
+$recv($recv($recv(self["@inspector"])._model())._instVarObjectAt_(self["@selectedItem"]))._browse();
+};
+$5=$recv($recv($recv(anEvent)._keyCode()).__eq((73)))._and_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+return $recv($recv(anEvent)._ctrlKey())._or_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx3) {
+//>>excludeEnd("ctx");
+return $recv(anEvent)._metaKey();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx3) {$ctx3.fillBlock({},$ctx2,5)});
+//>>excludeEnd("ctx");
+}));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)});
+//>>excludeEnd("ctx");
+}));
+if($core.assert($5)){
+self._dive();
+};
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"handleKeyDown:",{anEvent:anEvent},$globals.HLInspectorVariablesWidget)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["anEvent"],
+source: "handleKeyDown: anEvent\x0a\x0a\x09(anEvent keyCode = 66 and: [\x0a\x09anEvent ctrlKey or: [\x0a\x09anEvent metaKey ] ]) ifTrue: [\x0a\x09\x09(inspector model instVarObjectAt: selectedItem) browse ].\x0a\x0a\x09(anEvent keyCode = 73 and: [\x0a\x09anEvent ctrlKey or: [\x0a\x09anEvent metaKey ] ]) ifTrue: [\x0a\x09\x09self dive ].\x0a\x09\x09\x0a\x09",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["ifTrue:", "and:", "=", "keyCode", "or:", "ctrlKey", "metaKey", "browse", "instVarObjectAt:", "model", "dive"]
+}),
+$globals.HLInspectorVariablesWidget);
+
 $core.addMethod(
 $core.method({
 selector: "inspector",
@@ -792,6 +909,7 @@ return self._dive();
 }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
 //>>excludeEnd("ctx");
 }));
+self._bindKeys();
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"renderContentOn:",{html:html},$globals.HLInspectorVariablesWidget)});
@@ -799,10 +917,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["html"],
-source: "renderContentOn: html\x0a\x09self renderHeadOn: html.\x0a\x09super renderContentOn: html.\x0a\x09self wrapper onDblClick: [ self dive ]",
+source: "renderContentOn: html\x0a\x09self renderHeadOn: html.\x0a\x09super renderContentOn: html.\x0a\x09self wrapper onDblClick: [ self dive ].\x0a\x09\x0a\x09self bindKeys",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["renderHeadOn:", "renderContentOn:", "onDblClick:", "wrapper", "dive"]
+messageSends: ["renderHeadOn:", "renderContentOn:", "onDblClick:", "wrapper", "dive", "bindKeys"]
 }),
 $globals.HLInspectorVariablesWidget);
 

+ 21 - 1
src/Helios-Inspector.st

@@ -153,6 +153,11 @@ variables
 
 !HLInspectorVariablesWidget methodsFor: 'actions'!
 
+bindKeys
+	self wrapper asJQuery
+		keydown: [ :e | self handleKeyDown: e ]
+!
+
 dive
 	self announcer announce: HLDiveRequested new
 !
@@ -175,6 +180,19 @@ defaultItems
 
 !HLInspectorVariablesWidget methodsFor: 'reactions'!
 
+handleKeyDown: anEvent
+
+	(anEvent keyCode = 66 and: [
+	anEvent ctrlKey or: [
+	anEvent metaKey ] ]) ifTrue: [
+		(inspector model instVarObjectAt: selectedItem) browse ].
+
+	(anEvent keyCode = 73 and: [
+	anEvent ctrlKey or: [
+	anEvent metaKey ] ]) ifTrue: [
+		self dive ].
+!
+
 selectItem: anObject
 	super selectItem: anObject.
     self model selectedInstVar: anObject
@@ -192,7 +210,9 @@ renderButtonsOn: html
 renderContentOn: html
 	self renderHeadOn: html.
 	super renderContentOn: html.
-	self wrapper onDblClick: [ self dive ]
+	self wrapper onDblClick: [ self dive ].
+	
+	self bindKeys
 !
 
 renderHeadOn: html