package tiny_appkits
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
Application engines from scratch: a spreadsheet, rich text, paint, draw, CAD, editors and more
Install
dune-project
Dependency
Authors
Maintainers
Sources
0.3.6.tar.gz
md5=7c636383d146d30ac6f2fa234a6253c8
sha512=c79f3823c5f8f57e5038eb640d487c61168b84aa07c61999d6622ef9fd0c890e2b03b4c6a7cdbbe9352a49e25dda00ac7bb14693cee8e3d7beeed251351a2af0
doc/src/tiny_appkits.appkit_document/Undo.ml.html
Source file Undo.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56(* Claude Code * * Copyright (C) 2026 Yoann Padioleau * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * (LGPL) as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. *) (* See Undo.mli *) (* a version, and the name of the edit that made it *) (*****************************************************************************) (* Types *) (*****************************************************************************) type 'a step = { value : 'a; name : string option } type 'a t = { now : 'a step; past : 'a step list; future : 'a step list; limit : int } (*****************************************************************************) (* Functions *) (*****************************************************************************) let start ?(limit = 100) value = { now = { value; name = None }; past = []; future = []; limit } let now t = t.now.value (* the oldest versions are forgotten: an editor's memory has to stop * somewhere, and it stops at the end furthest from the person *) let rec keep n = function [] -> [] | x :: rest -> if n <= 0 then [] else x :: keep (n - 1) rest let record ?name value t = { t with now = { value; name }; past = keep t.limit (t.now :: t.past); future = [] } let amend value t = { t with now = { t.now with value } } let undo t = match t.past with | [] -> t | step :: past -> { t with now = step; past; future = t.now :: t.future } let redo t = match t.future with | [] -> t | step :: future -> { t with now = step; future; past = t.now :: t.past } let can_undo t = t.past <> [] let can_redo t = t.future <> [] (* undo takes back the edit that made the state we are in, so its name * is the one to show *) let undo_name t = if can_undo t then t.now.name else None let redo_name t = match t.future with [] -> None | step :: _ -> step.name let undos t = List.length t.past let redos t = List.length t.future
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>