diff options
Diffstat (limited to 'src/selection.ml')
-rwxr-xr-x | src/selection.ml | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/selection.ml b/src/selection.ml index 2bf41ce..28e11fa 100755 --- a/src/selection.ml +++ b/src/selection.ml @@ -71,3 +71,17 @@ end let shift = function | Single (start_x, start_y) -> fun (x, y) -> (x - start_x, y - start_y) | Multiple ((start_x, start_y), _) -> fun (x, y) -> (x - start_x, y - start_y) + +let move direction t = + let position = extract t in + let position' = begin match direction with + | Actions.Left quant -> Tools.Tuple2.replace1 (max 1 ((fst position) - quant)) position + | Actions.Right quant -> Tools.Tuple2.replace1 ((fst position) + quant) position + | Actions.Up quant -> Tools.Tuple2.replace2 (max 1 ((snd position) - quant)) position + | Actions.Down quant -> Tools.Tuple2.replace2 ((snd position) + quant) position + | Actions.Absolute (x, y)-> (x, y) + end in + if position = position' then + None + else + Some (create position') |