Restore “Restore Defaults” button in syntax editor

This commit is contained in:
1024jp 2024-02-09 11:13:13 +09:00
parent 696f4fe72e
commit 49039f52b7
2 changed files with 88 additions and 0 deletions

View File

@ -157,6 +157,11 @@ struct SyntaxEditView: View {
Divider()
HStack {
if self.isBundled {
Button(String(localized: "Restore Defaults", table: "SyntaxEdit")) {
self.restore()
}.fixedSize()
}
Spacer()
SubmitButtonGroup(action: self.submit) {
self.parent?.dismiss(nil)
@ -243,6 +248,19 @@ struct SyntaxEditView: View {
}
/// Restores the current settings in editor to the user default.
private func restore() {
guard
self.isBundled,
let definition = SyntaxManager.shared.bundledDefinition(name: self.name)
else { return }
self.syntax.update(with: definition)
self.errors = self.syntax.validate()
}
/// Validates the passed-in syntax name.
///
/// - Parameter name: The syntax name to test.

View File

@ -2973,6 +2973,76 @@
}
}
},
"Restore Defaults" : {
"localizations" : {
"cs" : {
"stringUnit" : {
"state" : "translated",
"value" : "Výchozí hodnoty"
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "Standard wiederherstellen"
}
},
"en-GB" : {
"stringUnit" : {
"state" : "translated",
"value" : "Restore Defaults"
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
"value" : "Restaurar valores por omisión"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Réglages par défaut"
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
"value" : "Ripristina default"
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "デフォルトに戻す"
}
},
"pt" : {
"stringUnit" : {
"state" : "translated",
"value" : "Restaurar Padrões"
}
},
"tr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Saptanmışlara Dön"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "恢复默认"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "回復預設值"
}
}
}
},
"Syntax.key.attributes.label" : {
"comment" : "syntax highlight type",
"extractionState" : "extracted_with_value",