diff --git a/ce/edit.c b/ce/edit.c index 7f61f7d..b60a491 100644 --- a/ce/edit.c +++ b/ce/edit.c @@ -77,9 +77,10 @@ static void update_vert_scroll (size_t screen_rows) { editor.row_offset = editor.cursor.line - (screen_rows - 1) + 1; } -void edit_start (const char* text) { +void edit_start (const char* file_path, const char* text) { prepare_lines (text); struct arena temp_arena; + memset (&temp_arena, 0, sizeof (temp_arena)); size_t cols, rows; terminal_dimensions (&cols, &rows); @@ -145,6 +146,15 @@ void edit_start (const char* text) { current_idx++; } + w = snprintf (bbptr, bb_remaining, ANSIQ_DYN_CUR_SET ANSIQ_SCR_CLR_LINE, (int)rows, 1); + bbptr += w; + bb_remaining -= w; + + w = snprintf (bbptr, bb_remaining, "Editing %s; line %zu col %zu", file_path, + editor.cursor.line, editor.cursor.col); + bbptr += w; + bb_remaining -= w; + w = snprintf (bbptr, bb_remaining, ANSIQ_DYN_CUR_SET ANSIQ_CUR_VISIBLE, (int)(editor.cursor.line - editor.row_offset) + 1, (int)(editor.cursor.col - editor.col_offset) + 1); diff --git a/ce/edit.h b/ce/edit.h index e9b7c06..15df3ce 100644 --- a/ce/edit.h +++ b/ce/edit.h @@ -1,6 +1,6 @@ #ifndef _EDIT_H #define _EDIT_H -void edit_start (const char* text); +void edit_start (const char* path, const char* text); #endif // _EDIT_H diff --git a/ce/interp.c b/ce/interp.c index 710870a..a499b85 100644 --- a/ce/interp.c +++ b/ce/interp.c @@ -235,7 +235,7 @@ static void edit (struct context* context, const char* path_string) { return; } - edit_start (str); + edit_start (path_string, str); volume_close (); } diff --git a/libterminal/tscreen.h b/libterminal/tscreen.h index 31a24d0..f2b5ce5 100644 --- a/libterminal/tscreen.h +++ b/libterminal/tscreen.h @@ -9,7 +9,7 @@ #define ANSIQ_SCR_CLR_SAV ANSIQ_ESC"[3J" // Clear saved lines #define ANSIQ_SCR_CLR2LEND ANSIQ_ESC"[0K" // Clear to end of line #define ANSIQ_SCR_CLR2LBEG ANSIQ_ESC"[1K" // Clear to begining of line -#define ANSIQ_SCR_CLR_LINE ANSIQ_ESC"[1K" // Clear entire line +#define ANSIQ_SCR_CLR_LINE ANSIQ_ESC"[2K" // Clear entire line #define ANSIQ_SCR_RESTORE ANSIQ_ESC"[?47l" #define ANSIQ_SCR_SAVE ANSIQ_ESC"[?47h" /* clang-format on */