diff --git a/src/editor.c b/src/editor.c index d857631..c644956 100644 --- a/src/editor.c +++ b/src/editor.c @@ -126,6 +126,17 @@ void editor_move_char_right(Editor *e) if (e->cursor < e->data.count) e->cursor += 1; } +void editor_move_char_begin(Editor *e) +{ + size_t cursor_row = editor_cursor_row(e); + e->cursor = e->lines.items[cursor_row].begin; +} +void editor_move_char_end(Editor *e) +{ + size_t cursor_row = editor_cursor_row(e); + e->cursor = e->lines.items[cursor_row].end; +} + void editor_insert_char(Editor *e, char x) { if (e->cursor > e->data.count) { diff --git a/src/editor.h b/src/editor.h index d39387a..0673f32 100644 --- a/src/editor.h +++ b/src/editor.h @@ -49,6 +49,8 @@ void editor_move_line_up(Editor *e); void editor_move_line_down(Editor *e); void editor_move_char_left(Editor *e); void editor_move_char_right(Editor *e); +void editor_move_char_begin(Editor *e); +void editor_move_char_end(Editor *e); void editor_insert_char(Editor *e, char x); void editor_recompute_lines(Editor *e); diff --git a/src/main.c b/src/main.c index 592da28..9a1cf3b 100644 --- a/src/main.c +++ b/src/main.c @@ -333,6 +333,34 @@ int main(int argc, char **argv) } break; + + case SDLK_HOME: { + editor_move_char_begin(&editor); + cursor_renderer_use(&cr); + glUniform1f(cr.uniforms[UNIFORM_SLOT_LAST_STROKE], (float) SDL_GetTicks() / 1000.0f); + + } + break; + + case SDLK_END: { + editor_move_char_end(&editor); + cursor_renderer_use(&cr); + glUniform1f(cr.uniforms[UNIFORM_SLOT_LAST_STROKE], (float) SDL_GetTicks() / 1000.0f); + + } + break; + + case SDLK_TAB: { + const char *text = " "; + size_t text_len = strlen(text); + for (size_t i = 0; i < text_len; ++i) { + editor_insert_char(&editor, text[i]); + } + cursor_renderer_use(&cr); + glUniform1f(cr.uniforms[UNIFORM_SLOT_LAST_STROKE], (float) SDL_GetTicks() / 1000.0f); + } + break; + } } break;