Fix buffer stomping; retool Makefile.
The Makefile is now useful for building ke(1) to aid in more rapid development. This works because ke doesn't (yet) need any special non-system libraries.
This commit is contained in:
45
Buffer.h
45
Buffer.h
@@ -35,28 +35,38 @@ public:
|
||||
enum class FileStatus : uint8_t {
|
||||
/// The file operation succeeded correctly.
|
||||
FileStatusOK = 0,
|
||||
|
||||
/// There was an error, but it wasn't handled correctly.
|
||||
/// This is mostly for debugging purposes, and shouldn't
|
||||
/// be seen by users.
|
||||
///
|
||||
/// \detail This is set at the beginning of failable
|
||||
/// operations, and indicates that the right
|
||||
/// status wasn't set correctly.
|
||||
FileStatusUnspecifiedError = 1,
|
||||
|
||||
/// The file can't be written to because it is marked
|
||||
/// read-only. This refers to a buffer being marked as
|
||||
/// read-only, not to whether the underlying file is
|
||||
/// actually read-only.
|
||||
FileStatusReadOnly = 1,
|
||||
FileStatusReadOnly = 2,
|
||||
|
||||
/// There was an I/O error trying to write to the file.
|
||||
FileStatusIOFailed = 2,
|
||||
FileStatusIOFailed = 3,
|
||||
|
||||
/// The Buffer couldn't be flushed because it is a virtual
|
||||
/// buffer. If the user explicitly tried to save the buffer,
|
||||
/// they should be prompted for a path.
|
||||
FileStatusVirtual = 3,
|
||||
FileStatusVirtual = 4,
|
||||
|
||||
/// The underlying file doesn't have the right permissions;
|
||||
/// for example, it's not writeable if the user is trying to
|
||||
/// write the file.
|
||||
FileStatusInvalidPermissions = 4,
|
||||
FileStatusInvalidPermissions = 5,
|
||||
|
||||
/// The underlying file doesn't exist.
|
||||
FileStatusNonExistent = 5,
|
||||
FileStatusNonExistent = 6,
|
||||
|
||||
};
|
||||
|
||||
static std::string FileStatusToString(FileStatus status);
|
||||
@@ -100,7 +110,7 @@ public:
|
||||
|
||||
void ChangePath(std::string newPath);
|
||||
|
||||
Cursor Cursor()
|
||||
Cursor Where()
|
||||
{ return this->cursor; }
|
||||
|
||||
void MarkDirty();
|
||||
@@ -109,16 +119,25 @@ public:
|
||||
|
||||
size_t Size();
|
||||
|
||||
/// Does this buffer have a current, on-disk file?
|
||||
///
|
||||
/// \return True if this is a file buffer with an extant source
|
||||
/// file.
|
||||
bool Exists();
|
||||
|
||||
/// PrintBufferStatus is a debug tool to capture the current
|
||||
/// buffer state.
|
||||
void PrintBufferStatus(std::ostream &os);
|
||||
private:
|
||||
void clearContents();
|
||||
|
||||
class Cursor cursor;
|
||||
|
||||
bool dirty;
|
||||
std::string name;
|
||||
OptString path;
|
||||
OptFile file;
|
||||
BufferContents contents;
|
||||
Cursor cursor;
|
||||
bool dirty;
|
||||
std::string name;
|
||||
OptString path;
|
||||
OptFile file;
|
||||
BufferContents contents;
|
||||
FileStatus status;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user