forked from panglesd/diffcessible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.diff
190 lines (183 loc) · 5.41 KB
/
example.diff
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
diff --git a/bin/dune b/bin/dune
index fca70de..fd7f225 100644
--- a/bin/dune
+++ b/bin/dune
@@ -1,4 +1,4 @@
(executable
(public_name diffcessible)
(name main)
- (libraries diffcessible cmdliner))
+ (libraries diffcessible cmdliner patch))
diff --git a/bin/main.ml b/bin/main.ml
index e03c4a4..cb71f31 100644
--- a/bin/main.ml
+++ b/bin/main.ml
@@ -1,7 +1,9 @@
open Diffcessible
let main () =
- Interactive_viewer.start ()
+ let s = In_channel.input_all In_channel.stdin in
+ let patch = Patch.to_diffs s in
+ Interactive_viewer.start patch
open Cmdliner
diff --git a/lib/dune b/lib/dune
index 196ed80..4269b32 100644
--- a/lib/dune
+++ b/lib/dune
@@ -1,3 +1,3 @@
(library
(name diffcessible)
- (libraries notty nottui lwd))
+ (libraries notty nottui lwd patch))
diff --git a/lib/interactive_viewer.ml b/lib/interactive_viewer.ml
index 9b59dfe..169ab52 100644
--- a/lib/interactive_viewer.ml
+++ b/lib/interactive_viewer.ml
@@ -1,39 +1,25 @@
open Nottui
module W = Nottui_widgets
-open Lwd_infix
-
-type patch = unit
+(* open Lwd_infix *)
let pure_str s = Lwd.pure (W.string s)
-
-let string_of_counter c =
- let$ c = c in
- W.string (string_of_int c)
-
let quit = Lwd.var false
-let counter = Lwd.var 0
-let counter_d = Lwd.get counter
+let string_of_operation = Format.asprintf "%a" (Patch.pp_operation ~git:false)
-let view =
+let view (patch : Patch.t list) =
+ let patch = match patch with p :: _ -> p | _ -> assert false in
W.scrollbox
(W.vbox
[
- pure_str "Hello world!";
- string_of_counter counter_d;
+ pure_str (string_of_operation patch.operation);
Lwd.pure
@@ Ui.keyboard_area
(function
| `ASCII 'q', [] ->
Lwd.set quit true;
`Handled
- | `ASCII 'a', [] ->
- Lwd.set counter (Lwd.peek counter + 1);
- `Handled
- | `ASCII 'b', [] ->
- Lwd.set counter (Lwd.peek counter - 1);
- `Handled
| _ -> `Unhandled)
(W.string "Type 'q' to quit.");
])
-let start () = Ui_loop.run ~quit ~tick_period:0.2 view
+let start patch = Ui_loop.run ~quit ~tick_period:0.2 (view patch)
diff --git a/lib/interactive_viewer.mli b/lib/interactive_viewer.mli
index 1202346..1afff98 100644
--- a/lib/interactive_viewer.mli
+++ b/lib/interactive_viewer.mli
@@ -1,5 +1,3 @@
(** Render and navigate through a diff. *)
-type patch = unit
-
-val start : patch -> unit
+val start : Patch.t list -> unit
diff --git a/dir1/file.txt b/dir2/file.txt
index dfd0d1e..ce59064 100644
--- a/dir1/file.txt
+++ b/dir2/file.txt
@@ -1 +1 @@
-This is the original content.
+This is the modified content.
diff --git a/dir2/new_diff.diff b/dir2/new_diff.diff
new file mode 100644
index 0000000..e69de29
diff --git a/dir1/file.txt b/dir2/file.txt
index dfd0d1e..50e0cc9 100644
--- a/dir1/file.txt
+++ b/dir2/file.txt
@@ -1 +1,2 @@
This is the original content.
+Here is some additional line.
diff --git a/dir2/new_diff.diff b/dir2/new_diff.diff
new file mode 100644
index 0000000..e69de29
diff --git a/dir1/file.txt b/dir2/file.txt
index dfd0d1e..cf5dea7 100644
--- a/dir1/file.txt
+++ b/dir2/file.txt
@@ -1 +1,2 @@
-This is the original content.
+Here is some additional line.
+Deleted line 1 and added this.
diff --git a/dir2/file.txt b/dir2/file.txt
new file mode 100644
index 0000000..01a59b0
--- /dev/null
+++ b/dir2/file.txt
@@ -0,0 +1 @@
+lorem ipsum
diff --git a/dir1/file.txt b/dir1/file.txt
deleted file mode 100644
index 7b57bd2..0000000
--- a/dir1/file.txt
+++ /dev/null
@@ -1 +0,0 @@
-some text
diff --git a/dir1/file.txt b/dir2/new_file.txt
similarity index 100%
rename from dir1/file.txt
rename to dir2/new_file.txt
diff --git a/dir1/file.txt b/dir1/file.txt
deleted file mode 100644
index 7b57bd2..0000000
--- a/dir1/file.txt
+++ /dev/null
@@ -1 +0,0 @@
-some text
diff --git a/dir2/sample.txt b/dir2/sample.txt
new file mode 100644
index 0000000..9809dd1
--- /dev/null
+++ b/dir2/sample.txt
@@ -0,0 +1,2 @@
+some text
+lorem ipsum
diff --git a/dir1/file.txt b/dir2/file.txt
index e69de29..eee417f 100644
--- a/dir1/file.txt
+++ b/dir2/file.txt
@@ -0,0 +1 @@
+new text
diff --git a/ocaml.txt b/ocaml.txt
index 4327c22..7becacf 100755
--- a/ocaml.txt
+++ b/ocaml.txt
@@ -0,0 +1,2 @@
+OCaml is an industrial-strength functional programming language with an emphasis on expressiveness and safety.
+Learning OCaml is interesting.
@@ -4,1 +4,2 @@
-Want to begin?
+Take a tour at https://ocaml.org/docs/tour-of-ocaml
+Write your first OCaml program here - https://ocaml.org/docs/your-first-program
diff --git a/outreachy.txt b/outreachy.txt
index 0de0c1f..dad322e 100755
--- a/outreachy.txt
+++ b/outreachy.txt
@@ -1,2 +1,2 @@
Outreachy internship projects may include programming, research, user experience, documentation, graphical design, data science, marketing, user advocacy, event planning, and more!
-Outreachy provides internships in open source and open science.
+Outreachy provides internships to people subject to systemic bias and impacted by underrepresentation in the technical industry where they are living.
@@ -5,2 +5,1 @@
-Outreachy is a diversity initiative of Software Freedom Conservancy.
-It is a life-changing experience.
+Outreachy provides a platform to contribute to open source and open science through learning, collaboration, and contribution.
@@ -9,2 +9,2 @@
-Join us in making a difference!
-Thank you
+Hello
+Outreachy