about summary refs log tree commit diff stats
path: root/contrib
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-03-30 14:12:04 -0400
committerDrew DeVault <sir@cmpwn.com>2019-03-30 14:12:04 -0400
commitfa04a1e036a418258451466d99de34a9546a9965 (patch)
treeec409d99e9a306488c6ffb9b71683e171a2ec007 /contrib
parent2958579ee75359dacfabb6d1b36664468011113c (diff)
downloadaerc-fa04a1e036a418258451466d99de34a9546a9965.tar.gz
Add basic message viewer mockup
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/hldiff.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/contrib/hldiff.py b/contrib/hldiff.py
new file mode 100755
index 0000000..e12f688
--- /dev/null
+++ b/contrib/hldiff.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+from colorama import Fore, Style
+import sys
+import re
+
+patch = sys.stdin.read().replace("\r\n", "\n")
+stat_re = re.compile(r'(\+*)(\-*)')
+
+hit_diff = False
+for line in patch.split("\n"):
+    if line.startswith("diff "):
+        hit_diff = True
+        print(line)
+        continue
+    if hit_diff:
+        if line.startswith("-"):
+            print(f"{Fore.RED}{line}{Style.RESET_ALL}")
+        elif line.startswith("+"):
+            print(f"{Fore.GREEN}{line}{Style.RESET_ALL}")
+        else:
+            print(line)
+    else:
+        if line.startswith(" ") and "|" in line and ("+" in line or "-" in line):
+            line = stat_re.sub(
+                    f'{Fore.GREEN}\\1{Fore.RED}\\2{Style.RESET_ALL}',
+                    line)
+        print(line)
t.cc?h=hlt&id=dd66068298b0a11f2a1f195376cba98e0c8570b5'>dd660682 ^
92a3d082 ^
dd660682 ^









01ce563d ^


92a3d082 ^


01ce563d ^



92a3d082 ^
01ce563d ^









1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63