mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-08 06:32:35 -04:00
Progress bar for Notepad IO (#1322)
This commit is contained in:
parent
0a3aa706ef
commit
411f6c0a34
3 changed files with 73 additions and 3 deletions
|
@ -341,7 +341,7 @@ static void show_save_prompt(
|
|||
std::function<void()> on_save,
|
||||
std::function<void()> continuation) {
|
||||
nav.display_modal(
|
||||
"Save?", "Save changes?", YESNO,
|
||||
"Save?", " Save changes?", YESNO,
|
||||
[on_save](bool choice) {
|
||||
if (choice && on_save)
|
||||
on_save();
|
||||
|
@ -474,7 +474,13 @@ void TextEditorView::open_file(const fs::path& path) {
|
|||
path_ = {};
|
||||
file_dirty_ = false;
|
||||
has_temp_file_ = false;
|
||||
auto result = FileWrapper::open(path);
|
||||
auto result = FileWrapper::open(
|
||||
path, false, [](uint32_t value, uint32_t total) {
|
||||
Painter p;
|
||||
auto percent = (value * 100) / total;
|
||||
auto width = (percent * screen_width) / 100;
|
||||
p.draw_hline({0, 16}, width, Color::yellow());
|
||||
});
|
||||
|
||||
if (!result) {
|
||||
nav_.display_modal("Read Error", "Cannot open file:\n" + result.error().what());
|
||||
|
@ -582,6 +588,10 @@ void TextEditorView::prepare_for_write() {
|
|||
if (has_temp_file_)
|
||||
return;
|
||||
|
||||
// TODO: This would be nice to have but it causes a stack overflow in an ISR?
|
||||
// Painter p;
|
||||
// p.draw_string({2, 48}, Styles::yellow, "Creating temporary file...");
|
||||
|
||||
// Copy to temp file on write.
|
||||
has_temp_file_ = true;
|
||||
delete_temp_file(path_);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue