diff options
| author | Will Eccles <[email protected]> | 2019-04-04 12:48:29 -0400 |
|---|---|---|
| committer | Will Eccles <[email protected]> | 2019-04-04 12:48:29 -0400 |
| commit | e4b86316185f10a4dc9d3fce93a2e9229c08200c (patch) | |
| tree | 5a2556185542735977f4d169001789a256d353dd | |
| parent | Added support for kitty, both input and output (diff) | |
| download | schemer2-e4b86316185f10a4dc9d3fce93a2e9229c08200c.tar.xz schemer2-e4b86316185f10a4dc9d3fce93a2e9229c08200c.zip | |
kitty input is now sorted
| -rw-r--r-- | input.go | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -8,6 +8,7 @@ import ( "regexp" "strconv" "strings" + "sort" ) func readFile(filename string) (string, error) { @@ -277,12 +278,17 @@ func inputKittyTerm(filename string) ([]color.Color, error) { re := regexp.MustCompile("^color[0-9]*") for _, l := range lines { if len(re.FindAllString(l, 1)) != 0 { - colorlines = append(colorlines, l) + colorlines = append(colorlines, strings.Replace(l, "color", "", 1)) } } + sort.Slice(colorlines, func(i, j int) bool { + numA, _ := strconv.Atoi(strings.TrimSpace(colorlines[i][:2])) + numB, _ := strconv.Atoi(strings.TrimSpace(colorlines[j][:2])) + return numA < numB + }) + // Extract and parse colors - // TODO: Sort by number first? colors := make([]color.Color, 0) for _, l := range colorlines { // Assuming the color to be the rightmost half of the last instance of space/tab |