Archos
unread,Jun 4, 2013, 5:28:49 AM6/4/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com
I'm implementing a gap buffer since it looks the better way to edit a line; it is not to be used into a editor else for the command line.
The next printing shows how is working now, where '*' indicates data set to zero and |__| is the gap (the space to use when data is inserted).
The gap slice is moved when the cursor is between data (no home neither end of line) since the user could inset data just there.
// []rune with len=32
Cursor: 0 · Gap start: 15 · Gap end: 31 [***************|_______________|]
// data entered: 0-9 so the cursor is in position 10.
Cursor: 10 · Gap start: 15 · Gap end: 31 [0123456789*****|_______________|]
// I'm moving the cursor one character to left, until after of character 4; like you can see all data
// after of the cursor is moved after of the gap.
Cursor: 9 · Gap start: 14 · Gap end: 30 [012345678*****|_______________|9]
Cursor: 8 · Gap start: 13 · Gap end: 29 [01234567*****|_______________|89]
Cursor: 7 · Gap start: 12 · Gap end: 28 [0123456*****|_______________|789]
Cursor: 6 · Gap start: 11 · Gap end: 27 [012345*****|_______________|6789]
Cursor: 5 · Gap start: 10 · Gap end: 26 [01234*****|_______________|56789]
My question is: When the gap is moved, those data to zero (*),
(a) should be moved at the end of the buffer,
[01234|_______________|56789*****]
(b) after of the gap,
[01234|_______________|*****56789]
(c) or is right like it is now?
* I was thinking that other option could be to use 2 buffers, one to insert data linearly (when cursor is outside of home or end of line) and the other one when data is inserted which would be inserted in the first buffer when the cursor is moved or at pressing enter.