diff options
author | G.raud <graud@gmx.com> | 2018-02-03 13:47:05 +0100 |
---|---|---|
committer | G.raud <graud@gmx.com> | 2018-02-03 18:17:14 +0100 |
commit | 7340d709618f0f9d65c4a544dc376ad5dc34349f (patch) | |
tree | 03cd3ed4e82caee59f2711ac145d9a5cb563fbb2 /src | |
parent | e7e44b9594e18f61792cafab7f2fe66506bc170e (diff) | |
download | unison-7340d709618f0f9d65c4a544dc376ad5dc34349f.zip unison-7340d709618f0f9d65c4a544dc376ad5dc34349f.tar.gz unison-7340d709618f0f9d65c4a544dc376ad5dc34349f.tar.bz2 |
Uitext.interact: add an option discard to actOnMatching
Diffstat (limited to 'src')
-rw-r--r-- | src/uitext.ml | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/uitext.ml b/src/uitext.ml index 53ae4c1..8ffdf95 100644 --- a/src/uitext.ml +++ b/src/uitext.ml @@ -321,14 +321,14 @@ 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 ?(change=true) f = + let actOnMatching ?(change=true) ?(discard=false) 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 not change then newLine(); - if f ri + if f ri || not discard then begin if change then begin redisplayri(); next() end else repeat() @@ -337,7 +337,7 @@ let interact prilist rilist = loop prev rest end | Some test -> newLine(); - let filt = fun ri -> if test ri then f ri else true in + let filt = fun ri -> if test ri then f ri || not discard else true in loop prev (ri::Safelist.filter filt rest) in displayri ri; @@ -519,7 +519,7 @@ let interact prilist rilist = (["-"], ("skip and discard for this session (curr or match)"), (fun () -> - actOnMatching (fun _->false))); + actOnMatching ~discard:true (fun _->false))); (["+"], ("skip and discard all the following"), (fun () -> newLine(); |