mirror of
https://github.com/wavetermdev/backup.git
synced 2026-08-05 13:57:07 -07:00
add support for "Hack" font family (#309)
* testing hack font * updates to allow font to be variable * allow setting of font-family. get initial font family from electron (needed for loading) * add termfontfamily * update wave logos for README * hook up fontfamily setting, remove old dropdown active var * get app to reload on font change. reload fonts * on termfontsize change, bump render version as well
This commit is contained in:
@@ -5134,6 +5134,24 @@ func validateOpenAIModel(model string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
const MaxFontFamilyLen = 50
|
||||
|
||||
var fontfamilyRe = regexp.MustCompile(`^[a-zA-Z0-9_ -]+$`)
|
||||
|
||||
func validateFontFamily(fontFamily string) error {
|
||||
if len(fontFamily) == 0 {
|
||||
return nil
|
||||
}
|
||||
if len(fontFamily) > MaxFontFamilyLen {
|
||||
return fmt.Errorf("invalid font family, too long")
|
||||
}
|
||||
m := fontfamilyRe.MatchString(fontFamily)
|
||||
if !m {
|
||||
return fmt.Errorf("invalid font family, must match %q", fontfamilyRe.String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ClientSetCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scbus.UpdatePacket, error) {
|
||||
clientData, err := sstore.EnsureClientData(ctx)
|
||||
if err != nil {
|
||||
@@ -5156,6 +5174,20 @@ func ClientSetCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sc
|
||||
}
|
||||
varsUpdated = append(varsUpdated, "termfontsize")
|
||||
}
|
||||
if fontFamilyStr, found := pk.Kwargs["termfontfamily"]; found {
|
||||
newFontFamily := fontFamilyStr
|
||||
err = validateFontFamily(newFontFamily)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
feOpts := clientData.FeOpts
|
||||
feOpts.TermFontFamily = newFontFamily
|
||||
err = sstore.UpdateClientFeOpts(ctx, feOpts)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error updating client feopts: %v", err)
|
||||
}
|
||||
varsUpdated = append(varsUpdated, "termfontfamily")
|
||||
}
|
||||
if apiToken, found := pk.Kwargs["openaiapitoken"]; found {
|
||||
err = validateOpenAIAPIToken(apiToken)
|
||||
if err != nil {
|
||||
@@ -5244,7 +5276,7 @@ func ClientSetCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sc
|
||||
}
|
||||
}
|
||||
if len(varsUpdated) == 0 {
|
||||
return nil, fmt.Errorf("/client:set requires a value to set: %s", formatStrs([]string{"termfontsize", "openaiapitoken", "openaimodel", "openaibaseurl", "openaimaxtokens", "openaimaxchoices"}, "or", false))
|
||||
return nil, fmt.Errorf("/client:set requires a value to set: %s", formatStrs([]string{"termfontsize", "termfontfamily", "openaiapitoken", "openaimodel", "openaibaseurl", "openaimaxtokens", "openaimaxchoices"}, "or", false))
|
||||
}
|
||||
clientData, err = sstore.EnsureClientData(ctx)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user