Skip to content

Commit

Permalink
decolorize header name while saving sorted columns in csv file and re…
Browse files Browse the repository at this point in the history
…move arrows
  • Loading branch information
chinmaysomani07 committed Feb 9, 2023
1 parent 9666649 commit 801143c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion internal/view/table.go
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"os/user"
"path/filepath"
"regexp"
"strings"
"time"

Expand Down Expand Up @@ -109,7 +110,12 @@ func (t *Table) importAsCSV(evt *tcell.EventKey) *tcell.EventKey {
for i := 0; i < rowCount; i++ {
var row []string
for j := 0; j < colCount; j++ {
row = append(row, t.GetCell(i, j).Text)
text := t.GetCell(i, j).Text
if strings.Contains(text, "↑") || strings.Contains(text, "↓") {
text = decolorize(text)
text = text[:len(text)-3]
}
row = append(row, text)
}
tableData = append(tableData, row)
}
Expand Down Expand Up @@ -140,3 +146,8 @@ func (t *Table) importAsCSV(evt *tcell.EventKey) *tcell.EventKey {
clipboard.WriteAll(path)
return nil
}

func decolorize(input string) string {
re := regexp.MustCompile("\\[.*?\\]")
return re.ReplaceAllString(input, "")
}

0 comments on commit 801143c

Please sign in to comment.