summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorG.raud <graud@gmx.com>2018-02-03 11:24:11 +0100
committerG.raud <graud@gmx.com>2018-02-03 12:23:32 +0100
commit1cf2f0d3a209b40ce030dad117ab083db85843dd (patch)
tree1bb0202c629d74b724f164197b23a2fdb8f628a8
parent3f1d6e5d542939bbe8b233227f598fd71b56e34d (diff)
downloadunison-1cf2f0d3a209b40ce030dad117ab083db85843dd.zip
unison-1cf2f0d3a209b40ce030dad117ab083db85843dd.tar.gz
unison-1cf2f0d3a209b40ce030dad117ab083db85843dd.tar.bz2
Uitext.interact: tweak actOnMatching to accept functions that display
-rw-r--r--src/uitext.ml17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/uitext.ml b/src/uitext.ml
index b6571a7..5f615b3 100644
--- a/src/uitext.ml
+++ b/src/uitext.ml
@@ -308,12 +308,21 @@ let interact prilist rilist =
loop (nukeIgnoredRis (ri::prev)) (nukeIgnoredRis ril) in
(* This should work on most terminals: *)
let redisplayri() = overwrite (); displayri ri; display "\n" in
- let actOnMatching f =
+ let actOnMatching ?(change=true) f =
(* [f] can have effects on the ri and return false to discard it *)
+ (* Disabling [change] avoids to redisplay the item, allows [f] to
+ print a message (info or error) on a separate line and repeats
+ instead of going to the next item *)
match !ripred with
- | None -> if f ri
- then begin redisplayri(); next() end
- else begin newLine(); loop prev rest end
+ | None -> if not change then newLine();
+ if f ri
+ then begin
+ if change then begin redisplayri(); next() end
+ else repeat()
+ end else begin
+ if change then newLine();
+ loop prev rest
+ end
| Some test -> newLine();
let filt = fun ri -> if test ri then f ri else true in
loop prev (ri::Safelist.filter filt rest)