summaryrefslogtreecommitdiff
path: root/par/piece-table.scm
diff options
context:
space:
mode:
Diffstat (limited to 'par/piece-table.scm')
-rw-r--r--par/piece-table.scm57
1 files changed, 57 insertions, 0 deletions
diff --git a/par/piece-table.scm b/par/piece-table.scm
new file mode 100644
index 0000000..d6a3c4e
--- /dev/null
+++ b/par/piece-table.scm
@@ -0,0 +1,57 @@
+;; Pieces themselves: the buffer is a reference to the buffer they take their
+;; data from.
+;; Start and end are numbers.
+;; The type defines how they should be rendered, it makes
+;; possible to account for hyperlinks or stuff like that in the future with
+;; ease.
+(define-record-type <piece>
+ (make-piece buffer start length type)
+ piece?
+ (buffer piece-buffer set-piece-buffer!)
+ (start piece-start set-piece-start!)
+ (length piece-length set-piece-length!)
+ (type piece-type set-piece-type!))
+
+
+
+;; The piece table itself;
+;; original and add are strings and pieces is a list of pieces
+(define-record-type <piece-table>
+ (make-piece-table original add pieces)
+ piece-table?
+ (original piece-table-original set-piece-table-original!)
+ (add piece-table-add set-piece-table-add!)
+ (pieces piece-table-pieces set-piece-table-pieces!))
+
+(define (add-piece-table-piece! piece-table piece)
+ (cons piece (piece-table-pieces piece-table)))
+
+
+(define (piece-table-index piece-table pos)
+ #f)
+
+(define (piece-table-insert! piece-table pos char)
+ #f)
+
+(define (piece-table-delete! piece-table pos)
+ #f)
+
+
+
+;; Serialization - Deserialization
+(define (piece-table-write port)
+ "Write a piece table to port"
+ #f)
+(define (piece-table-read port)
+ "Read a piece table stored in port"
+ #f)
+
+
+
+;; From/to string
+(define (string->piece-table string)
+ (make-piece-table string ""
+ (list (make-piece string 0 (string-length string) 'normal))))
+
+(define (piece-table->string piece-table)
+ #f)