From 37d73f63e3ece0297352e6e1a3dee74cf4697ca3 Mon Sep 17 00:00:00 2001 From: kamkow1 Date: Sat, 7 Mar 2026 00:35:39 +0100 Subject: [PATCH] CE edit handle tab key --- ce/edit.c | 9 +++++++++ 1 file changed, 9 insertions(+) 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);