Projekt

Obecné

Profil

Stáhnout (8.07 KB) Statistiky
| Větev: | Tag: | Revize:
1
ace.define("ace/keyboard/vscode",["require","exports","module","ace/keyboard/hash_handler","ace/config"], function(require, exports, module) {
2
"use strict";
3

    
4
var HashHandler = require("../keyboard/hash_handler").HashHandler;
5
var config = require("../config");
6

    
7
exports.handler = new HashHandler();
8
exports.handler.$id = "ace/keyboard/vscode";
9

    
10
exports.handler.addCommands([{
11
    name: "toggleWordWrap",
12
    exec: function(editor) {
13
        var wrapUsed = editor.session.getUseWrapMode();
14
        editor.session.setUseWrapMode(!wrapUsed);
15
    },
16
    readOnly: true
17
}, {
18
    name: "navigateToLastEditLocation",
19
    exec: function(editor) {
20
        var lastDelta = editor.session.getUndoManager().$lastDelta;
21
        var range = (lastDelta.action  == "remove")? lastDelta.start: lastDelta.end;
22
        editor.moveCursorTo(range.row, range.column);
23
        editor.clearSelection();
24
    }
25
}, {
26
    name: "replaceAll",
27
    exec: function (editor) {
28
        if (!editor.searchBox) {
29
            config.loadModule("ace/ext/searchbox", function(e) {
30
                e.Search(editor, true);
31
            });
32
        } else {
33
            if (editor.searchBox.active === true && editor.searchBox.replaceOption.checked === true) {
34
                editor.searchBox.replaceAll();
35
            }
36
        }
37
    }
38
}, {
39
    name: "replaceOne",
40
    exec: function (editor) {
41
        if (!editor.searchBox) {
42
            config.loadModule("ace/ext/searchbox", function(e) {
43
                e.Search(editor, true);
44
            });
45
        } else {
46
            if (editor.searchBox.active === true && editor.searchBox.replaceOption.checked === true) {
47
                editor.searchBox.replace();
48
            }
49
        }
50
    }
51
}, {
52
    name: "selectAllMatches",
53
    exec: function (editor) {
54
        if (!editor.searchBox) {
55
            config.loadModule("ace/ext/searchbox", function(e) {
56
                e.Search(editor, false);
57
            });
58
        } else {
59
            if (editor.searchBox.active === true) {
60
                editor.searchBox.findAll();
61
            }
62
        }
63
    }
64
}, {
65
    name: "toggleFindCaseSensitive",
66
    exec: function (editor) {
67
        config.loadModule("ace/ext/searchbox", function(e) {
68
            e.Search(editor, false);
69
            var sb = editor.searchBox;
70
            sb.caseSensitiveOption.checked = !sb.caseSensitiveOption.checked;
71
            sb.$syncOptions();
72
        });
73

    
74
    }
75
}, {
76
    name: "toggleFindInSelection",
77
    exec: function (editor) {
78
        config.loadModule("ace/ext/searchbox", function(e) {
79
            e.Search(editor, false);
80
            var sb = editor.searchBox;
81
            sb.searchOption.checked = !sb.searchRange;
82
            sb.setSearchRange(sb.searchOption.checked && sb.editor.getSelectionRange());
83
            sb.$syncOptions();
84
        });
85
    }
86
}, {
87
    name: "toggleFindRegex",
88
    exec: function (editor) {
89
        config.loadModule("ace/ext/searchbox", function(e) {
90
            e.Search(editor, false);
91
            var sb = editor.searchBox;
92
            sb.regExpOption.checked = !sb.regExpOption.checked;
93
            sb.$syncOptions();
94
        });
95
    }
96
}, {
97
    name: "toggleFindWholeWord",
98
    exec: function (editor) {
99
        config.loadModule("ace/ext/searchbox", function(e) {
100
            e.Search(editor, false);
101
            var sb = editor.searchBox;
102
            sb.wholeWordOption.checked = !sb.wholeWordOption.checked;
103
            sb.$syncOptions();
104
        });
105
    }
106
}, {
107
    name: "removeSecondaryCursors",
108
    exec: function (editor) {
109
        var ranges = editor.selection.ranges;
110
        if (ranges && ranges.length > 1)
111
            editor.selection.toSingleRange(ranges[ranges.length - 1]);
112
        else
113
            editor.selection.clearSelection();
114
    }
115
}]);
116

    
117

    
118
[{
119
    bindKey: {mac: "Ctrl-G", win: "Ctrl-G"},
120
    name: "gotoline"
121
}, {
122
    bindKey: {mac: "Command-Shift-L|Command-F2", win: "Ctrl-Shift-L|Ctrl-F2"},
123
    name: "findAll"
124
}, {
125
    bindKey: {mac: "Shift-F8|Shift-Option-F8", win: "Shift-F8|Shift-Alt-F8"},
126
    name: "goToPreviousError"
127
}, {
128
    bindKey: {mac: "F8|Option-F8", win: "F8|Alt-F8"},
129
    name: "goToNextError"
130
}, {
131
    bindKey: {mac: "Command-Shift-P|F1", win: "Ctrl-Shift-P|F1"},
132
    name: "openCommandPallete"
133
}, {
134
    bindKey: {mac: "Command-K|Command-S", win: "Ctrl-K|Ctrl-S"},
135
    name: "showKeyboardShortcuts"
136
}, {
137
    bindKey: {mac: "Shift-Option-Up", win: "Alt-Shift-Up"},
138
    name: "copylinesup"
139
}, {
140
    bindKey: {mac: "Shift-Option-Down", win: "Alt-Shift-Down"},
141
    name: "copylinesdown"
142
}, {
143
    bindKey: {mac: "Command-Shift-K", win: "Ctrl-Shift-K"},
144
    name: "removeline"
145
}, {
146
    bindKey: {mac: "Command-Enter", win: "Ctrl-Enter"},
147
    name: "addLineAfter"
148
}, {
149
    bindKey: {mac: "Command-Shift-Enter", win: "Ctrl-Shift-Enter"},
150
    name: "addLineBefore"
151
}, {
152
    bindKey: {mac: "Command-Shift-\\", win: "Ctrl-Shift-\\"},
153
    name: "jumptomatching"
154
}, {
155
    bindKey: {mac: "Command-]", win: "Ctrl-]"},
156
    name: "blockindent"
157
}, {
158
    bindKey: {mac: "Command-[", win: "Ctrl-["},
159
    name: "blockoutdent"
160
}, {
161
    bindKey: {mac: "Ctrl-PageDown", win: "Alt-PageDown"},
162
    name: "pagedown"
163
}, {
164
    bindKey: {mac: "Ctrl-PageUp", win: "Alt-PageUp"},
165
    name: "pageup"
166
}, {
167
    bindKey: {mac: "Shift-Option-A", win: "Shift-Alt-A"},
168
    name: "toggleBlockComment"
169
}, {
170
    bindKey: {mac: "Option-Z", win: "Alt-Z"},
171
    name: "toggleWordWrap"
172
}, {
173
    bindKey: {mac: "Command-G", win: "F3|Ctrl-K Ctrl-D"},
174
    name: "findnext"
175
}, {
176
    bindKey: {mac: "Command-Shift-G", win: "Shift-F3"},
177
    name: "findprevious"
178
}, {
179
    bindKey: {mac: "Option-Enter", win: "Alt-Enter"},
180
    name: "selectAllMatches"
181
}, {
182
    bindKey: {mac: "Command-D", win: "Ctrl-D"},
183
    name: "selectMoreAfter"
184
}, {
185
    bindKey: {mac: "Command-K Command-D", win: "Ctrl-K Ctrl-D"},
186
    name: "selectOrFindNext"
187
}, {
188
    bindKey: {mac: "Shift-Option-I", win: "Shift-Alt-I"},
189
    name: "splitSelectionIntoLines"
190
}, {
191
    bindKey: {mac: "Command-K M", win: "Ctrl-K M"},
192
    name: "modeSelect"
193
}, {
194
    bindKey: {mac: "Command-Option-[", win: "Ctrl-Shift-["},
195
    name: "toggleFoldWidget"
196
}, {
197
    bindKey: {mac: "Command-Option-]", win: "Ctrl-Shift-]"},
198
    name: "toggleFoldWidget"
199
}, {
200
    bindKey: {mac: "Command-K Command-0", win: "Ctrl-K Ctrl-0"},
201
    name: "foldall"
202
}, {
203
    bindKey: {mac: "Command-K Command-J", win: "Ctrl-K Ctrl-J"},
204
    name: "unfoldall"
205
}, {
206
    bindKey: { mac: "Command-K Command-1", win: "Ctrl-K Ctrl-1" },
207
    name: "foldOther"
208
}, {
209
    bindKey: { mac: "Command-K Command-Q", win: "Ctrl-K Ctrl-Q" },
210
    name: "navigateToLastEditLocation"
211
}, {
212
    bindKey: { mac: "Command-K Command-R|Command-K Command-S", win: "Ctrl-K Ctrl-R|Ctrl-K Ctrl-S" },
213
    name: "showKeyboardShortcuts"
214
}, {
215
    bindKey: { mac: "Command-K Command-X", win: "Ctrl-K Ctrl-X" },
216
    name: "trimTrailingSpace"
217
}, {
218
    bindKey: {mac: "Shift-Down|Command-Shift-Down", win: "Shift-Down|Ctrl-Shift-Down"},
219
    name: "selectdown"
220
}, {
221
    bindKey: {mac: "Shift-Up|Command-Shift-Up", win: "Shift-Up|Ctrl-Shift-Up"},
222
    name: "selectup"
223
}, {
224
    bindKey: {mac: "Command-Alt-Enter", win: "Ctrl-Alt-Enter"},
225
    name: "replaceAll"
226
}, {
227
    bindKey: {mac: "Command-Shift-1", win: "Ctrl-Shift-1"},
228
    name: "replaceOne"
229
}, {
230
    bindKey: {mac: "Option-C", win: "Alt-C"},
231
    name: "toggleFindCaseSensitive"
232
}, {
233
    bindKey: {mac: "Option-L", win: "Alt-L"},
234
    name: "toggleFindInSelection"
235
}, {
236
    bindKey: {mac: "Option-R", win: "Alt-R"},
237
    name: "toggleFindRegex"
238
}, {
239
    bindKey: {mac: "Option-W", win: "Alt-W"},
240
    name: "toggleFindWholeWord"
241
}, {
242
    bindKey: {mac: "Command-L", win: "Ctrl-L"},
243
    name: "expandtoline"
244
}, {
245
    bindKey: {mac: "Shift-Esc", win: "Shift-Esc"},
246
    name: "removeSecondaryCursors"
247
} 
248
].forEach(function(binding) {
249
    var command = exports.handler.commands[binding.name];
250
    if (command)
251
        command.bindKey = binding.bindKey;
252
    exports.handler.bindKey(binding.bindKey, command || binding.name);
253
});
254

    
255
});                (function() {
256
                    ace.require(["ace/keyboard/vscode"], function(m) {
257
                        if (typeof module == "object" && typeof exports == "object" && module) {
258
                            module.exports = m;
259
                        }
260
                    });
261
                })();
262
            
(26-26/244)