diff options
Diffstat (limited to 'lib/editorBuffer.ml')
| -rw-r--r-- | lib/editorBuffer.ml | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/editorBuffer.ml b/lib/editorBuffer.ml index 2e2b4b6..b682116 100644 --- a/lib/editorBuffer.ml +++ b/lib/editorBuffer.ml | |||
| @@ -29,8 +29,27 @@ module Action = struct | |||
| 29 | let bof = far_left |> on_content | 29 | let bof = far_left |> on_content |
| 30 | let eof = far_right |> on_content | 30 | let eof = far_right |> on_content |
| 31 | let insert k = map_focus (push k) |> on_content | 31 | let insert k = map_focus (push k) |> on_content |
| 32 | let delete_after ~n = Fn.apply_n_times ~n (map_focus pop_after) |> on_content | 32 | |
| 33 | let delete_before ~n = Fn.apply_n_times ~n (map_focus pop) |> on_content | 33 | let delete_after ?(cross_lines = false) ~n = |
| 34 | let aux z = | ||
| 35 | let line = focus_or ~default:Zipper.empty z in | ||
| 36 | if cross_lines && is_far_right line && not (is_far_right z) then | ||
| 37 | (* let next = right z |> focus_or ~default:Zipper.empty |> far_left in *) | ||
| 38 | (* right z |> pop_after |> left |> map_focus (Fn.flip join next) *) | ||
| 39 | pop_after z |> map_focus_or ~default:line (far_left &> join line) | ||
| 40 | else map_focus pop_after z | ||
| 41 | in | ||
| 42 | Fn.apply_n_times ~n aux |> on_content | ||
| 43 | |||
| 44 | let delete_before ?(cross_lines = false) ~n = | ||
| 45 | let aux z = | ||
| 46 | let line = focus_or ~default:Zipper.empty z in | ||
| 47 | if cross_lines && is_far_left line && not (is_far_left z) then | ||
| 48 | pop_after z |> left |> map_focus (far_right &> Fn.flip join line) | ||
| 49 | else map_focus pop z | ||
| 50 | in | ||
| 51 | Fn.apply_n_times ~n aux |> on_content | ||
| 52 | |||
| 34 | let delete_to_eol = map_focus (split &> fst) |> on_content | 53 | let delete_to_eol = map_focus (split &> fst) |> on_content |
| 35 | let delete_to_bol = map_focus (split &> snd) |> on_content | 54 | let delete_to_bol = map_focus (split &> snd) |> on_content |
| 36 | let delete_lines ~n = Fn.apply_n_times ~n pop_after |> on_content | 55 | let delete_lines ~n = Fn.apply_n_times ~n pop_after |> on_content |
