mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-17 22:18:41 -09:00
Fix decorated config with default colors (#2242)
Fix decorated config with default colors
This commit is contained in:
parent
cc2ff06318
commit
c02c2526ac
4 changed files with 27 additions and 7 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const notify = require('./notify');
|
const notify = require('./notify');
|
||||||
const _import = require('./config/import');
|
const {_import, getDefaultConfig} = require('./config/import');
|
||||||
const _openConfig = require('./config/open');
|
const _openConfig = require('./config/open');
|
||||||
const win = require('./config/windows');
|
const win = require('./config/windows');
|
||||||
const {cfgPath, cfgDir} = require('./config/paths');
|
const {cfgPath, cfgDir} = require('./config/paths');
|
||||||
|
|
@ -112,6 +112,13 @@ const checkDeprecatedConfig = function() {
|
||||||
notify('Configuration warning', `Your configuration uses some deprecated CSS classes (${deprecatedStr})`);
|
notify('Configuration warning', `Your configuration uses some deprecated CSS classes (${deprecatedStr})`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.fixConfigDefaults = decoratedConfig => {
|
||||||
|
const defaultConfig = getDefaultConfig().config;
|
||||||
|
// We must have default colors for xterm css.
|
||||||
|
decoratedConfig.colors = Object.assign({}, defaultConfig.colors, decoratedConfig.colors);
|
||||||
|
return decoratedConfig;
|
||||||
|
};
|
||||||
|
|
||||||
exports.htermConfigTranslate = config => {
|
exports.htermConfigTranslate = config => {
|
||||||
const cssReplacements = {
|
const cssReplacements = {
|
||||||
'x-screen x-row([ {.[])': '.xterm-rows > div$1',
|
'x-screen x-row([ {.[])': '.xterm-rows > div$1',
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
const {writeFileSync, readFileSync} = require('fs');
|
const {writeFileSync, readFileSync} = require('fs');
|
||||||
const {sync: mkdirpSync} = require('mkdirp');
|
const {sync: mkdirpSync} = require('mkdirp');
|
||||||
const {defaultCfg, cfgPath, plugs} = require('./paths');
|
const {defaultCfg, cfgPath, plugs} = require('./paths');
|
||||||
const _init = require('./init');
|
const {_init, _extractDefault} = require('./init');
|
||||||
const _keymaps = require('./keymaps');
|
const _keymaps = require('./keymaps');
|
||||||
|
|
||||||
|
let defaultConfig;
|
||||||
|
|
||||||
const _write = function(path, data) {
|
const _write = function(path, data) {
|
||||||
// This method will take text formatted as Unix line endings and transform it
|
// This method will take text formatted as Unix line endings and transform it
|
||||||
// to text formatted with DOS line endings. We do this because the default
|
// to text formatted with DOS line endings. We do this because the default
|
||||||
|
|
@ -35,8 +37,10 @@ const _importConf = function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const _import = function() {
|
exports._import = () => {
|
||||||
const cfg = _init(_importConf());
|
const imported = _importConf();
|
||||||
|
defaultConfig = _extractDefault(imported.defaultCfg);
|
||||||
|
const cfg = _init(imported);
|
||||||
|
|
||||||
if (cfg) {
|
if (cfg) {
|
||||||
cfg.keymaps = _keymaps.import(cfg.keymaps);
|
cfg.keymaps = _keymaps.import(cfg.keymaps);
|
||||||
|
|
@ -44,4 +48,9 @@ const _import = function() {
|
||||||
return cfg;
|
return cfg;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = _import;
|
exports.getDefaultConfig = () => {
|
||||||
|
if (!defaultConfig) {
|
||||||
|
defaultConfig = _extractDefault(_importConf().defaultCfg);
|
||||||
|
}
|
||||||
|
return defaultConfig;
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -45,4 +45,7 @@ const _init = function(cfg) {
|
||||||
return _extractDefault(cfg.defaultCfg);
|
return _extractDefault(cfg.defaultCfg);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = _init;
|
module.exports = {
|
||||||
|
_init,
|
||||||
|
_extractDefault
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -354,7 +354,8 @@ exports.getDecoratedEnv = baseEnv => {
|
||||||
exports.getDecoratedConfig = () => {
|
exports.getDecoratedConfig = () => {
|
||||||
const baseConfig = config.getConfig();
|
const baseConfig = config.getConfig();
|
||||||
const decoratedConfig = decorateObject(baseConfig, 'decorateConfig');
|
const decoratedConfig = decorateObject(baseConfig, 'decorateConfig');
|
||||||
const translatedConfig = config.htermConfigTranslate(decoratedConfig);
|
const fixedConfig = config.fixConfigDefaults(decoratedConfig);
|
||||||
|
const translatedConfig = config.htermConfigTranslate(fixedConfig);
|
||||||
return translatedConfig;
|
return translatedConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue