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:
Kyle Reed
2023-06-01 15:45:55 -07:00
committed by GitHub
parent 69011754c9
commit 8d7fdeb633
11 changed files with 847 additions and 148 deletions

View File

@@ -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;