summaryrefslogtreecommitdiff
path: root/docs/dit.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/dit.md')
-rw-r--r--docs/dit.md59
1 files changed, 59 insertions, 0 deletions
diff --git a/docs/dit.md b/docs/dit.md
new file mode 100644
index 0000000..999a5be
--- /dev/null
+++ b/docs/dit.md
@@ -0,0 +1,59 @@
+# Dit API
+
+## Structures
+
+```
+LineIndex: 5 bytes
+ - type: 1 byte
+ - data: 4 bytes
+
+Current: 0
+Last: 0
+Number: 0
+CurrentPlus: i32
+Bookmark: FieldIndex
+FirstRegex: FieldIndex
+LastRegex: FieldIndex
+
+LineRange: 10 bytes
+ - start: LineIndex (5 bytes)
+ - end: LineIndex (5 bytes)
+
+FieldIndex: 4 bytes
+
+BufferId: 1 byte
+```
+
+## Commands
+
+Commands, for the most part, are contained within a single byte slice in the
+first message field. The other fields will be used if the command needs to
+reference a string or a file, using the `FieldIndex` type. Those fields can be
+set to null if the field index is zero. The first byte indicates which command
+is being requested. If the calling program has opened multiple buffers, then it
+can optionally specify the buffer id by adding it to the end of the byte slice.
+Otherwise, the implied buffer is the last one that has been used by the calling
+program.
+
+```
+append = [0, LineIndex, FieldIndex, BufferId?]
+change = [1, LineRange, FieldIndex, BufferId?]
+delete = [2, LineRange, BufferId?]
+open = [3, FieldIndex] returns BufferId
+setfile = [4, FieldIndex, BufferId?]
+find = [5, LineRange, FieldIndex, BufferId?] returns number[]
+insert = [6, LineIndex, FieldIndex, BufferId?]
+join = [7, LineRange, BufferId?]
+bookmark = [8, LineIndex, FieldIndex, BufferId?]
+move = [9, LineRange, LineIndex, BufferId?]
+read = [10, LineRange, BufferId?] returns [LineRange, String]
+substitute = [11, LineRange, FieldIndex, FieldIndex, BufferId?]
+copy = [12, LineRange, FieldIndex, BufferId?]
+undo = [13, BufferId?]
+write = [14, BufferId?]
+linenumber = [15, BufferId?] returns number
+jump = [16, LineIndex, BufferId?]
+```
+
+### Append
+