Add marks and regex addressing systems
- Hook up parser to buffer edits. - Other minor fixes.
This commit is contained in:
@@ -41,17 +41,11 @@ struct Address {
|
||||
char m;
|
||||
};
|
||||
|
||||
struct RegexLine { // /re/ or ?re?
|
||||
struct Regex { // /re/ or ?re?
|
||||
internal::Direction dir;
|
||||
std::string re;
|
||||
};
|
||||
|
||||
// BEd Extended types of addressing.
|
||||
struct Regex { // &/re/ or &?re?
|
||||
internal::Direction dir; // returns next/previous line containing the regex
|
||||
std::string re; // (not only if it matches full line)
|
||||
};
|
||||
|
||||
struct Diagnostic { // #n# for diagnostic number n. (From lsp.)
|
||||
uint16_t n;
|
||||
};
|
||||
@@ -91,7 +85,6 @@ struct Address {
|
||||
Last,
|
||||
Number,
|
||||
Mark,
|
||||
RegexLine,
|
||||
Regex,
|
||||
Diagnostic,
|
||||
DiagnosticNext,
|
||||
|
||||
@@ -34,6 +34,7 @@ struct Buffer {
|
||||
void remove(uint64_t start_line, uint64_t end_line);
|
||||
void append(std::string text, uint64_t line);
|
||||
void print(BEd &ctx, uint64_t start_line, uint64_t end_line);
|
||||
void number_print(BEd &ctx, uint64_t start_line, uint64_t end_line);
|
||||
std::string list_string(std::string_view s);
|
||||
};
|
||||
} // namespace bed::internal::buffer
|
||||
|
||||
@@ -3,5 +3,55 @@
|
||||
#include "pch.h"
|
||||
|
||||
namespace bed::internal::marks {
|
||||
struct MarksEngine {};
|
||||
struct MarksEngine {
|
||||
uint64_t marks[1 << UINT8_WIDTH]{UINT64_MAX};
|
||||
|
||||
MarksEngine() {
|
||||
for (auto &m : marks)
|
||||
m = UINT64_MAX;
|
||||
}
|
||||
|
||||
uint64_t get(uint8_t m) {
|
||||
return marks[m];
|
||||
}
|
||||
|
||||
void set(uint8_t m, uint64_t line) {
|
||||
marks[m] = line;
|
||||
}
|
||||
|
||||
void insert(uint64_t start, uint64_t count) {
|
||||
for (uint16_t i = 0; i <= UINT8_MAX; ++i) {
|
||||
if (marks[i] == UINT64_MAX)
|
||||
continue;
|
||||
if (marks[i] >= start)
|
||||
marks[i] += count;
|
||||
}
|
||||
}
|
||||
|
||||
void erase(uint64_t start, uint64_t count) {
|
||||
for (uint16_t i = 0; i <= UINT8_MAX; ++i) {
|
||||
if (marks[i] == UINT64_MAX)
|
||||
continue;
|
||||
if (marks[i] >= start) {
|
||||
if (marks[i] < start + count)
|
||||
marks[i] = UINT64_MAX;
|
||||
else
|
||||
marks[i] -= count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void collapse(uint64_t start, uint64_t count) {
|
||||
for (uint16_t i = 0; i <= UINT8_MAX; ++i) {
|
||||
if (marks[i] == UINT64_MAX)
|
||||
continue;
|
||||
if (marks[i] >= start) {
|
||||
if (marks[i] < start + count)
|
||||
marks[i] = start;
|
||||
else
|
||||
marks[i] -= count;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace bed::internal::marks
|
||||
|
||||
@@ -69,17 +69,8 @@ struct Token {
|
||||
};
|
||||
|
||||
struct ParseEvent {
|
||||
std::string_view name;
|
||||
enum T : uint8_t {
|
||||
Opening,
|
||||
Closing,
|
||||
SymbolDef,
|
||||
Symbol
|
||||
} ev_type;
|
||||
uint8_t type; // type.
|
||||
|
||||
ParseEvent(T t) : ev_type(t) {}
|
||||
ParseEvent(T e_t, std::string_view s, uint8_t type) : name(s), ev_type(e_t), type(type) {}
|
||||
uint8_t closing;
|
||||
ParseEvent(uint8_t t) : closing(t) {}
|
||||
};
|
||||
|
||||
struct Language {
|
||||
@@ -90,16 +81,6 @@ struct Language {
|
||||
std::function<void(void *)> destroy;
|
||||
};
|
||||
|
||||
struct Symbol {
|
||||
uint32_t definition;
|
||||
uint16_t reference_count;
|
||||
uint8_t type;
|
||||
uint8_t len;
|
||||
// first chars of count len, padded to 4 bytes.
|
||||
// then a set of references. 32bit
|
||||
// references later as modifying at end is faster than shifting the name.
|
||||
};
|
||||
|
||||
struct ParseState {
|
||||
static constexpr uint64_t BRANCH_BIT = 1ull << 63;
|
||||
static constexpr uint64_t LINES_MASK = ~BRANCH_BIT;
|
||||
|
||||
@@ -5,15 +5,6 @@
|
||||
#include "tries.h"
|
||||
|
||||
namespace bed::internal::syntax::ruby {
|
||||
enum struct ScopeTypes : uint8_t {
|
||||
None,
|
||||
Comment,
|
||||
Method,
|
||||
Class,
|
||||
Module,
|
||||
Block
|
||||
};
|
||||
|
||||
struct alignas(2) RubyState {
|
||||
struct RubyInternalState {
|
||||
uint16_t brace_level;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "buffer/append.h"
|
||||
#include "buffer/original.h"
|
||||
#include "constants.h"
|
||||
#include "definitions.h"
|
||||
#include "iterators/line.h"
|
||||
#include "pch.h"
|
||||
#include "shard.h"
|
||||
@@ -92,6 +93,9 @@ struct Vase {
|
||||
std::string_view pattern, Range range, std::string_view options
|
||||
);
|
||||
|
||||
uint64_t find_next(std::string_view pattern, uint64_t start);
|
||||
uint64_t find_prev(std::string_view pattern, uint64_t start);
|
||||
|
||||
bool undo();
|
||||
bool redo();
|
||||
void snapshot();
|
||||
|
||||
Reference in New Issue
Block a user