mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-08 21:25:32 +02:00
get rid of utils.Cut since we can now rely on strings.Cut instead
This commit is contained in:
@@ -3,13 +3,13 @@
|
||||
package at
|
||||
|
||||
import (
|
||||
"kitty/tools/utils"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func parse_key_val_args(args []string) map[escaped_string]escaped_string {
|
||||
ans := make(map[escaped_string]escaped_string, len(args))
|
||||
for _, arg := range args {
|
||||
key, value, found := utils.Cut(arg, "=")
|
||||
key, value, found := strings.Cut(arg, "=")
|
||||
if found {
|
||||
ans[escaped_string(key)] = escaped_string(value)
|
||||
} else {
|
||||
|
||||
@@ -80,7 +80,7 @@ func get_pubkey(encoded_key string) (encryption_version string, pubkey []byte, e
|
||||
return
|
||||
}
|
||||
}
|
||||
encryption_version, encoded_key, found := utils.Cut(encoded_key, ":")
|
||||
encryption_version, encoded_key, found := strings.Cut(encoded_key, ":")
|
||||
if !found {
|
||||
err = fmt.Errorf("KITTY_PUBLIC_KEY environment variable does not have a : in it")
|
||||
return
|
||||
|
||||
@@ -48,7 +48,7 @@ func set_color_in_color_map(key, val string, ans map[string]any, check_nullable,
|
||||
func parse_colors_and_files(args []string) (map[string]any, error) {
|
||||
ans := make(map[string]any, len(args))
|
||||
for _, arg := range args {
|
||||
key, val, found := utils.Cut(strings.ToLower(arg), "=")
|
||||
key, val, found := strings.Cut(strings.ToLower(arg), "=")
|
||||
if found {
|
||||
err := set_color_in_color_map(key, val, ans, true, false)
|
||||
if err != nil {
|
||||
@@ -63,7 +63,7 @@ func parse_colors_and_files(args []string) (map[string]any, error) {
|
||||
defer f.Close()
|
||||
scanner := bufio.NewScanner(f)
|
||||
for scanner.Scan() {
|
||||
key, val, found := utils.Cut(scanner.Text(), " ")
|
||||
key, val, found := strings.Cut(scanner.Text(), " ")
|
||||
if found {
|
||||
set_color_in_color_map(strings.ToLower(key), strings.ToLower(strings.TrimSpace(val)), ans, true, true)
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"kitty/tools/utils"
|
||||
)
|
||||
|
||||
func parse_set_spacing(args []string) (map[string]any, error) {
|
||||
@@ -24,7 +22,7 @@ func parse_set_spacing(args []string) (map[string]any, error) {
|
||||
mapper[q+"-bottom"] = []string{q + "bottom"}
|
||||
}
|
||||
for _, arg := range args {
|
||||
k, v, found := utils.Cut(arg, "=")
|
||||
k, v, found := strings.Cut(arg, "=")
|
||||
if !found {
|
||||
return nil, fmt.Errorf("%s is not a valid setting", arg)
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@ package at
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"kitty/tools/utils"
|
||||
)
|
||||
|
||||
var valid_color_names = map[string]bool{"active_fg": true, "active_bg": true, "inactive_fg": true, "inactive_bg": true}
|
||||
@@ -14,7 +12,7 @@ var valid_color_names = map[string]bool{"active_fg": true, "active_bg": true, "i
|
||||
func parse_tab_colors(args []string) (map[string]any, error) {
|
||||
ans := make(map[string]any, len(args))
|
||||
for _, arg := range args {
|
||||
key, val, found := utils.Cut(strings.ToLower(arg), "=")
|
||||
key, val, found := strings.Cut(strings.ToLower(arg), "=")
|
||||
if !found {
|
||||
return nil, fmt.Errorf("%s is not a valid setting", arg)
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ func parse_escape_code(etype loop.EscapeCodeType, data []byte) (metadata map[str
|
||||
func parse_aliases(raw []string) (map[string][]string, error) {
|
||||
ans := make(map[string][]string, len(raw))
|
||||
for _, x := range raw {
|
||||
k, v, found := utils.Cut(x, "=")
|
||||
k, v, found := strings.Cut(x, "=")
|
||||
if !found {
|
||||
return nil, fmt.Errorf("%s is not valid MIME alias specification", x)
|
||||
}
|
||||
|
||||
@@ -70,16 +70,16 @@ func parse_identify_record(ans *IdentifyRecord, raw *IdentifyOutput) (err error)
|
||||
}
|
||||
ans.Gap = utils.Max(0, ans.Gap)
|
||||
}
|
||||
area, pos, found := utils.Cut(raw.Canvas, "+")
|
||||
area, pos, found := strings.Cut(raw.Canvas, "+")
|
||||
ok := false
|
||||
if found {
|
||||
w, h, found := utils.Cut(area, "x")
|
||||
w, h, found := strings.Cut(area, "x")
|
||||
if found {
|
||||
ans.Canvas.Width, err = strconv.Atoi(w)
|
||||
if err == nil {
|
||||
ans.Canvas.Height, err = strconv.Atoi(h)
|
||||
if err == nil {
|
||||
x, y, found := utils.Cut(pos, "+")
|
||||
x, y, found := strings.Cut(pos, "+")
|
||||
if found {
|
||||
ans.Canvas.Left, err = strconv.Atoi(x)
|
||||
if err == nil {
|
||||
@@ -94,7 +94,7 @@ func parse_identify_record(ans *IdentifyRecord, raw *IdentifyOutput) (err error)
|
||||
if !ok {
|
||||
return fmt.Errorf("Invalid canvas value in identify output: %s", raw.Canvas)
|
||||
}
|
||||
w, h, found := utils.Cut(raw.Size, "x")
|
||||
w, h, found := strings.Cut(raw.Size, "x")
|
||||
ok = false
|
||||
if found {
|
||||
ans.Width, err = strconv.Atoi(w)
|
||||
@@ -106,7 +106,7 @@ func parse_identify_record(ans *IdentifyRecord, raw *IdentifyOutput) (err error)
|
||||
if !ok {
|
||||
return fmt.Errorf("Invalid size value in identify output: %s", raw.Size)
|
||||
}
|
||||
x, y, found := utils.Cut(raw.Dpi, "x")
|
||||
x, y, found := strings.Cut(raw.Dpi, "x")
|
||||
ok = false
|
||||
if found {
|
||||
ans.Dpi.X, err = strconv.ParseFloat(x, 64)
|
||||
@@ -302,7 +302,7 @@ func Render(path string, ro *RenderOptions, frames []IdentifyRecord) (ans []*ima
|
||||
min_gap := calc_min_gap(gaps)
|
||||
for _, entry := range entries {
|
||||
fname := entry.Name()
|
||||
p, _, _ := utils.Cut(fname, ".")
|
||||
p, _, _ := strings.Cut(fname, ".")
|
||||
parts := strings.Split(p, "-")
|
||||
if len(parts) < 5 {
|
||||
continue
|
||||
@@ -319,11 +319,11 @@ func Render(path string, ro *RenderOptions, frames []IdentifyRecord) (ans []*ima
|
||||
if cerr != nil {
|
||||
continue
|
||||
}
|
||||
_, pos, found := utils.Cut(parts[3], "+")
|
||||
_, pos, found := strings.Cut(parts[3], "+")
|
||||
if !found {
|
||||
continue
|
||||
}
|
||||
px, py, found := utils.Cut(pos, "+")
|
||||
px, py, found := strings.Cut(pos, "+")
|
||||
if !found {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -91,15 +91,15 @@ func parse_place() (err error) {
|
||||
if opts.Place == "" {
|
||||
return nil
|
||||
}
|
||||
area, pos, found := utils.Cut(opts.Place, "@")
|
||||
area, pos, found := strings.Cut(opts.Place, "@")
|
||||
if !found {
|
||||
return fmt.Errorf("Invalid --place specification: %s", opts.Place)
|
||||
}
|
||||
w, h, found := utils.Cut(area, "x")
|
||||
w, h, found := strings.Cut(area, "x")
|
||||
if !found {
|
||||
return fmt.Errorf("Invalid --place specification: %s", opts.Place)
|
||||
}
|
||||
l, t, found := utils.Cut(pos, "x")
|
||||
l, t, found := strings.Cut(pos, "x")
|
||||
if !found {
|
||||
return fmt.Errorf("Invalid --place specification: %s", opts.Place)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user