aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/code-editor/code-editor-wrapper.js (renamed from js/controllers/code-editor-controller.js)34
-rw-r--r--js/code-editor/codemirror-ninja/lib/ninja-simple-hint.js4
-rw-r--r--js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html10
-rw-r--r--js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js61
-rwxr-xr-xjs/document/views/code.js2
-rwxr-xr-xjs/ninja.reel/ninja.html9
-rwxr-xr-xjs/ninja.reel/ninja.js2
7 files changed, 80 insertions, 42 deletions
diff --git a/js/controllers/code-editor-controller.js b/js/code-editor/code-editor-wrapper.js
index f3c19b92..942bd5cd 100644
--- a/js/controllers/code-editor-controller.js
+++ b/js/code-editor/code-editor-wrapper.js
@@ -9,7 +9,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
9var Montage = require("montage/core/core").Montage, 9var Montage = require("montage/core/core").Montage,
10 Component = require("montage/ui/component").Component; 10 Component = require("montage/ui/component").Component;
11 11
12exports.CodeEditorController = Montage.create(Component, { 12exports.CodeEditorWrapper = Montage.create(Component, {
13 hasTemplate: { 13 hasTemplate: {
14 value: false 14 value: false
15 }, 15 },
@@ -32,8 +32,9 @@ exports.CodeEditorController = Montage.create(Component, {
32 if(!value) { 32 if(!value) {
33 33
34 } else if(this._currentDocument.currentView === "code") { 34 } else if(this._currentDocument.currentView === "code") {
35 this.autocomplete = !this.codeCompletionSupport[this._currentDocument.model.file.extension]; 35 this.autocomplete = this.codeCompletionSupport[this._currentDocument.model.file.extension];
36 this._currentDocument.model.views.code.editor.focus(); 36 this._currentDocument.model.views.code.editor.focus();
37
37 this.applySettings(); 38 this.applySettings();
38 } 39 }
39 } 40 }
@@ -56,21 +57,6 @@ exports.CodeEditorController = Montage.create(Component, {
56 value: false 57 value: false
57 }, 58 },
58 59
59 _automaticCodeComplete: {
60 value:false
61 },
62
63 automaticCodeComplete:{
64 get: function(){
65 return this._automaticCodeComplete;
66 },
67 set: function(value) {
68 if(this._automaticCodeComplete !== value) {
69 this._automaticCodeComplete = value;
70 }
71 }
72 },
73
74 _editorTheme: { 60 _editorTheme: {
75 value:"default" 61 value:"default"
76 }, 62 },
@@ -93,7 +79,10 @@ exports.CodeEditorController = Montage.create(Component, {
93 return this._zoomFactor; 79 return this._zoomFactor;
94 }, 80 },
95 set: function(value) { 81 set: function(value) {
96 this.handleZoom(value); 82 if(value !== this._zoomFactor){
83 this._zoomFactor = value;
84 this.handleZoom(value);
85 }
97 } 86 }
98 }, 87 },
99 88
@@ -112,6 +101,10 @@ exports.CodeEditorController = Montage.create(Component, {
112 value:function(codeDocumentView, type, documentType, textDocument){ 101 value:function(codeDocumentView, type, documentType, textDocument){
113 var self = this, editorOptions = null; 102 var self = this, editorOptions = null;
114 103
104 if(!this.application.ninja.editorViewOptions.codeEditorWrapper){
105 this.application.ninja.editorViewOptions.codeEditorWrapper = this;
106 }
107
115 editorOptions = { 108 editorOptions = {
116 lineNumbers: true, 109 lineNumbers: true,
117 matchBrackets:true, 110 matchBrackets:true,
@@ -132,6 +125,9 @@ exports.CodeEditorController = Montage.create(Component, {
132 }; 125 };
133 126
134 //configure auto code completion if it is supported for that document type 127 //configure auto code completion if it is supported for that document type
128
129 this.autocomplete = this.codeCompletionSupport[documentType];
130
135 if(this.autocomplete) { 131 if(this.autocomplete) {
136 132
137 editorOptions.onKeyEvent = function(cm, keyEvent){ 133 editorOptions.onKeyEvent = function(cm, keyEvent){
@@ -163,7 +159,7 @@ exports.CodeEditorController = Montage.create(Component, {
163 } 159 }
164 160
165 //===manually triggered code completion 161 //===manually triggered code completion
166 if((this.automaticCodeComplete === false)){ 162 if((this.currentDocument.model.views.code.editor.automaticCodeHint === false)){
167 if(keyEvent.ctrlKey && keyEvent.keyCode === 32){//Ctrl+Space 163 if(keyEvent.ctrlKey && keyEvent.keyCode === 32){//Ctrl+Space
168 this.codeEditor.simpleHint(cm, this.codeEditor.javascriptHint); 164 this.codeEditor.simpleHint(cm, this.codeEditor.javascriptHint);
169 } 165 }
diff --git a/js/code-editor/codemirror-ninja/lib/ninja-simple-hint.js b/js/code-editor/codemirror-ninja/lib/ninja-simple-hint.js
index 4787b4f8..adcafd41 100644
--- a/js/code-editor/codemirror-ninja/lib/ninja-simple-hint.js
+++ b/js/code-editor/codemirror-ninja/lib/ninja-simple-hint.js
@@ -22,8 +22,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
22 function insert(str) { 22 function insert(str) {
23 editor.replaceRange(str, result.from, result.to); 23 editor.replaceRange(str, result.from, result.to);
24 } 24 }
25 // Ninja override: don't autocomplete to reduce user's typing errors 25
26// if (completions.length == 1) {insert(completions[0]); return true;} 26 if (completions.length == 1) {insert(completions[0]); return true;}
27 27
28 // Build the select widget 28 // Build the select widget
29 var complete = document.createElement("div"); 29 var complete = document.createElement("div");
diff --git a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html
index 4448e1f1..9871525b 100644
--- a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html
+++ b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html
@@ -11,12 +11,13 @@
11 <script type="text/montage-serialization"> 11 <script type="text/montage-serialization">
12 { 12 {
13 "codeCompleteCheck":{ 13 "codeCompleteCheck":{
14 "prototype": "montage/ui/input-checkbox.reel", 14 "prototype": "montage/ui/native/input-checkbox.reel",
15 "properties": { 15 "properties": {
16 "element": {"#": "codeComplete"} 16 "element": {"#": "codeComplete"}
17 }, 17 },
18 "bindings": { 18 "bindings": {
19 "disabled": {"<-": "@owner.autocomplete"} 19 "disabled": {"<-": "@owner.autocomplete"},
20 "checked": {"<->": "@owner.automaticCodeHint"}
20 } 21 }
21 }, 22 },
22 23
@@ -29,6 +30,9 @@
29 "stepSize" :10, 30 "stepSize" :10,
30 "acceptableUnits" : ["%"], 31 "acceptableUnits" : ["%"],
31 "units" : "%" 32 "units" : "%"
33 },
34 "bindings": {
35 "value": {"<->": "@owner.zoomFactor"}
32 } 36 }
33 }, 37 },
34 38
@@ -54,7 +58,7 @@
54 <input class="zoomFont" data-montage-id="zoomFont"/> 58 <input class="zoomFont" data-montage-id="zoomFont"/>
55 <div class="autoCodeComplete" > 59 <div class="autoCodeComplete" >
56 <input type="checkbox" data-montage-id="codeComplete" /> 60 <input type="checkbox" data-montage-id="codeComplete" />
57 <label data-montage-id="autoCompleteLabel">Automatic Completion</label> 61 <label data-montage-id="autoCompleteLabel">Auto Code Hints</label>
58 </div> 62 </div>
59 <div class="floatButtons"> 63 <div class="floatButtons">
60 <!--<button disabled="disabled" id="format" value="format" class="nj-skinned format">Format</button>--> 64 <!--<button disabled="disabled" id="format" value="format" class="nj-skinned format">Format</button>-->
diff --git a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js
index 13c9a705..6c983867 100644
--- a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js
+++ b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js
@@ -36,6 +36,21 @@ exports.CodeEditorViewOptions = Montage.create(Component, {
36 } 36 }
37 }, 37 },
38 38
39 _codeEditorWrapper:{
40 value: null
41 },
42
43 codeEditorWrapper:{
44 get : function() {
45 return this._codeEditorWrapper;
46 },
47 set : function(value) {
48 if(this._codeEditorWrapper !== value){
49 this._codeEditorWrapper = value;
50 }
51 }
52 },
53
39 _visible: { 54 _visible: {
40 value: false 55 value: false
41 }, 56 },
@@ -97,6 +112,35 @@ exports.CodeEditorViewOptions = Montage.create(Component, {
97 serializable: true 112 serializable: true
98 }, 113 },
99 114
115 _zoomFactor:{
116 value: 100
117 },
118
119 zoomFactor:{
120 get: function(){
121