Compare commits

..

2 Commits

View File

@@ -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;
}
@@ -113,7 +113,7 @@ int main(int argc, char** argv) {
return -10;
}
while (num_of_chars > 1) {
while (num_of_chars > 0) {
buffer_left(buffer);
num_of_chars--;
}
@@ -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++;
}