Fixed a bug with moving the cursor to the start of the text, and fixed a bug where the grow method would cause weird anamolies
This commit is contained in:
9
editor.c
9
editor.c
@@ -38,7 +38,7 @@ void buffer_grow(Buffer* buffer) {
|
||||
buffer->start = buffer->text + start_offset;
|
||||
|
||||
buffer->gap_size = 10;
|
||||
for (int i=0; i < (old_size - start_offset); i++) {
|
||||
for (int i= (old_size - start_offset) - 1; i >= 0; i--) {
|
||||
*(buffer->start + i + buffer->gap_size) = *(buffer->start + i);
|
||||
*(buffer->start + i) = 0;
|
||||
}
|
||||
@@ -133,13 +133,16 @@ int main(int argc, char** argv) {
|
||||
gap starts at the first index of the string, and continues till the end */
|
||||
|
||||
while (i < buffer->size) {
|
||||
addch(*(buffer->text + i));
|
||||
i++;
|
||||
if ((buffer->start - buffer->text) == i) { /* If we have encountered
|
||||
the start of the gap */
|
||||
getyx(stdscr,y,x);
|
||||
i += buffer->gap_size;
|
||||
}
|
||||
if (i >= buffer->size) {
|
||||
break;
|
||||
}
|
||||
addch(*(buffer->text + i));
|
||||
i++;
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user