Lots of updates:

1. Scrolling and click to set the cursor works.
2. GUI now uses Brass Mono as the font.
3. A lot of stability and other updates.
This commit is contained in:
2025-11-29 20:22:24 -08:00
parent 932bc3c504
commit 57bfab633d
56 changed files with 10897 additions and 1522 deletions

200
Editor.h
View File

@@ -11,6 +11,7 @@
#include "Buffer.h"
class Editor {
public:
Editor();
@@ -116,6 +117,189 @@ public:
}
// --- Minimal search state for incremental search (milestone 6) ---
void SetSearchActive(bool on)
{
search_active_ = on;
}
[[nodiscard]] bool SearchActive() const
{
return search_active_;
}
void SetSearchQuery(const std::string &q)
{
search_query_ = q;
}
[[nodiscard]] const std::string &SearchQuery() const
{
return search_query_;
}
void SetSearchMatch(std::size_t y, std::size_t x, std::size_t len)
{
search_y_ = y;
search_x_ = x;
search_len_ = len;
}
[[nodiscard]] std::size_t SearchMatchY() const
{
return search_y_;
}
[[nodiscard]] std::size_t SearchMatchX() const
{
return search_x_;
}
[[nodiscard]] std::size_t SearchMatchLen() const
{
return search_len_;
}
// Additional helpers for search session bookkeeping
void SetSearchOrigin(std::size_t x, std::size_t y, std::size_t rowoffs, std::size_t coloffs)
{
search_origin_set_ = true;
search_orig_x_ = x;
search_orig_y_ = y;
search_orig_rowoffs_ = rowoffs;
search_orig_coloffs_ = coloffs;
}
void ClearSearchOrigin()
{
search_origin_set_ = false;
search_orig_x_ = search_orig_y_ = search_orig_rowoffs_ = search_orig_coloffs_ = 0;
}
[[nodiscard]] bool SearchOriginSet() const
{
return search_origin_set_;
}
[[nodiscard]] std::size_t SearchOrigX() const
{
return search_orig_x_;
}
[[nodiscard]] std::size_t SearchOrigY() const
{
return search_orig_y_;
}
[[nodiscard]] std::size_t SearchOrigRowoffs() const
{
return search_orig_rowoffs_;
}
[[nodiscard]] std::size_t SearchOrigColoffs() const
{
return search_orig_coloffs_;
}
void SetSearchIndex(int i)
{
search_index_ = i;
}
[[nodiscard]] int SearchIndex() const
{
return search_index_;
}
// --- Generic Prompt subsystem (for search, open-file, save-as, etc.) ---
enum class PromptKind { None = 0, Search, OpenFile, SaveAs, Confirm };
void StartPrompt(PromptKind kind, const std::string &label, const std::string &initial)
{
prompt_active_ = true;
prompt_kind_ = kind;
prompt_label_ = label;
prompt_text_ = initial;
}
void CancelPrompt()
{
prompt_active_ = false;
prompt_kind_ = PromptKind::None;
prompt_label_.clear();
prompt_text_.clear();
}
void AcceptPrompt()
{
// Editor-level accept only ends prompt; commands act on value.
prompt_active_ = false;
}
void SetPromptText(const std::string &t)
{
prompt_text_ = t;
}
void AppendPromptText(const std::string &t)
{
prompt_text_ += t;
}
void BackspacePromptText()
{
if (!prompt_text_.empty())
prompt_text_.pop_back();
}
[[nodiscard]] bool PromptActive() const
{
return prompt_active_;
}
[[nodiscard]] PromptKind CurrentPromptKind() const
{
return prompt_kind_;
}
[[nodiscard]] const std::string &PromptLabel() const
{
return prompt_label_;
}
[[nodiscard]] const std::string &PromptText() const
{
return prompt_text_;
}
// Buffers
[[nodiscard]] std::size_t BufferCount() const
{
@@ -172,6 +356,22 @@ private:
std::vector<Buffer> buffers_;
std::size_t curbuf_ = 0; // index into buffers_
// Search state
bool search_active_ = false;
std::string search_query_;
std::size_t search_y_ = 0, search_x_ = 0, search_len_ = 0;
// Search session bookkeeping
bool search_origin_set_ = false;
std::size_t search_orig_x_ = 0, search_orig_y_ = 0;
std::size_t search_orig_rowoffs_ = 0, search_orig_coloffs_ = 0;
int search_index_ = -1;
// Prompt state
bool prompt_active_ = false;
PromptKind prompt_kind_ = PromptKind::None;
std::string prompt_label_;
std::string prompt_text_;
};
#endif // KTE_EDITOR_H