fd046800074548b6746141c45e46deb7da14ab07

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

fix: change cat lineno color and style

Diff

 1diff --git a/server/middleware.go b/server/middleware.go
 2index 1ef8759411c81131941e45180965849e752bc435..e60fd53b57648ce20db5722a217ae6a0d857f067 100644
 3--- a/server/middleware.go
 4+++ b/server/middleware.go
 5@@ -17,6 +17,10 @@ import (
 6 	"github.com/muesli/termenv"
 7 )
 8 
 9+var (
10+	linenoStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("8"))
11+)
12+
13 // softServeMiddleware is a middleware that handles displaying files with the
14 // option of syntax highlighting and line numbers.
15 func softServeMiddleware(ac *appCfg.Config) wish.Middleware {
16@@ -109,14 +113,14 @@ func readFile(r *gg.Repository, fp string) (string, error) {
17 }
18 
19 func withLineNumber(s string, color bool) string {
20-	st := lipgloss.NewStyle().Foreground(lipgloss.Color("15"))
21 	lines := strings.Split(s, "\n")
22 	mll := fmt.Sprintf("%d", len(fmt.Sprintf("%d", len(lines))))
23 	for i, l := range lines {
24-		lines[i] = fmt.Sprintf("%-"+mll+"d │ %s", i+1, l)
25+		lines[i] = fmt.Sprintf("%-"+mll+"d", i+1)
26 		if color {
27-			lines[i] = st.Render(lines[i])
28+			lines[i] = linenoStyle.Render(lines[i])
29 		}
30+		lines[i] += " │ " + l
31 	}
32 	return strings.Join(lines, "\n")
33 }