|
Lines 271-276
exports.setUpEditor = function(isReadOnly){
Link Here
|
| 271 |
} |
271 |
} |
| 272 |
}; |
272 |
}; |
| 273 |
|
273 |
|
|
|
274 |
var escHandler = { |
| 275 |
handlers: [], |
| 276 |
|
| 277 |
addHandler: function(handler) { |
| 278 |
this.handlers.push(handler); |
| 279 |
}, |
| 280 |
|
| 281 |
cancel: function() { |
| 282 |
var handled = false; |
| 283 |
// To be safe, we give all our handlers a chance, not just the first one. |
| 284 |
// In case the user has left multiple modal popups open (such as key assist and search) |
| 285 |
for (var i=0; i<this.handlers.length; i++) { |
| 286 |
handled = this.handlers[i].cancel() || handled; |
| 287 |
} |
| 288 |
return handled; |
| 289 |
}, |
| 290 |
|
| 291 |
isActive: function() { |
| 292 |
for (var i=0; i<this.handlers.length; i++) { |
| 293 |
if (this.handlers[i].isActive()) { |
| 294 |
return true; |
| 295 |
} |
| 296 |
} |
| 297 |
return false; |
| 298 |
}, |
| 299 |
|
| 300 |
lineUp: function() { |
| 301 |
return false; |
| 302 |
}, |
| 303 |
lineDown: function() { |
| 304 |
return false; |
| 305 |
}, |
| 306 |
enter: function() { |
| 307 |
return false; |
| 308 |
} |
| 309 |
}; |
| 310 |
|
| 274 |
var keyBindingFactory = function(editor, keyModeStack, undoStack, contentAssist) { |
311 |
var keyBindingFactory = function(editor, keyModeStack, undoStack, contentAssist) { |
| 275 |
// Register commands that depend on external services, the registry, etc. |
312 |
// Register commands that depend on external services, the registry, etc. |
| 276 |
var commandGenerator = new mEditorCommands.EditorCommandFactory(serviceRegistry, commandService, fileClient, inputManager, "pageActions", isReadOnly); |
313 |
var commandGenerator = new mEditorCommands.EditorCommandFactory(serviceRegistry, commandService, fileClient, inputManager, "pageActions", isReadOnly); |
|
Lines 285-290
exports.setUpEditor = function(isReadOnly){
Link Here
|
| 285 |
var codeBindings = new mEditorFeatures.SourceCodeActions(editor, undoStack, contentAssist); |
322 |
var codeBindings = new mEditorFeatures.SourceCodeActions(editor, undoStack, contentAssist); |
| 286 |
keyModeStack.push(codeBindings); |
323 |
keyModeStack.push(codeBindings); |
| 287 |
|
324 |
|
|
|
325 |
// give our external escape handler a shot at handling escape |
| 326 |
keyModeStack.push(escHandler); |
| 327 |
|
| 288 |
// global search |
328 |
// global search |
| 289 |
editor.getTextView().setKeyBinding(new mKeyBinding.KeyBinding("h", true), "Search Files"); |
329 |
editor.getTextView().setKeyBinding(new mKeyBinding.KeyBinding("h", true), "Search Files"); |
| 290 |
editor.getTextView().setAction("Search Files", function() { |
330 |
editor.getTextView().setAction("Search Files", function() { |
|
Lines 299-307
exports.setUpEditor = function(isReadOnly){
Link Here
|
| 299 |
} if (!searchPattern) { |
339 |
} if (!searchPattern) { |
| 300 |
return; |
340 |
return; |
| 301 |
} |
341 |
} |
| 302 |
searchFloat.onclick = function() { |
342 |
dojo.connect(document, "onkeypress", dojo.hitch(this, function (e){ |
| 303 |
searchFloat.style.display = "none"; |
343 |
if (e.charOrCode === dojo.keys.ESCAPE) { |
|
|
344 |
searchFloat.style.display = "none"; |
| 345 |
} |
| 346 |
})); |
| 347 |
|
| 348 |
var searchFloatEscHandler = { |
| 349 |
isActive: function() { |
| 350 |
return searchFloat.style.display === "block"; |
| 351 |
}, |
| 352 |
|
| 353 |
cancel: function() { |
| 354 |
if (this.isActive()) { |
| 355 |
searchFloat.style.display = "none"; |
| 356 |
return true; |
| 357 |
} |
| 358 |
return false; // not handled |
| 359 |
} |
| 304 |
}; |
360 |
}; |
|
|
361 |
escHandler.addHandler(searchFloatEscHandler); |
| 362 |
|
| 305 |
// TEMPORARY until we can better scope the search |
363 |
// TEMPORARY until we can better scope the search |
| 306 |
var extensionFilter = ""; |
364 |
var extensionFilter = ""; |
| 307 |
var fileName = inputManager.getTitle(); |
365 |
var fileName = inputManager.getTitle(); |
|
Lines 382-388
exports.setUpEditor = function(isReadOnly){
Link Here
|
| 382 |
inputManager.setInput(dojo.hash(), editor); |
440 |
inputManager.setInput(dojo.hash(), editor); |
| 383 |
|
441 |
|
| 384 |
// TODO search location needs to be gotten from somewhere |
442 |
// TODO search location needs to be gotten from somewhere |
| 385 |
mGlobalCommands.generateBanner("toolbar", serviceRegistry, commandService, prefsService, searcher, editor, editor); |
443 |
mGlobalCommands.generateBanner("toolbar", serviceRegistry, commandService, prefsService, searcher, editor, editor, escHandler); |
| 386 |
mGlobalCommands.generateDomCommandsInBanner(commandService, editor); |
444 |
mGlobalCommands.generateDomCommandsInBanner(commandService, editor); |
| 387 |
|
445 |
|
| 388 |
var syntaxChecker = new mSyntaxchecker.SyntaxChecker(serviceRegistry, editor); |
446 |
var syntaxChecker = new mSyntaxchecker.SyntaxChecker(serviceRegistry, editor); |