mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 17:41:40 -05:00
Merge pull request #2664 from tridactyl/platform_specific_config
Add platform specific defaults
This commit is contained in:
commit
acbc6938d7
3 changed files with 46 additions and 7 deletions
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
import * as R from "ramda"
|
||||
import * as binding from "@src/lib/binding"
|
||||
import * as platform from "@src/lib/platform"
|
||||
|
||||
/* Remove all nulls from objects recursively
|
||||
* NB: also applies to arrays
|
||||
|
@ -1059,8 +1060,35 @@ export class default_config {
|
|||
visualexitauto: "true" | "false" = "true"
|
||||
}
|
||||
|
||||
const platform_defaults = {
|
||||
win: {
|
||||
browsermaps: {
|
||||
"<C-6>": null,
|
||||
"<A-6>": "buffer #",
|
||||
} as unknown, // typescript doesn't like me adding new binds like this
|
||||
nmaps: {
|
||||
"<C-6>": "buffer #",
|
||||
} as unknown,
|
||||
imaps: {
|
||||
"<C-6>": "buffer #",
|
||||
} as unknown,
|
||||
inputmaps: {
|
||||
"<C-6>": "buffer #",
|
||||
} as unknown,
|
||||
ignoremaps: {
|
||||
"<C-6>": "buffer #",
|
||||
} as unknown,
|
||||
},
|
||||
} as Record<browser.runtime.PlatformOs, default_config>
|
||||
|
||||
|
||||
/** @hidden
|
||||
* Merges two objects and removes all keys with null values at all levels
|
||||
*/
|
||||
export const mergeDeepCull = R.pipe(mergeDeep, removeNull)
|
||||
|
||||
/** @hidden */
|
||||
export const DEFAULTS = o(new default_config())
|
||||
export const DEFAULTS = mergeDeepCull(o(new default_config()), platform_defaults[platform.getPlatformOs()])
|
||||
|
||||
/** Given an object and a target, extract the target if it exists, else return undefined
|
||||
|
||||
|
@ -1126,11 +1154,6 @@ export function mergeDeep(o1, o2) {
|
|||
return r
|
||||
}
|
||||
|
||||
/** @hidden
|
||||
* Merges two objects and removes all keys with null values at all levels
|
||||
*/
|
||||
export const mergeDeepCull = R.pipe(mergeDeep, removeNull)
|
||||
|
||||
/** @hidden
|
||||
* Gets a site-specific setting.
|
||||
*/
|
||||
|
|
15
src/lib/platform.ts
Normal file
15
src/lib/platform.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import * as R from "ramda"
|
||||
|
||||
// Synchronous version of runtime.getPlatformInfo()
|
||||
// Not as exhaustive as the real thing
|
||||
// Will return undefined if it can't work it out
|
||||
export function getPlatformOs(): browser.runtime.PlatformOs {
|
||||
const platform = navigator.platform
|
||||
const mapping = {
|
||||
"win": "Windows",
|
||||
"openbsd": "BSD",
|
||||
"mac": "Mac",
|
||||
"linux": "Linux",
|
||||
}
|
||||
return R.keys(R.filter(x=>platform.includes(x), mapping))[0] as keyof typeof mapping
|
||||
}
|
|
@ -24,7 +24,8 @@
|
|||
},
|
||||
"command_2": {
|
||||
"suggested_key": {
|
||||
"default": "MacCtrl+6"
|
||||
"default": "MacCtrl+6",
|
||||
"windows": "Alt+6"
|
||||
},
|
||||
"description": "Internal use. See `:help bind`. Use `:bind --mode=browser` to change - do not change here."
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue