diff --git a/ce/edit.c b/ce/edit.c index dc63df5..29ce089 100644 --- a/ce/edit.c +++ b/ce/edit.c @@ -23,6 +23,8 @@ #define STATUS_LINE_STYLE ANSIQ_GR_SEQ (ANSIQ_BG_RGB (240, 191, 88) ANSIQ_FG_BLACK) +#define TAB_INSERT " " + struct edit_line { struct list_node_link lines_link; struct gapbuffer gb; @@ -229,6 +231,13 @@ void edit_start (const char* file_path, const char* text) { gapbuffer_backspace (&editor.current_line->gb); } break; + case '\t': + gapbuffer_move (&editor.current_line->gb, editor.cursor.col); + for (size_t i = 0; i < sizeof (TAB_INSERT) - 1; i++) + gapbuffer_insert (&wrealloc, NULL, &editor.current_line->gb, TAB_INSERT[i]); + + editor.cursor.col += sizeof (TAB_INSERT) - 1; + break; case '\n': { gapbuffer_move (&editor.current_line->gb, editor.cursor.col);