From 221797b2506bc54483042b8a7beb0aa016f4f8e6 Mon Sep 17 00:00:00 2001 From: Kirill Petrashin Date: Sun, 5 Apr 2026 15:11:16 +0300 Subject: Prompt for filename when creating a BMP --- main.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 7e74c58..ef99997 100644 --- a/main.c +++ b/main.c @@ -179,9 +179,18 @@ int main(int argc, char **argv) { } break; case 's': - /* TODO: prompt for filename? or do a define idk */ - map_to_bmp(map, width, height, start_pos, end_pos, path, visited, "out.bmp"); - mvprintw(height + map_offset_y + 1, map_offset_x - 2, "Saved to out.bmp"); /* FIXME: clear the line first */ + move(height + map_offset_y + 1, map_offset_x - 2); clrtoeol(); /* Clears the line */ + mvprintw(height + map_offset_y + 1, map_offset_x - 2, "Filename: "); + /* TODO: figure out how to show the cursor and echo the characters */ + curs_set(2); /* Hide the cursor */ + echo(); /* Don't echo characters */ + char filename[FILENAME_BUF_SIZE] = "out.bmp"; + curs_set(0); /* Hide the cursor */ + noecho(); /* Don't echo characters */ + mvgetnstr(height + map_offset_y + 1, map_offset_x - 2, filename, FILENAME_BUF_SIZE - 1); + map_to_bmp(map, width, height, start_pos, end_pos, path, visited, filename); + move(height + map_offset_y + 1, map_offset_x - 2); clrtoeol(); /* Clears the line */ + mvprintw(height + map_offset_y + 1, map_offset_x - 2, "Saved to %s", filename); getch(); break; case 'n': -- cgit v1.2.3