mirror of
https://github.com/atom/atom.git
synced 2026-02-06 20:55:33 -05:00
Add core URI handlers
This commit is contained in:
@@ -32,6 +32,7 @@ ThemeManager = require './theme-manager'
|
||||
MenuManager = require './menu-manager'
|
||||
ContextMenuManager = require './context-menu-manager'
|
||||
CommandInstaller = require './command-installer'
|
||||
CoreURIHandlers = require './core-uri-handlers'
|
||||
ProtocolHandlerInstaller = require './protocol-handler-installer'
|
||||
Project = require './project'
|
||||
TitleBar = require './title-bar'
|
||||
@@ -238,6 +239,7 @@ class AtomEnvironment extends Model
|
||||
|
||||
@commandInstaller.initialize(@getVersion())
|
||||
@protocolHandlerInstaller.initialize(@config, @notifications)
|
||||
@uriHandlerRegistry.registerHostHandler('core', CoreURIHandlers.create(@))
|
||||
@autoUpdater.initialize()
|
||||
|
||||
@config.load()
|
||||
|
||||
24
src/core-uri-handlers.js
Normal file
24
src/core-uri-handlers.js
Normal file
@@ -0,0 +1,24 @@
|
||||
function openFile (atom, {query}) {
|
||||
const {filename, line, column} = query
|
||||
|
||||
atom.workspace.open(filename, {
|
||||
initialLine: parseInt(line || 0, 10),
|
||||
initialColumn: parseInt(column || 0, 10),
|
||||
searchAllPanes: true
|
||||
})
|
||||
}
|
||||
|
||||
const ROUTER = {
|
||||
'/open/file': openFile
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
create (atomEnv) {
|
||||
return function coreURIHandler (parsed) {
|
||||
const handler = ROUTER[parsed.pathname]
|
||||
if (handler) {
|
||||
handler(atomEnv, parsed)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user