forked from c9/cloud9
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquickwatch.js
More file actions
119 lines (100 loc) · 3.08 KB
/
Copy pathquickwatch.js
File metadata and controls
119 lines (100 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/**
* quickwatch Module for the Cloud9 IDE
*
* @copyright 2010, Ajax.org B.V.
* @license GPLv3 <http://www.gnu.org/licenses/gpl.txt>
*/
define(function(require, exports, module) {
var ide = require("core/ide");
var ext = require("core/ext");
var editors = require("ext/editors/editors");
var noderunner = require("ext/noderunner/noderunner");
var markup = require("text!ext/quickwatch/quickwatch.xml");
return ext.register("ext/quickwatch/quickwatch", {
name : "quickwatch",
dev : "Ajax.org",
type : ext.GENERAL,
alone : true,
markup : markup,
deps : [noderunner],
commands : {
"quickwatch": {hint: "quickly inspect the variable that is under the cursor"}
},
hotitems: {},
nodes : [],
hook : function(){
},
init : function(amlNode){
txtCurObject.addEventListener("keydown", function(e){
if (e.keyCode == 13) {
if (!this.value.trim())
return dgWatch.clear();
require("ext/console/console").evaluate(this.value);
}
else if (e.keyCode == 40 && dgWatch.length) {
var first = dgWatch.getFirstTraverseNode();
if (first) {
dgWatch.select(first);
dgWatch.focus();
}
}
});
var restricted = [38, 40, 36, 35];
dgWatch.addEventListener("keydown", function(e) {
if (e.keyCode == 38) {
if (this.selected == this.getFirstTraverseNode())
txtCurObject.focus();
}
else if (restricted.indexOf(e.keyCode) == -1) {
txtCurObject.focus();
}
}, true);
},
toggleDialog: function(force, exec) {
ext.initExtension(this);
if (!winQuickWatch.visible || force == 1) {
var editor = editors.currentEditor;
var range;
var sel = editor.getSelection();
var doc = editor.getDocument();
if (sel.isEmpty()) {
var cursor = sel.getCursor();
range = doc.getWordRange(cursor.row, cursor.column);
}
else
range = sel.getRange();
var value = doc.getTextRange(range);
if (value) {
txtCurObject.setValue(value);
if (exec) {
require("ext/console/console").evaluate(value);
txtCurObject.focus();
}
}
winQuickWatch.show();
}
else
winQuickWatch.hide();
return false;
},
quickwatch : function(){
this.toggleDialog(1, true);
},
enable : function(){
this.nodes.each(function(item){
item.enable();
});
},
disable : function(){
this.nodes.each(function(item){
item.disable();
});
},
destroy : function(){
this.nodes.each(function(item){
item.destroy(true, true);
});
this.nodes = [];
}
});
});