diff options
Diffstat (limited to 'src/shared/Settings.ts')
-rw-r--r-- | src/shared/Settings.ts | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/shared/Settings.ts b/src/shared/Settings.ts index d338e2a..3014abc 100644 --- a/src/shared/Settings.ts +++ b/src/shared/Settings.ts @@ -1,7 +1,5 @@ -import * as operations from './operations'; import * as PropertyDefs from './property-defs'; - -export type Keymaps = {[key: string]: operations.Operation}; +import Keymaps from './settings/Keymaps'; export interface Search { default: string; @@ -21,14 +19,6 @@ export default interface Settings { blacklist: string[]; } -export const keymapsValueOf = (o: any): Keymaps => { - return Object.keys(o).reduce((keymaps: Keymaps, key: string): Keymaps => { - let op = operations.valueOf(o[key]); - keymaps[key] = op; - return keymaps; - }, {}); -}; - export const searchValueOf = (o: any): Search => { if (typeof o.default !== 'string') { throw new TypeError('string field "default" not set"'); @@ -97,7 +87,7 @@ export const valueOf = (o: any): Settings => { for (let key of Object.keys(o)) { switch (key) { case 'keymaps': - settings.keymaps = keymapsValueOf(o.keymaps); + settings.keymaps = Keymaps.fromJSON(o.keymaps); break; case 'search': settings.search = searchValueOf(o.search); @@ -115,8 +105,17 @@ export const valueOf = (o: any): Settings => { return settings; }; +export const toJSON = (settings: Settings): any => { + return { + keymaps: settings.keymaps.toJSON(), + search: settings.search, + properties: settings.properties, + blacklist: settings.blacklist, + }; +}; + export const DefaultSetting: Settings = { - keymaps: { + keymaps: Keymaps.fromJSON({ '0': { 'type': 'scroll.home' }, ':': { 'type': 'command.show' }, 'o': { 'type': 'command.show.open', 'alter': false }, @@ -179,7 +178,7 @@ export const DefaultSetting: Settings = { 'N': { 'type': 'find.prev' }, '.': { 'type': 'repeat.last' }, '<S-Esc>': { 'type': 'addon.toggle.enabled' } - }, + }), search: { default: 'google', engines: { |