Fix io system and highlighting.
This commit is contained in:
+3
-2
@@ -19,7 +19,7 @@ struct BEd {
|
||||
std::array<std::optional<internal::functions::Suffix>, 26> suffixes;
|
||||
internal::theme::Theme theme;
|
||||
std::unordered_map<std::string, internal::syntax::Language *> languages;
|
||||
internal::io::IO &io;
|
||||
internal::io::IO io;
|
||||
internal::vase::AppendStorage append{"/tmp"};
|
||||
|
||||
bool help_mode = false;
|
||||
@@ -39,7 +39,7 @@ struct BEd {
|
||||
internal::buffer::Range prev_2;
|
||||
internal::marks::MarksEngine marks;
|
||||
|
||||
BEd(std::vector<std::string> args, internal::io::IO &io);
|
||||
BEd(std::vector<std::string> args);
|
||||
~BEd();
|
||||
|
||||
internal::buffer::Buffer &buffer(const std::string &);
|
||||
@@ -47,6 +47,7 @@ struct BEd {
|
||||
internal::buffer::Range &prev();
|
||||
void mark(uint8_t, internal::buffer::Line);
|
||||
|
||||
void print_help();
|
||||
void handle(std::string_view cmd, bool eof);
|
||||
void run();
|
||||
void suffix_handle(char s);
|
||||
|
||||
@@ -15,17 +15,4 @@ struct fatal_error : std::runtime_error {
|
||||
struct ed_error : std::runtime_error {
|
||||
ed_error(std::string msg) : std::runtime_error(msg) {}
|
||||
};
|
||||
|
||||
struct Highlight {
|
||||
enum : uint8_t {
|
||||
None = 0,
|
||||
Bold = 1 << 0,
|
||||
Italic = 1 << 1,
|
||||
Strikethrough = 1 << 2,
|
||||
Underline = 1 << 3,
|
||||
};
|
||||
uint32_t fg;
|
||||
uint32_t bg;
|
||||
uint8_t flags;
|
||||
};
|
||||
} // namespace bed
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "definitions.h"
|
||||
#include "pch.h"
|
||||
#include "tokens.h"
|
||||
|
||||
namespace bed::internal::io {
|
||||
struct KeyEvent {
|
||||
@@ -57,6 +58,7 @@ struct IO {
|
||||
static void enable_raw();
|
||||
static volatile std::atomic_bool resized;
|
||||
static void handle_sigwinch(int);
|
||||
BEd &bed;
|
||||
|
||||
static enum struct Mode {
|
||||
PIPE,
|
||||
@@ -66,7 +68,7 @@ struct IO {
|
||||
std::string pipe_input;
|
||||
std::deque<char> input_queue;
|
||||
|
||||
IO();
|
||||
IO(BEd &);
|
||||
~IO();
|
||||
|
||||
IO(const IO &) = delete;
|
||||
@@ -75,6 +77,8 @@ struct IO {
|
||||
bool interactive() const {
|
||||
return mode == Mode::TERMINAL;
|
||||
}
|
||||
void apply(const io::Token::Kind &t);
|
||||
void reset();
|
||||
void enable_mouse();
|
||||
void disable_mouse();
|
||||
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
#pragma once
|
||||
|
||||
#include "definitions.h"
|
||||
#include "pch.h"
|
||||
|
||||
namespace bed::internal::io {
|
||||
struct Token {
|
||||
uint32_t start;
|
||||
uint32_t end;
|
||||
enum Kind : uint8_t {
|
||||
TempCurrent,
|
||||
AddressSeperator,
|
||||
Address,
|
||||
Offset,
|
||||
AddressRegex,
|
||||
AddressSymbol,
|
||||
Number,
|
||||
Mark,
|
||||
RubyFunction,
|
||||
RubyArg,
|
||||
Function,
|
||||
Any,
|
||||
Shell,
|
||||
Ruby,
|
||||
File,
|
||||
Regex,
|
||||
Replacement,
|
||||
Suffix,
|
||||
Color1,
|
||||
Color2,
|
||||
Color3,
|
||||
Color4,
|
||||
Color5,
|
||||
Warning,
|
||||
Data,
|
||||
Shebang,
|
||||
Comment,
|
||||
Error,
|
||||
String,
|
||||
Escape,
|
||||
Interpolation,
|
||||
Regexp,
|
||||
True,
|
||||
False,
|
||||
Char,
|
||||
Keyword,
|
||||
KeywordOperator,
|
||||
Operator,
|
||||
Namespace,
|
||||
Class,
|
||||
Module,
|
||||
Type,
|
||||
Constant,
|
||||
VariableInstance,
|
||||
VariableGlobal,
|
||||
Annotation,
|
||||
Directive,
|
||||
Label,
|
||||
Brace1,
|
||||
Brace2,
|
||||
Brace3,
|
||||
Brace4,
|
||||
Brace5,
|
||||
Heading1,
|
||||
Heading2,
|
||||
Heading3,
|
||||
Heading4,
|
||||
Heading5,
|
||||
Heading6,
|
||||
Blockquote,
|
||||
List,
|
||||
ListItem,
|
||||
Code,
|
||||
LanguageName,
|
||||
LinkLabel,
|
||||
ImageLabel,
|
||||
Link,
|
||||
Table,
|
||||
TableHeader,
|
||||
Italic,
|
||||
Bold,
|
||||
Underline,
|
||||
Strikethrough,
|
||||
HorizontalRule,
|
||||
Tag,
|
||||
Attribute,
|
||||
CheckDone,
|
||||
CheckNotDone,
|
||||
Count
|
||||
} type;
|
||||
};
|
||||
|
||||
struct Highlight {
|
||||
enum : uint8_t {
|
||||
None = 0,
|
||||
Bold = 1 << 0,
|
||||
Italic = 1 << 1,
|
||||
Strikethrough = 1 << 2,
|
||||
Underline = 1 << 3,
|
||||
};
|
||||
uint32_t fg;
|
||||
uint32_t bg;
|
||||
uint8_t flags;
|
||||
};
|
||||
} // namespace bed::internal::io
|
||||
@@ -1,74 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "internal/io/tokens.h"
|
||||
#include "internal/trie/trie.h"
|
||||
#include "internal/vase/vase.h"
|
||||
#include "pch.h"
|
||||
|
||||
namespace bed::internal::syntax {
|
||||
struct Token {
|
||||
uint32_t start;
|
||||
uint32_t end;
|
||||
enum Kind : uint8_t {
|
||||
Data,
|
||||
Shebang,
|
||||
Comment,
|
||||
Error,
|
||||
String,
|
||||
Escape,
|
||||
Interpolation,
|
||||
Regexp,
|
||||
Number,
|
||||
True,
|
||||
False,
|
||||
Char,
|
||||
Keyword,
|
||||
KeywordOperator,
|
||||
Operator,
|
||||
Function,
|
||||
Namespace,
|
||||
Class,
|
||||
Module,
|
||||
Type,
|
||||
Constant,
|
||||
VariableInstance,
|
||||
VariableGlobal,
|
||||
Annotation,
|
||||
Directive,
|
||||
Label,
|
||||
Brace1,
|
||||
Brace2,
|
||||
Brace3,
|
||||
Brace4,
|
||||
Brace5,
|
||||
Heading1,
|
||||
Heading2,
|
||||
Heading3,
|
||||
Heading4,
|
||||
Heading5,
|
||||
Heading6,
|
||||
Blockquote,
|
||||
List,
|
||||
ListItem,
|
||||
Code,
|
||||
LanguageName,
|
||||
LinkLabel,
|
||||
ImageLabel,
|
||||
Link,
|
||||
Table,
|
||||
TableHeader,
|
||||
Italic,
|
||||
Bold,
|
||||
Underline,
|
||||
Strikethrough,
|
||||
HorizontalRule,
|
||||
Tag,
|
||||
Attribute,
|
||||
CheckDone,
|
||||
CheckNotDone,
|
||||
Count
|
||||
} type;
|
||||
};
|
||||
|
||||
struct ParseEvent {
|
||||
uint8_t closing;
|
||||
ParseEvent(uint8_t t) : closing(t) {}
|
||||
@@ -78,7 +15,7 @@ struct Language {
|
||||
std::function<void *()> none_state;
|
||||
std::function<void(
|
||||
void **, std::string_view,
|
||||
bool, std::vector<Token> *, std::vector<ParseEvent> *
|
||||
bool, std::vector<io::Token> *, std::vector<ParseEvent> *
|
||||
)>
|
||||
parse;
|
||||
std::function<void *(void *)> copy;
|
||||
|
||||
@@ -21,7 +21,7 @@ struct Iterator {
|
||||
std::optional<vase::Iterator> it;
|
||||
void *state;
|
||||
uint64_t at;
|
||||
std::vector<Token> tokens;
|
||||
std::vector<io::Token> tokens;
|
||||
std::vector<ParseEvent> events;
|
||||
Iterator(uint64_t, ParserSnapshot, vase::Shard *);
|
||||
~Iterator();
|
||||
|
||||
@@ -104,6 +104,6 @@ struct RubyParser {
|
||||
|
||||
void ruby_parse(
|
||||
void **v_state, std::string_view line, bool first_line,
|
||||
std::vector<Token> *tokens, std::vector<ParseEvent> *events
|
||||
std::vector<io::Token> *tokens, std::vector<ParseEvent> *events
|
||||
);
|
||||
} // namespace bed::internal::syntax::ruby
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
namespace bed::internal::theme {
|
||||
struct Theme {
|
||||
std::array<Highlight, internal::syntax::Token::Count> hl;
|
||||
std::array<io::Highlight, io::Token::Count> hl;
|
||||
|
||||
Theme();
|
||||
|
||||
Highlight get(internal::syntax::Token token) const;
|
||||
io::Highlight get(const io::Token::Kind &token) const;
|
||||
|
||||
static Theme default_theme();
|
||||
static Theme from_name(std::string_view name);
|
||||
|
||||
Reference in New Issue
Block a user