diff options
author | G.raud <graud@gmx.com> | 2018-02-02 17:30:02 +0100 |
---|---|---|
committer | G.raud <graud@gmx.com> | 2018-02-02 20:43:02 +0100 |
commit | 03fa8a53b9feae62c517cdc37a484bcf83b9d3c6 (patch) | |
tree | 350e08b3083dbf71b8cf710f114426a6ca9df65b | |
parent | d0a09c98f9d065a796d9ccf458b7acc2474ef701 (diff) | |
download | unison-03fa8a53b9feae62c517cdc37a484bcf83b9d3c6.zip unison-03fa8a53b9feae62c517cdc37a484bcf83b9d3c6.tar.gz unison-03fa8a53b9feae62c517cdc37a484bcf83b9d3c6.tar.bz2 |
Uitext.interact: new subfunction actOnMatching
A subfunction to do an action on the current item then repeat or to do
an action on a subset of the following items that matches a mutable
predicate and filter them.
-rw-r--r-- | src/uitext.ml | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/uitext.ml b/src/uitext.ml index 8eaa1ff..96fffa2 100644 --- a/src/uitext.ml +++ b/src/uitext.ml @@ -268,6 +268,7 @@ let interact prilist rilist = | {replicas = Different diff} -> diff.direction <- Conflict "skip requested" | _ -> () in + let ripred = ref None in let rec loop prev = let rec previous prev ril = match prev with @@ -295,6 +296,16 @@ 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 = + (* [f] can have effects on the ri and return false to discard it *) + match !ripred with + | None -> if f ri + then begin redisplayri(); next() end + else begin 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) + in displayri ri; match ri.replicas with Problem s -> display "\n"; display s; display "\n"; next() |