本文整理汇总了TypeScript中@src/lib/config.get函数的典型用法代码示例。如果您正苦于以下问题:TypeScript get函数的具体用法?TypeScript get怎么用?TypeScript get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: readText
export function readText(text: string): void {
if (window.speechSynthesis.getVoices().length === 0) {
// should try to warn user? This apparently can happen on some machines
// TODO: Implement when there's an error feedback mechanism
throw new Error("No voice found: cannot use Text-To-Speech API")
}
const utterance = new SpeechSynthesisUtterance(text)
const pitch = Config.get("ttspitch")
const voice = Config.get("ttsvoice")
const volume = Config.get("ttsvolume")
const rate = Config.get("ttsrate")
if (pitch >= 0 && pitch < 2) utterance.pitch = pitch
if (volume >= 0 && volume <= 1) utterance.volume = volume
if (rate >= 0.1 && rate <= 10) utterance.rate = rate
const voiceObj = getVoiceFromName(voice)
if (voiceObj) {
utterance.voice = voiceObj
}
window.speechSynthesis.speak(utterance)
}
开发者ID:antonva,项目名称:tridactyl,代码行数:27,代码来源:text_to_speech.ts
示例2: addContentStateChangedListener
addContentStateChangedListener((property, oldMode, oldValue, newValue) => {
let mode = newValue
let suffix = ""
let result = ""
if (property !== "mode") {
if (property === "suffix") {
mode = oldMode
suffix = newValue
} else {
return
}
}
const privateMode = browser.extension.inIncognitoContext
? "TridactylPrivate"
: ""
statusIndicator.className =
"cleanslate TridactylStatusIndicator " + privateMode
if (
dom.isTextEditable(document.activeElement) &&
!["input", "ignore"].includes(mode)
) {
statusIndicator.textContent = "insert"
// this doesn't work; statusIndicator.style is full of empty string
// statusIndicator.style.borderColor = "green !important"
// need to fix loss of focus by click: doesn't do anything here.
} else if (
mode === "insert" &&
!dom.isTextEditable(document.activeElement)
) {
statusIndicator.textContent = "normal"
// statusIndicator.style.borderColor = "lightgray !important"
} else {
result = mode
}
const modeindicatorshowkeys = Config.get("modeindicatorshowkeys")
if (modeindicatorshowkeys === "true" && suffix !== "") {
result = mode + " " + suffix
}
logger.debug(
"statusindicator: ",
result,
";",
"config",
modeindicatorshowkeys,
)
statusIndicator.textContent = result
statusIndicator.className +=
" TridactylMode" + statusIndicator.textContent
if (config.get("modeindicator") !== "true") statusIndicator.remove()
})
开发者ID:antonva,项目名称:tridactyl,代码行数:52,代码来源:content.ts
示例3: log
/**
* Config-aware logging function.
*
* @param level the level of the logging - if <= configured, the message
* will be shown
*
* @return logging function: this is returned as a function to
* retain the call site
*/
private log(level: Config.LoggingLevel) {
const configedLevel = Config.get("logging", this.logModule)
if (LevelToNum.get(level) <= LevelToNum.get(configedLevel)) {
// hand over to console.log, error or debug as needed
switch (level) {
case "error":
// TODO: replicate this for other levels, don't steal focus
// work out how to import messaging/webext without breaking everything
return async (...message) => {
console.error(...message)
return browser.runtime.sendMessage({
type: "controller_background",
command: "acceptExCmd",
args: ["fillcmdline_nofocus # " + message.join(" ")],
})
}
case "warning":
return console.warn
case "info":
return console.log
case "debug":
return console.debug
}
}
// do nothing with the message
return function(...args) {}
}
开发者ID:antonva,项目名称:tridactyl,代码行数:38,代码来源:logging.ts
示例4: expandExstr
export function expandExstr(
exstr: string,
aliases = config.get("exaliases"),
prevExpansions: string[] = [],
): string {
// Split on whitespace
const [command] = exstr.trim().split(/\s+/)
// Base case: alias not found; return original command
if (aliases[command] === undefined) {
return exstr
}
// Infinite loop detected
if (prevExpansions.includes(command)) {
throw `Infinite loop detected while expanding aliases. Stack: ${prevExpansions}.`
}
// Add command to expansions used so far
prevExpansions.push(command)
// Alias exists; expand it recursively
return expandExstr(
exstr.replace(command, aliases[command]),
aliases,
prevExpansions,
)
}
开发者ID:antonva,项目名称:tridactyl,代码行数:28,代码来源:aliases.ts
示例5: shouldNagForVersion
export function shouldNagForVersion(version: TriVersionFeedItem) {
const timeSinceRelease = (Date.now() - version.releaseDate.getTime()) / 1000
const updateNagWaitSeconds = Config.get("update", "nagwait") * 24 * 60 * 60
const newerThanInstalled = SemverCompare(version.version, getInstalledPatchVersion()) > 0
return newerThanInstalled && timeSinceRelease > updateNagWaitSeconds
}
开发者ID:antonva,项目名称:tridactyl,代码行数:7,代码来源:updates.ts
示例6: parser
export function parser(conf, keys): keyseq.ParserResponse {
let maps: any = config.get(conf)
if (maps === undefined) throw new Error("No binds defined for this mode. Reload page with <C-r> and add binds, e.g. :bind --mode=[mode] <Esc> mode normal")
// If so configured, translate keys using the key translation map
if (config.get("keytranslatemodes")[conf] === "true") {
const translationmap = config.get("keytranslatemap")
keyseq.translateKeysUsingKeyTranslateMap(keys, translationmap)
}
// Remove unbound keys
maps = Object.entries(maps).filter(([k, v]) => v !== "")
// Convert to KeyMap
maps = keyseq.mapstrMapToKeyMap(new Map(maps))
return keyseq.parse(keys, maps)
}
开发者ID:antonva,项目名称:tridactyl,代码行数:17,代码来源:genericmode.ts
示例7: getLatestVersion
export async function getLatestVersion(force_check = false) {
const pastUpdateInterval = secondsSinceLastCheck() > Config.get("update", "checkintervalsecs")
if (force_check || pastUpdateInterval) {
await updateVersion()
}
return highestKnownVersion
}
开发者ID:antonva,项目名称:tridactyl,代码行数:8,代码来源:updates.ts
示例8: editor
export async function editor(file: string, line: number, col: number, content?: string) {
if (content !== undefined) await write(file, content)
const editorcmd =
(config.get("editorcmd") === "auto"
? await getBestEditor()
: config.get("editorcmd"))
.replace(/%l/, line)
.replace(/%c/, col)
let exec
if (editorcmd.indexOf("%f") !== -1) {
exec = await run(editorcmd.replace(/%f/, file))
} else {
exec = await run(editorcmd + " " + file)
}
if (exec.code != 0)
return exec
return read(file)
}
开发者ID:antonva,项目名称:tridactyl,代码行数:18,代码来源:native.ts
示例9: protectSlash
function protectSlash(e) {
config.get("blacklistkeys").map(
protkey => {
if (protkey.indexOf(e.key) !== -1 && contentState.mode === "normal") {
e.cancelBubble = true
e.stopImmediatePropagation()
}
}
)
}
开发者ID:antonva,项目名称:tridactyl,代码行数:10,代码来源:content.ts
示例10: naggedForVersion
export function naggedForVersion(version: TriVersionFeedItem) {
const lastNaggedVersion = Config.get("update", "lastnaggedversion")
if (lastNaggedVersion) {
// If the version is <= the last nagged version, we've already
// nagged for it.
return SemverCompare(version.version, lastNaggedVersion) <= 0
} else {
return false
}
}
开发者ID:antonva,项目名称:tridactyl,代码行数:10,代码来源:updates.ts
注:本文中的@src/lib/config.get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论