mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-13 20:16:14 +00:00
Add edit support for Notepad (#1093)
* WIP file editing * WIP file editing * Add "on_pop" handler to navigation. * WIP Editing * WIP for draft * Fix mock and unit tests, support +newline at end. * Clean up Painter API and use string_view * Fix optional rvalue functions * Fix Result 'take' to be more standard * FileWrapper stack buffer reads * Grasping at straws * Nit * Move set_on_pop impl to cpp * Workaround "Open" when file not dirty. --------- Co-authored-by: kallanreed <kallanreed@outlook.com>
This commit is contained in:
@@ -320,13 +320,8 @@ class File {
|
||||
return value_;
|
||||
}
|
||||
|
||||
/* Allows value to be moved out of the Result. */
|
||||
T take() {
|
||||
if (is_error())
|
||||
return {};
|
||||
T temp;
|
||||
std::swap(temp, value_);
|
||||
return temp;
|
||||
T&& operator*() && {
|
||||
return std::move(value_);
|
||||
}
|
||||
|
||||
Error error() const {
|
||||
@@ -369,7 +364,7 @@ class File {
|
||||
File& operator=(const File&) = delete;
|
||||
|
||||
// TODO: Return Result<>.
|
||||
Optional<Error> open(const std::filesystem::path& filename);
|
||||
Optional<Error> open(const std::filesystem::path& filename, bool read_only = true);
|
||||
Optional<Error> append(const std::filesystem::path& filename);
|
||||
Optional<Error> create(const std::filesystem::path& filename);
|
||||
|
||||
@@ -377,6 +372,7 @@ class File {
|
||||
Result<Size> write(const void* data, Size bytes_to_write);
|
||||
|
||||
Result<Offset> seek(uint64_t Offset);
|
||||
Result<Offset> truncate();
|
||||
// Timestamp created_date() const;
|
||||
Size size() const;
|
||||
|
||||
|
Reference in New Issue
Block a user