Browse Source

First draft of a source code widget

Nicolas Petton 11 years ago
parent
commit
a2f96da353
3 changed files with 103 additions and 0 deletions
  1. 37 0
      js/Helios-Workspace.deploy.js
  2. 47 0
      js/Helios-Workspace.js
  3. 19 0
      st/Helios-Workspace.st

+ 37 - 0
js/Helios-Workspace.deploy.js

@@ -539,6 +539,43 @@ smalltalk.HLCodeWidget);
 
 
 
+smalltalk.addClass('HLSourceCodeWidget', smalltalk.HLCodeWidget, [], 'Helios-Workspace');
+smalltalk.addMethod(
+"_onKeyDown_",
+smalltalk.method({
+selector: "onKeyDown:",
+fn: function (anEvent){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1,$2,$3;
+$1=smalltalk.HLCodeWidget.fn.prototype._onKeyDown_.apply(_st(self), [anEvent]);
+if(! smalltalk.assert($1)){
+return false;
+};
+$2=_st(anEvent)._ctrlKey();
+if(smalltalk.assert($2)){
+$3=_st(_st(anEvent)._keyCode()).__eq((83));
+if(smalltalk.assert($3)){
+_st(self)._onSave();
+_st(anEvent)._preventDefault();
+return false;
+};
+};
+return self}, function($ctx1) {$ctx1.fill(self,"onKeyDown:",{anEvent:anEvent}, smalltalk.HLSourceCodeWidget)})},
+messageSends: ["ifFalse:", "onKeyDown:", "ifTrue:", "onSave", "preventDefault", "=", "keyCode", "ctrlKey"]}),
+smalltalk.HLSourceCodeWidget);
+
+smalltalk.addMethod(
+"_onSave",
+smalltalk.method({
+selector: "onSave",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return self}, function($ctx1) {$ctx1.fill(self,"onSave",{}, smalltalk.HLSourceCodeWidget)})},
+messageSends: []}),
+smalltalk.HLSourceCodeWidget);
+
+
+
 smalltalk.addClass('HLWorkspace', smalltalk.HLWidget, ['model', 'codeWidget'], 'Helios-Workspace');
 smalltalk.addMethod(
 "_codeWidget",

+ 47 - 0
js/Helios-Workspace.js

@@ -729,6 +729,53 @@ smalltalk.HLCodeWidget);
 
 
 
+smalltalk.addClass('HLSourceCodeWidget', smalltalk.HLCodeWidget, [], 'Helios-Workspace');
+smalltalk.addMethod(
+"_onKeyDown_",
+smalltalk.method({
+selector: "onKeyDown:",
+category: 'reactions',
+fn: function (anEvent){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1,$2,$3;
+$1=smalltalk.HLCodeWidget.fn.prototype._onKeyDown_.apply(_st(self), [anEvent]);
+if(! smalltalk.assert($1)){
+return false;
+};
+$2=_st(anEvent)._ctrlKey();
+if(smalltalk.assert($2)){
+$3=_st(_st(anEvent)._keyCode()).__eq((83));
+if(smalltalk.assert($3)){
+_st(self)._onSave();
+_st(anEvent)._preventDefault();
+return false;
+};
+};
+return self}, function($ctx1) {$ctx1.fill(self,"onKeyDown:",{anEvent:anEvent}, smalltalk.HLSourceCodeWidget)})},
+args: ["anEvent"],
+source: "onKeyDown: anEvent\x0a\x09(super onKeyDown: anEvent) ifFalse: [ ^ false ].\x0a    \x0a\x09anEvent ctrlKey ifTrue: [\x0a\x09\x09anEvent keyCode = 83 ifTrue: [\x0a\x09\x09\x09self onSave.\x0a\x09\x09\x09anEvent preventDefault.\x0a\x09\x09\x09^ false ] ]",
+messageSends: ["ifFalse:", "onKeyDown:", "ifTrue:", "onSave", "preventDefault", "=", "keyCode", "ctrlKey"],
+referencedClasses: []
+}),
+smalltalk.HLSourceCodeWidget);
+
+smalltalk.addMethod(
+"_onSave",
+smalltalk.method({
+selector: "onSave",
+category: 'reactions',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return self}, function($ctx1) {$ctx1.fill(self,"onSave",{}, smalltalk.HLSourceCodeWidget)})},
+args: [],
+source: "onSave",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.HLSourceCodeWidget);
+
+
+
 smalltalk.addClass('HLWorkspace', smalltalk.HLWidget, ['model', 'codeWidget'], 'Helios-Workspace');
 smalltalk.addMethod(
 "_codeWidget",

+ 19 - 0
st/Helios-Workspace.st

@@ -244,6 +244,25 @@ renderContentOn: html
     self observeWrapper
 ! !
 
+HLCodeWidget subclass: #HLSourceCodeWidget
+	instanceVariableNames: ''
+	package: 'Helios-Workspace'!
+
+!HLSourceCodeWidget methodsFor: 'reactions'!
+
+onKeyDown: anEvent
+	(super onKeyDown: anEvent) ifFalse: [ ^ false ].
+    
+	anEvent ctrlKey ifTrue: [
+		anEvent keyCode = 83 ifTrue: [
+			self onSave.
+			anEvent preventDefault.
+			^ false ] ]
+!
+
+onSave
+! !
+
 HLWidget subclass: #HLWorkspace
 	instanceVariableNames: 'model codeWidget'
 	package: 'Helios-Workspace'!