[Toybox] [PATCH] vi: Replace linelist with mem_block based design

Jarno Mäkipää jmakip87 at gmail.com
Thu Jan 16 05:58:38 PST 2020


Replaced dlist linelist with continuous memory blocks. This will allow
editing huge files without billion mallocs. File is first opened with
mmap() and mapped region is fully described in block_list as one block.

Currently "valid" data is described as slices, when first loading file
there is only one slice that points to memory existing in block_list.
When cutting text, block_list is not freed or modified, but instead
slice_list is modified to have "hole" between 2 slices. when inserting
new mem_block is added, previos slices are cut in cursor position and
new slice is added...

Implementation is not as finished as old linelist, but most of the heavy
lifting is done so wanted to share this at this state.

Added functions to handling data inside block_list+slice_list

insert_str(), cut_str() are used for all delete and add operations
text_strrchr(), text_strchr() are used for searching lineendings
text_byte(), text_codepoint(), text_getline() are for simple data access

Implemented: yank,delete,insert,push and most of the previos moves

Implemented partly: saving of file, since current file is still mmaped
cant save on top of it, so now saves into "filename".swp, later need
to move .swp into original file after munmap

Not Implemented: search, linenumber counting, etc..

Removed: Some unused functions

br

-Jarno

---
 toys/pending/vi.c | 1237 +++++++++++++++++++++++++--------------------
 1 file changed, 692 insertions(+), 545 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-vi-Replace-linelist-with-mem_block-based-design.patch
Type: text/x-patch
Size: 49257 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20200116/27e3d7b7/attachment-0001.bin>


More information about the Toybox mailing list