Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Add fully configurable color scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
notnotdrew committed Mar 27, 2017
1 parent 0f298e4 commit b90bb73
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules
.env
build/*
!build/.gitkeep
styles/terminal-colors.css
4 changes: 4 additions & 0 deletions lib/atom-helper.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ module.exports =
atom.packages.activatePackage(packageName()).then ->
atom.menu.sortPackagesMenu()

reloadStylesheets: ->
pkg = atom.packages.getActivePackage(packageName())
pkg.reloadStylesheets()

41 changes: 41 additions & 0 deletions lib/colors.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
fs = require 'fs'
path = require 'path'
atomHelper = require './atom-helper'
{name} = require '../package.json'

module.exports = setTerminalColors = ->
# TODO: handle legacy config keys
text = atom.config.get("#{name}.basicColors.text")
background = atom.config.get("#{name}.basicColors.background")

css = """
.terminal {
color: #{text.toRGBAString()};
}
.terminal .xterm-viewport {
background-color: #{background.toRGBAString()};
}\n
"""

for n in [0..15]
color = atom.config.get("#{name}.ansiColors.ansiColor#{n}")
rgba = color.toRGBAString()

css += """
\n.terminal .xterm-color-#{n} {
color: #{rgba};
}
.terminal .xterm-bg-color-#{n} {
background-color: #{rgba};
}\n
"""

file = path.join(__dirname, '..', 'styles', 'terminal-colors.css')
fs.writeFile file, css, (err) ->
if err?
console.warn 'unable to write colors:', err

atomHelper.reloadStylesheets()

10 changes: 6 additions & 4 deletions lib/learn-ide.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ config = require './config'
updater = require './updater'
version = require './version'
{name} = require '../package.json'
setTerminalColors = require './colors'

ABOUT_URL = 'https://help.learn.co/hc/en-us/categories/204144547-The-Learn-IDE'

Expand All @@ -25,6 +26,7 @@ module.exports =
@checkForV1WindowsInstall()
@registerWindowsProtocol()
@disableFormerPackage()
setTerminalColors()

@subscriptions = new CompositeDisposable
@subscribeToLogin()
Expand Down Expand Up @@ -107,11 +109,11 @@ module.exports =
'learn-ide:decrease-font-size': => @termView.decreaseFontSize()
'learn-ide:clear-terminal': => @term.send(' ')

atom.config.onDidChange "#{name}.terminalFontColor", ({newValue}) =>
@termView.updateFontColor(newValue)
atom.config.onDidChange "#{name}.basicColors", =>
setTerminalColors()

atom.config.onDidChange "#{name}.terminalBackgroundColor", ({newValue}) =>
@termView.updateBackgroundColor(newValue)
atom.config.onDidChange "#{name}.ansiColors", =>
setTerminalColors()

atom.config.onDidChange "#{name}.notifier", ({newValue}) =>
if newValue then @activateNotifier() else @notifier.deactivate()
Expand Down
151 changes: 131 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,6 @@
"learn-ide-material-ui": "1.3.14",
"learn-ide-tree": "1.0.22"
},
"configSchema": {
"notifier": {
"type": "boolean",
"default": true,
"title": "Learn Status Notifications",
"description": "Receive desktop notifications that correspond to the lights on Learn.co"
},
"terminalFontColor": {
"type": "color",
"default": "#ffffff",
"title": "Terminal Font Color",
"description": "A valid CSS color value which will be used to style your terminal's font"
},
"terminalBackgroundColor": {
"type": "color",
"default": "#1A2226",
"title": "Terminal Background Color",
"description": "A valid CSS color value which will be used to style your terminal's background"
}
},
"devDependencies": {
"decompress": "4.0.0",
"del": "2.2.2",
Expand All @@ -67,5 +47,136 @@
"run-sequence": "1.2.2",
"shelljs": "0.7.3",
"ssh2": "0.5.0"
},
"configSchema": {
"notifier": {
"order": 0,
"type": "boolean",
"default": true,
"title": "Learn Status Notifications",
"description": "Receive desktop notifications that correspond to the lights on Learn.co"
},
"basicColors": {
"order": 1,
"title": "Terminal: Basic Colors",
"type": "object",
"properties": {
"text": {
"order": 0,
"type": "color",
"default": "#ffffff",
"title": "Text"
},
"background": {
"order": 1,
"type": "color",
"default": "#1A2226",
"title": "Background"
}
}
},
"ansiColors": {
"order": 2,
"title": "Terminal: ANSI Colors",
"type": "object",
"properties": {
"ansiColor0": {
"order": 0,
"type": "color",
"default": "#2e3436",
"title": "Black"
},
"ansiColor1": {
"order": 1,
"type": "color",
"default": "#cc0000",
"title": "Red"
},
"ansiColor2": {
"order": 2,
"type": "color",
"default": "#4e9a06",
"title": "Green"
},
"ansiColor3": {
"order": 3,
"type": "color",
"default": "#c4a000",
"title": "Yellow"
},
"ansiColor4": {
"order": 4,
"type": "color",
"default": "#3465a4",
"title": "Blue"
},
"ansiColor5": {
"order": 5,
"type": "color",
"default": "#75507b",
"title": "Magenta"
},
"ansiColor6": {
"order": 6,
"type": "color",
"default": "#06989a",
"title": "Cyan"
},
"ansiColor7": {
"order": 7,
"type": "color",
"default": "#d3d7cf",
"title": "White"
},
"ansiColor8": {
"order": 8,
"type": "color",
"default": "#555753",
"title": "Bright Black"
},
"ansiColor9": {
"order": 9,
"type": "color",
"default": "#ef2929",
"title": "Bright Red"
},
"ansiColor10": {
"order": 10,
"type": "color",
"default": "#8ae234",
"title": "Bright Green"
},
"ansiColor11": {
"order": 11,
"type": "color",
"default": "#fce94f",
"title": "Bright Yellow"
},
"ansiColor12": {
"order": 12,
"type": "color",
"default": "#729fcf",
"title": "Bright Blue"
},
"ansiColor13": {
"order": 13,
"type": "color",
"default": "#ad7fa8",
"title": "Bright Magenta"
},
"ansiColor14": {
"order": 14,
"type": "color",
"default": "#34e2e2",
"title": "Bright Cyan"
},
"ansiColor15": {
"order": 15,
"type": "color",
"default": "#eeeeec",
"title": "Bright White"
}
}
}
}
}

0 comments on commit b90bb73

Please sign in to comment.