Major updates/cleanup.
This commit is contained in:
@@ -26,6 +26,7 @@ struct BEd {
|
||||
bool prompt_mode = true;
|
||||
std::function<std::string(BEd &)> prompt = nullptr;
|
||||
bool suppress_mode = false;
|
||||
bool color_mode = false;
|
||||
bool temporary_current = false;
|
||||
std::string last_help = "";
|
||||
std::string last_regex = "";
|
||||
|
||||
@@ -17,7 +17,6 @@ struct Token {
|
||||
RubyFunction,
|
||||
RubyArg,
|
||||
Function,
|
||||
Any,
|
||||
Shell,
|
||||
File,
|
||||
Suffix,
|
||||
|
||||
@@ -93,6 +93,9 @@ struct Parser {
|
||||
std::vector<io::Token> *tokens, CompletionContext *completion
|
||||
);
|
||||
|
||||
void token(io::Token::Kind);
|
||||
void end_token();
|
||||
|
||||
char peek(uint16_t = 0); // == \0 if at eof.
|
||||
std::string_view peek_str(uint16_t = UINT16_MAX);
|
||||
void advance(uint16_t = 1);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "decl.h"
|
||||
|
||||
namespace bed::internal::syntax {
|
||||
struct MiniParser {
|
||||
Language ⟨
|
||||
void *start_state;
|
||||
std::vector<std::pair<void *, std::vector<io::Token>>> lines;
|
||||
|
||||
explicit MiniParser(Language &lang, vase::Shard *vase, void *initial_state);
|
||||
~MiniParser();
|
||||
|
||||
MiniParser(const MiniParser &) = delete;
|
||||
MiniParser &operator=(const MiniParser &) = delete;
|
||||
|
||||
void dirty(vase::Shard *vase, uint64_t start, uint64_t count);
|
||||
void insert(vase::Shard *vase, uint64_t start, uint64_t count);
|
||||
void erase(vase::Shard *vase, uint64_t start, uint64_t count);
|
||||
};
|
||||
} // namespace bed::internal::syntax
|
||||
@@ -1,23 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include "definitions.h"
|
||||
#include "internal/syntax/miniparser.h"
|
||||
#include "pch.h"
|
||||
|
||||
namespace bed::internal::ui {
|
||||
namespace bed::internal::ui::text_mode {
|
||||
struct TextMode {
|
||||
std::string cmd;
|
||||
uint16_t cursor;
|
||||
struct Row {
|
||||
uint64_t start;
|
||||
uint64_t length;
|
||||
};
|
||||
using Lines = std::vector<Row>;
|
||||
vase::Shard *vase;
|
||||
vase::Point cursor;
|
||||
std::optional<syntax::MiniParser> parser;
|
||||
std::vector<Lines> lines;
|
||||
uint16_t start;
|
||||
uint16_t height;
|
||||
uint16_t term_height;
|
||||
uint16_t term_width;
|
||||
BEd &bed;
|
||||
|
||||
TextMode(BEd &);
|
||||
TextMode(BEd &, vase::Shard *, syntax::Language *, void *);
|
||||
std::pair<vase::Shard *, bool> run();
|
||||
std::pair<vase::Shard *, bool> run_pipe();
|
||||
std::pair<vase::Shard *, bool> run_terminal();
|
||||
void grow();
|
||||
void redraw();
|
||||
void layout_lines();
|
||||
};
|
||||
} // namespace bed::internal::ui
|
||||
} // namespace bed::internal::ui::text_mode
|
||||
|
||||
@@ -41,7 +41,7 @@ struct ReplacePart {
|
||||
|
||||
uint64_t offset_of(Shard *root, uint64_t line);
|
||||
uint64_t offset_of(Shard *root, Point point);
|
||||
Point point_of(Shard *root, uint64_t offset);
|
||||
Point eof_point(Shard *root);
|
||||
|
||||
std::string to_string(Shard *root);
|
||||
std::string to_string(Shard *root, Range range);
|
||||
|
||||
Reference in New Issue
Block a user