diff --git a/keymaps/learn-ide.cson b/keymaps/learn-ide.cson index b4bbc32..35f26bd 100644 --- a/keymaps/learn-ide.cson +++ b/keymaps/learn-ide.cson @@ -1,6 +1,7 @@ '.platform-darwin': - 'cmd-I': 'learn-ide:toggle-terminal' + 'cmd-i': 'learn-ide:toggle-terminal' 'cmd-;': 'learn-ide:toggle-focus' + 'cmd-I': 'learn-ide:toggle-popout' '.platform-win32, .platform-linux': 'ctrl-I': 'learn-ide:toggle-terminal' diff --git a/lib/colors.coffee b/lib/colors.coffee index b5fa3bc..72a5af4 100644 --- a/lib/colors.coffee +++ b/lib/colors.coffee @@ -38,6 +38,7 @@ helper = css = """ .terminal { color: #{foreground.toRGBAString()}; + background-color: #{background.toRGBAString()}; } .terminal .xterm-viewport { diff --git a/lib/event-bus.js b/lib/event-bus.js index 8fd5f56..bff3d25 100644 --- a/lib/event-bus.js +++ b/lib/event-bus.js @@ -1,6 +1,6 @@ var pageBus = require('page-bus'); -module.exports = (function() { +module.exports = bus = (function() { return pageBus({key: 'learn-ide'}) })() diff --git a/lib/learn-ide.coffee b/lib/learn-ide.coffee index c23e10b..0737d65 100644 --- a/lib/learn-ide.coffee +++ b/lib/learn-ide.coffee @@ -93,6 +93,7 @@ module.exports = @subscriptions.add atom.commands.add 'atom-workspace', 'learn-ide:open': (e) => @learnOpen(e.detail.path) 'learn-ide:toggle-terminal': () => @termView.toggle() + 'learn-ide:toggle-popout': () => @termView.popout() 'learn-ide:toggle-focus': => @termView.toggleFocus() 'learn-ide:focus': => @termView.focusEmulator() 'learn-ide:toggle:debugger': => @term.toggleDebugger() diff --git a/lib/local-storage.js b/lib/local-storage.js index eaf46c9..c04360b 100644 --- a/lib/local-storage.js +++ b/lib/local-storage.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = local = { get(key) { return localStorage.getItem(key) }, diff --git a/lib/terminal-view.coffee b/lib/terminal-view.coffee index fe7fb55..c51506b 100644 --- a/lib/terminal-view.coffee +++ b/lib/terminal-view.coffee @@ -1,7 +1,13 @@ {$, View} = require 'atom-space-pen-views' {clipboard} = require 'electron' +{BrowserWindow} = require 'remote' TerminalEmulator = require 'xterm' TerminalEmulator.loadAddon 'fit' +path = require 'path' +bus = require './event-bus' +localStorage = require './local-storage' + +POPOUT_WINDOW = path.resolve( __dirname, '..', 'static', 'popout-terminal.html') module.exports = class TerminalView extends View @@ -24,6 +30,8 @@ class TerminalView extends View @terminal.on 'message', (msg) => @emulator.write(msg) + if @popoutPresent + bus.emit('popout-terminal:message', msg) @on 'mousedown', '.terminal-resize-handle', (e) => @resizeByDragStarted(e) @@ -55,6 +63,24 @@ class TerminalView extends View atom.workspace.addBottomPanel({item: this}) @emulator.open(@emulatorContainer[0]) + popout: -> + @hide() + @popoutPresent = true + + win = new BrowserWindow() + win.loadURL("file://#{POPOUT_WINDOW}") + win.once 'ready-to-show', => win.show() + win.openDevTools() + win.on 'closed', => + @show() + @popoutPresent = false + + bus.on 'popout-terminal:data', (data) => + if not event? + @terminal.send(data) + else + @parseTerminalDataEvent(event, data) + copyText: -> selection = document.getSelection() rawText = selection.toString() diff --git a/static/popout-terminal.html b/static/popout-terminal.html new file mode 100644 index 0000000..b80b848 --- /dev/null +++ b/static/popout-terminal.html @@ -0,0 +1,36 @@ + + +
+ + + + + + + + + + + + + + + + +