Skip to content

Commit 917f05d

Browse files
committed
Use colors for the copy/paste status output
1 parent 4f37766 commit 917f05d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Diff for: v2/main.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ var (
4949

5050
// An empty *CodeCompleter struct
5151
cc = NewCodeCompleter()
52+
53+
envNoColor = env.Bool("NO_COLOR")
5254
)
5355

5456
func main() {
@@ -173,7 +175,11 @@ func main() {
173175
os.Chmod(filename, 0o755)
174176
}
175177
if tailString != "" && !batFlag {
176-
fmt.Printf("Wrote %d bytes to %s from the clipboard. Tail bytes: %s\n", n, filename, strings.TrimSpace(strings.ReplaceAll(tailString, "\n", "\\n")))
178+
if envNoColor {
179+
fmt.Printf("Wrote %d bytes to %s from the clipboard. Tail bytes: %s\n", n, filename, strings.TrimSpace(strings.ReplaceAll(tailString, "\n", "\\n")))
180+
} else {
181+
fmt.Printf("Wrote %s%d%s bytes to %s from the clipboard. Tail bytes: %s%s%s\n", vt100.Red, n, vt100.Stop(), filename, vt100.LightBlue, strings.TrimSpace(strings.ReplaceAll(tailString, "\n", "\\n")), vt100.Stop())
182+
}
177183
} else {
178184
fmt.Printf("Wrote %d bytes to %s from the clipboard.\n", n, filename)
179185
}
@@ -207,7 +213,11 @@ func main() {
207213
batFlag = true
208214
}
209215
if tailString != "" && !batFlag {
210-
fmt.Printf("Copied %d byte%s from %s to the clipboard. Tail bytes: %s\n", n, plural, filename, strings.TrimSpace(strings.ReplaceAll(tailString, "\n", "\\n")))
216+
if envNoColor {
217+
fmt.Printf("Copied %d byte%s from %s to the clipboard. Tail bytes: %s\n", n, plural, filename, strings.TrimSpace(strings.ReplaceAll(tailString, "\n", "\\n")))
218+
} else {
219+
fmt.Printf("Copied %s%d%s byte%s from %s to the clipboard. Tail bytes: %s%s%s\n", vt100.Yellow, n, vt100.Stop(), plural, filename, vt100.LightCyan, strings.TrimSpace(strings.ReplaceAll(tailString, "\n", "\\n")), vt100.Stop())
220+
}
211221
} else {
212222
fmt.Printf("Copied %d byte%s from %s to the clipboard.\n", n, plural, filename)
213223
}

Diff for: v2/neweditor.go

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ var (
2323
inVTEGUI = env.Bool("OG") // is o running within the VTE GUI application?
2424
noDrawUntilResize atomic.Bool // we are running within the VTE GUI application, but SIGWINCH has not been sent yet
2525
tempDir = env.Dir("TMPDIR", "/tmp")
26-
envNoColor = env.Bool("NO_COLOR")
2726
errFileNotFound = errors.New("file not found")
2827
)
2928

0 commit comments

Comments
 (0)