diff --git a/final/binary b/final/binary index c5a21f5..72a7733 100755 Binary files a/final/binary and b/final/binary differ diff --git a/final/editor.c b/final/editor.c index 2b438b1..5f782d7 100644 --- a/final/editor.c +++ b/final/editor.c @@ -72,10 +72,20 @@ void delchar(Editor* self) { delch(); } +void pressed_enter(Editor* self) { + move_cursor(self, 1, 0); +} + void addchar(Editor* self, char c) { - insch(c); - // insert the character into the string at the given index if (self->screen_line == self->lines) { + move(self->screen_line, 0); + char line_no[5]; + snprintf(line_no, 5, "%-5d", self->screen_line + 1); + // adding the line of text to the buffer + addstr(line_no); + addch(' '); + move(self->screen_line, self->screen_col + 5); + fprintf(stderr, "buffer full\n"); // reallocate self->buffer to be 1 larger self->lines++; @@ -90,6 +100,8 @@ void addchar(Editor* self, char c) { fprintf(stderr, "ok!"); } + insch(c); + // insert the character into the string at the given index str_insert(&self->buffer[self->screen_line], self->screen_col, c); move_cursor(self, 1, 0); } diff --git a/final/editor.h b/final/editor.h index 727bceb..fadee90 100644 --- a/final/editor.h +++ b/final/editor.h @@ -16,5 +16,6 @@ Editor editor_from(char* input_string); void move_cursor(Editor* self, int x, int y); void delchar(Editor* self); void addchar(Editor* self, char c); +void pressed_enter(Editor* self); String_t* to_string(Editor* self); diff --git a/final/main.c b/final/main.c index 9036838..2894162 100644 --- a/final/main.c +++ b/final/main.c @@ -41,6 +41,8 @@ int open_editor() { delchar(&editor); break; case KEY_ENTER: + //pressed_enter(&editor); + move_cursor(&editor, 1, 0); //TODO: next line break; case KEY_UP: