File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ ansicolors = {
2
+ "BLACK" : "\033 [30m" ,
3
+ "RED" : "\033 [31m" ,
4
+ "GREEN" : "\033 [32m" ,
5
+ "YELLOW" : "\033 [33m" ,
6
+ "BLUE" : "\033 [34m" ,
7
+ "MAGENTA" : "\033 [35m" ,
8
+ "CYAN" : "\033 [36m" ,
9
+ "WHITE" : "\033 [37m" ,
10
+ "BOLD" : "\033 [1m" ,
11
+ "RESET" : "\033 [0m" ,
12
+ }
13
+
14
+ green_start = ansicolors ["GREEN" ]
15
+ red_start = ansicolors ["RED" ]
16
+ cyan_start = ansicolors ["CYAN" ]
17
+ reset = ansicolors ["RESET" ]
18
+
19
+
20
+ def color_unified_diff_line (line ):
21
+ if line [0 :2 ] == "+ " :
22
+ return f"{ green_start } { line } { reset } "
23
+ elif line [0 :2 ] == "- " :
24
+ return f"{ red_start } { line } { reset } "
25
+ elif line [0 :3 ] == "@@ " :
26
+ return f"{ cyan_start } { line } { reset } "
27
+ elif line [0 :4 ] == "--- " :
28
+ return f"{ red_start } { line } { reset } "
29
+ elif line [0 :4 ] == "+++ " :
30
+ return f"{ green_start } { line } { reset } "
31
+ else :
32
+ return line
You can’t perform that action at this time.
0 commit comments