diff options
| author | Kirill Petrashin <kirill8201@yandex.ru> | 2026-04-05 15:11:16 +0300 |
|---|---|---|
| committer | Kirill Petrashin <kirill8201@yandex.ru> | 2026-04-05 15:11:16 +0300 |
| commit | 221797b2506bc54483042b8a7beb0aa016f4f8e6 (patch) | |
| tree | a3c13e3a512c5d52edc1f76236efe18b22c43f1b | |
| parent | 3800654c56fc598bffda5b93fbe9dc7f88896fc2 (diff) | |
| download | astar-221797b2506bc54483042b8a7beb0aa016f4f8e6.tar.xz | |
Prompt for filename when creating a BMP
| -rw-r--r-- | config.h | 2 | ||||
| -rw-r--r-- | main.c | 15 |
2 files changed, 14 insertions, 3 deletions
@@ -18,4 +18,6 @@ #define CURSOR_CHAR_1 '<' #define CURSOR_CHAR_2 '>' +#define FILENAME_BUF_SIZE 128 + #endif /*CONFIG_H_ */ @@ -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': |
