Compare commits
2 Commits
5b66f503e4
...
experiment
| Author | SHA1 | Date | |
|---|---|---|---|
|
c683754d49
|
|||
|
e9d164d769
|
@@ -2,12 +2,12 @@
|
|||||||
#define EDITOR_H
|
#define EDITOR_H
|
||||||
|
|
||||||
#include "editor/indents.h"
|
#include "editor/indents.h"
|
||||||
|
#include "extentions/diagnostics.h"
|
||||||
#include "extentions/hover.h"
|
#include "extentions/hover.h"
|
||||||
#include "io/knot.h"
|
#include "io/knot.h"
|
||||||
#include "io/sysio.h"
|
#include "io/sysio.h"
|
||||||
#include "syntax/extras.h"
|
#include "syntax/extras.h"
|
||||||
#include "syntax/parser.h"
|
#include "syntax/parser.h"
|
||||||
#include "ui/diagnostics.h"
|
|
||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
#include "windows/decl.h"
|
#include "windows/decl.h"
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ struct Editor : Window {
|
|||||||
std::shared_mutex lsp_mtx;
|
std::shared_mutex lsp_mtx;
|
||||||
std::atomic<struct LSPInstance *> lsp = nullptr;
|
std::atomic<struct LSPInstance *> lsp = nullptr;
|
||||||
HoverBox *hover_popup = init_hover();
|
HoverBox *hover_popup = init_hover();
|
||||||
bool diagnostics_active = false;
|
DiagnosticBox *diagnostic_popup = init_diagnostic();
|
||||||
std::atomic<int> lsp_version = 1;
|
std::atomic<int> lsp_version = 1;
|
||||||
IndentationEngine indents = {};
|
IndentationEngine indents = {};
|
||||||
Parser *parser = nullptr;
|
Parser *parser = nullptr;
|
||||||
|
|||||||
22
include/extentions/diagnostics.h
Normal file
22
include/extentions/diagnostics.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef EXTENTION_DIAGNOSTICS_H
|
||||||
|
#define EXTENTION_DIAGNOSTICS_H
|
||||||
|
|
||||||
|
#include "editor/decl.h"
|
||||||
|
#include "io/sysio.h"
|
||||||
|
#include "pch.h"
|
||||||
|
#include "utils/utils.h"
|
||||||
|
#include "windows/decl.h"
|
||||||
|
|
||||||
|
struct DiagnosticBox : Popup {
|
||||||
|
std::vector<VWarn> warnings;
|
||||||
|
|
||||||
|
DiagnosticBox() { this->hidden = true; }
|
||||||
|
void clear() { this->warnings.clear(); }
|
||||||
|
void render(std::vector<ScreenCell> &buffer, Coord size, Coord pos) override;
|
||||||
|
void handle_click(KeyEvent, Coord) override { this->hidden = true; };
|
||||||
|
~DiagnosticBox() {};
|
||||||
|
};
|
||||||
|
|
||||||
|
DiagnosticBox *init_diagnostic();
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -2,19 +2,15 @@
|
|||||||
#define LSP_H
|
#define LSP_H
|
||||||
|
|
||||||
#include "editor/editor.h"
|
#include "editor/editor.h"
|
||||||
|
#include "main.h"
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
|
#include <cstdint>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
#define LSP_TIMEOUT 3000
|
#define LSP_TIMEOUT_START 3000
|
||||||
|
#define LSP_TIMEOUT_QUIT_NORMAL 300
|
||||||
namespace lsp {
|
#define LSP_TIMEOUT_QUIT_FORCE 80
|
||||||
extern std::mutex lsp_mutex;
|
|
||||||
extern std::unordered_map<std::string, std::unique_ptr<LSPInstance>>
|
|
||||||
active_lsps;
|
|
||||||
extern Queue<std::string> need_opening;
|
|
||||||
extern std::unordered_set<std::string> opened;
|
|
||||||
extern std::vector<Editor *> new_editors;
|
|
||||||
} // namespace lsp
|
|
||||||
|
|
||||||
void lsp_worker();
|
void lsp_worker();
|
||||||
|
|
||||||
@@ -48,6 +44,16 @@ struct LSPMessage {
|
|||||||
std::function<void(const LSPMessage &)> callback;
|
std::function<void(const LSPMessage &)> callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace lsp {
|
||||||
|
extern std::mutex lsp_mutex;
|
||||||
|
extern std::unordered_map<std::string, std::unique_ptr<LSPInstance>>
|
||||||
|
active_lsps;
|
||||||
|
extern Queue<std::string> need_opening;
|
||||||
|
extern std::unordered_set<std::string> opened;
|
||||||
|
extern std::vector<Editor *> new_editors;
|
||||||
|
extern Queue<std::unique_ptr<LSPMessage>> response_queue;
|
||||||
|
} // namespace lsp
|
||||||
|
|
||||||
struct LSPInstance {
|
struct LSPInstance {
|
||||||
const LSP *lsp_info;
|
const LSP *lsp_info;
|
||||||
std::string root_dir;
|
std::string root_dir;
|
||||||
@@ -70,7 +76,6 @@ struct LSPInstance {
|
|||||||
Queue<json> inbox;
|
Queue<json> inbox;
|
||||||
Queue<json> outbox;
|
Queue<json> outbox;
|
||||||
std::unordered_map<uint32_t, std::unique_ptr<LSPMessage>> pending;
|
std::unordered_map<uint32_t, std::unique_ptr<LSPMessage>> pending;
|
||||||
std::vector<std::unique_ptr<LSPMessage>> lsp_response_queue;
|
|
||||||
std::vector<Editor *> editors;
|
std::vector<Editor *> editors;
|
||||||
|
|
||||||
LSPInstance(std::string lsp_id) {
|
LSPInstance(std::string lsp_id) {
|
||||||
@@ -89,7 +94,15 @@ struct LSPInstance {
|
|||||||
{"capabilities", client_capabilities}}}};
|
{"capabilities", client_capabilities}}}};
|
||||||
send_raw(initialize_message);
|
send_raw(initialize_message);
|
||||||
pollfd pfd{stdout_fd, POLLIN, 0};
|
pollfd pfd{stdout_fd, POLLIN, 0};
|
||||||
poll(&pfd, 1, LSP_TIMEOUT);
|
uint32_t waited = 0;
|
||||||
|
while (waited < LSP_TIMEOUT_START) {
|
||||||
|
poll(&pfd, 1, 50);
|
||||||
|
if (pfd.revents & POLLIN)
|
||||||
|
break;
|
||||||
|
if (!running)
|
||||||
|
return;
|
||||||
|
waited += 50;
|
||||||
|
}
|
||||||
if (!(pfd.revents & POLLIN)) {
|
if (!(pfd.revents & POLLIN)) {
|
||||||
exited = true;
|
exited = true;
|
||||||
return;
|
return;
|
||||||
@@ -179,34 +192,39 @@ struct LSPInstance {
|
|||||||
send_raw(initialized_message);
|
send_raw(initialized_message);
|
||||||
}
|
}
|
||||||
~LSPInstance() {
|
~LSPInstance() {
|
||||||
|
uint32_t timeout =
|
||||||
|
running ? LSP_TIMEOUT_QUIT_NORMAL : LSP_TIMEOUT_QUIT_FORCE;
|
||||||
for (auto &ed : editors)
|
for (auto &ed : editors)
|
||||||
ed->lsp.store(nullptr);
|
ed->lsp.store(nullptr);
|
||||||
initialized = false;
|
initialized = false;
|
||||||
exited = true;
|
exited = true;
|
||||||
if (pid == -1)
|
if (pid == -1)
|
||||||
return;
|
return;
|
||||||
json shutdown = {{"id", ++last_id}, {"method", "shutdown"}};
|
json shutdown = {
|
||||||
|
{"jsonrpc", "2.0"}, {"id", ++last_id}, {"method", "shutdown"}};
|
||||||
send_raw(shutdown);
|
send_raw(shutdown);
|
||||||
pollfd pfd{stdout_fd, POLLIN, 0};
|
pollfd pfd{stdout_fd, POLLIN, 0};
|
||||||
poll(&pfd, 1, 500);
|
poll(&pfd, 1, timeout);
|
||||||
json exit_msg = {{"method", "exit"}};
|
if (pfd.revents & POLLIN) {
|
||||||
send_raw(exit_msg);
|
json exit_msg = {{"jsonrpc", "2.0"}, {"method", "exit"}};
|
||||||
int waited = 0;
|
send_raw(exit_msg);
|
||||||
while (waited < 100) {
|
int waited = 0;
|
||||||
int status;
|
while (waited < timeout) {
|
||||||
pid_t res = waitpid(pid, &status, WNOHANG);
|
int status;
|
||||||
if (res == pid)
|
pid_t res = waitpid(pid, &status, WNOHANG);
|
||||||
break;
|
if (res == pid)
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
break;
|
||||||
waited += 10;
|
std::this_thread::sleep_for(10ms);
|
||||||
|
waited += 10;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
close(stdin_fd);
|
||||||
|
close(stdout_fd);
|
||||||
if (kill(pid, 0) == 0) {
|
if (kill(pid, 0) == 0) {
|
||||||
kill(pid, SIGKILL);
|
kill(pid, SIGKILL);
|
||||||
waitpid(pid, nullptr, 0);
|
waitpid(pid, nullptr, 0);
|
||||||
}
|
}
|
||||||
pid = -1;
|
pid = -1;
|
||||||
close(stdin_fd);
|
|
||||||
close(stdout_fd);
|
|
||||||
}
|
}
|
||||||
bool init_process() {
|
bool init_process() {
|
||||||
int in_pipe[2];
|
int in_pipe[2];
|
||||||
@@ -312,7 +330,7 @@ struct LSPInstance {
|
|||||||
if (it != pending.end()) {
|
if (it != pending.end()) {
|
||||||
if (it->second->editor) {
|
if (it->second->editor) {
|
||||||
it->second->message = *msg;
|
it->second->message = *msg;
|
||||||
lsp_response_queue.push_back(std::move(it->second));
|
lsp::response_queue.push(std::move(it->second));
|
||||||
} else {
|
} else {
|
||||||
auto message = *std::move(it->second);
|
auto message = *std::move(it->second);
|
||||||
message.message = *msg;
|
message.message = *msg;
|
||||||
@@ -335,7 +353,7 @@ struct LSPInstance {
|
|||||||
response->message = *msg;
|
response->message = *msg;
|
||||||
response->callback = editor_handle_wrapper;
|
response->callback = editor_handle_wrapper;
|
||||||
if (ed)
|
if (ed)
|
||||||
lsp_response_queue.push_back(std::move(response));
|
lsp::response_queue.push(std::move(response));
|
||||||
else
|
else
|
||||||
lsp_handle(*msg);
|
lsp_handle(*msg);
|
||||||
}
|
}
|
||||||
@@ -344,11 +362,6 @@ struct LSPInstance {
|
|||||||
inline static void editor_handle_wrapper(const LSPMessage &message) {
|
inline static void editor_handle_wrapper(const LSPMessage &message) {
|
||||||
message.editor->lsp_handle(message.message);
|
message.editor->lsp_handle(message.message);
|
||||||
}
|
}
|
||||||
void callbacks() {
|
|
||||||
for (auto &message : lsp_response_queue)
|
|
||||||
message->callback(*message);
|
|
||||||
lsp_response_queue.clear();
|
|
||||||
}
|
|
||||||
inline void send_raw(const json &msg) {
|
inline void send_raw(const json &msg) {
|
||||||
std::string payload = msg.dump();
|
std::string payload = msg.dump();
|
||||||
std::string header =
|
std::string header =
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "syntax/trie.h"
|
#include "syntax/trie.h"
|
||||||
|
|
||||||
#define MAX_LINES_LOOKBEHIND 80
|
#define MAX_LINES_LOOKAROUND 512
|
||||||
|
|
||||||
struct Highlight {
|
struct Highlight {
|
||||||
uint32_t fg{0xFFFFFF};
|
uint32_t fg{0xFFFFFF};
|
||||||
|
|||||||
@@ -59,15 +59,8 @@ struct LineMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void apply_edit(uint32_t start, int64_t delta) {
|
void apply_edit(uint32_t start, int64_t delta) {
|
||||||
if (delta < 0) {
|
if (delta < 0)
|
||||||
int64_t count = -delta;
|
batch_remove(start, -delta);
|
||||||
for (int64_t i = 0; i < count; i++) {
|
|
||||||
auto key = resolve_line(start + i);
|
|
||||||
if (!key)
|
|
||||||
continue;
|
|
||||||
lines.erase(*key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
current_version++;
|
current_version++;
|
||||||
edit_log.push_back({start, delta});
|
edit_log.push_back({start, delta});
|
||||||
}
|
}
|
||||||
@@ -79,6 +72,45 @@ private:
|
|||||||
|
|
||||||
uint32_t current_version;
|
uint32_t current_version;
|
||||||
|
|
||||||
|
void batch_remove(uint32_t line, uint32_t count) {
|
||||||
|
std::vector<uint32_t> lines_t;
|
||||||
|
lines_t.reserve(count);
|
||||||
|
for (uint32_t i = 0; i < count; i++)
|
||||||
|
lines_t.push_back(line + i);
|
||||||
|
for (int64_t v = current_version; v >= 0; v--) {
|
||||||
|
for (auto &l : lines_t) {
|
||||||
|
if (l == UINT32_MAX)
|
||||||
|
continue;
|
||||||
|
LineKey key = {l, (uint32_t)v};
|
||||||
|
if (lines.find(key) != lines.end()) {
|
||||||
|
lines.erase(key);
|
||||||
|
l = UINT32_MAX;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bool all_removed = true;
|
||||||
|
const auto &edit = edit_log[v];
|
||||||
|
for (auto &l : lines_t) {
|
||||||
|
if (l == UINT32_MAX)
|
||||||
|
continue;
|
||||||
|
all_removed = false;
|
||||||
|
if (edit.delta > 0) {
|
||||||
|
if (l >= edit.start_line) {
|
||||||
|
if (l < edit.start_line + edit.delta)
|
||||||
|
l = UINT32_MAX;
|
||||||
|
else
|
||||||
|
l -= edit.delta;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (l >= edit.start_line)
|
||||||
|
l -= edit.delta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (all_removed)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<LineKey> resolve_line(uint32_t line) {
|
std::optional<LineKey> resolve_line(uint32_t line) {
|
||||||
uint32_t current_line = line;
|
uint32_t current_line = line;
|
||||||
for (int64_t v = current_version; v >= 0; v--) {
|
for (int64_t v = current_version; v >= 0; v--) {
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
#ifndef UI_DIAGNOSTICS_H
|
|
||||||
#define UI_DIAGNOSTICS_H
|
|
||||||
|
|
||||||
#include "editor/decl.h"
|
|
||||||
#include "io/sysio.h"
|
|
||||||
#include "pch.h"
|
|
||||||
#include "utils/utils.h"
|
|
||||||
|
|
||||||
struct DiagnosticBox {
|
|
||||||
std::vector<VWarn> warnings;
|
|
||||||
std::vector<ScreenCell> cells;
|
|
||||||
Coord size;
|
|
||||||
|
|
||||||
void clear();
|
|
||||||
void render_first();
|
|
||||||
void render(Coord pos);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -6,18 +6,19 @@
|
|||||||
template <typename T> struct Queue {
|
template <typename T> struct Queue {
|
||||||
void push(T val) {
|
void push(T val) {
|
||||||
std::lock_guard<std::mutex> lock(m);
|
std::lock_guard<std::mutex> lock(m);
|
||||||
q.push(val);
|
q.push(std::move(val));
|
||||||
}
|
}
|
||||||
std::optional<T> front() {
|
std::optional<T> front() {
|
||||||
|
std::lock_guard<std::mutex> lock(m);
|
||||||
if (q.empty())
|
if (q.empty())
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
return q.front();
|
return std::move(q.front());
|
||||||
}
|
}
|
||||||
bool pop(T &val) {
|
bool pop(T &val) {
|
||||||
std::lock_guard<std::mutex> lock(m);
|
std::lock_guard<std::mutex> lock(m);
|
||||||
if (q.empty())
|
if (q.empty())
|
||||||
return false;
|
return false;
|
||||||
val = q.front();
|
val = std::move(q.front());
|
||||||
q.pop();
|
q.pop();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,16 +113,6 @@ extern std::vector<std::unique_ptr<Popup>> popups;
|
|||||||
extern std::vector<std::unique_ptr<TileBase>> floating_tiles;
|
extern std::vector<std::unique_ptr<TileBase>> floating_tiles;
|
||||||
} // namespace layout
|
} // namespace layout
|
||||||
|
|
||||||
inline void close(Popup *handle) {
|
|
||||||
std::erase_if(layout::popups,
|
|
||||||
[handle](const auto &p) { return p.get() == handle; });
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void close(TileBase *handle) {
|
|
||||||
std::erase_if(layout::floating_tiles,
|
|
||||||
[handle](const auto &p) { return p.get() == handle; });
|
|
||||||
}
|
|
||||||
|
|
||||||
void render();
|
void render();
|
||||||
void handle_click(KeyEvent event);
|
void handle_click(KeyEvent event);
|
||||||
|
|
||||||
|
|||||||
@@ -339,6 +339,5 @@ puts 'Ruby syntax highlighting test complete.'
|
|||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
|
||||||
|
|
||||||
Anything here should be ignored >><<
|
Anything here should be ignored >><<
|
||||||
{{{}}}[[[]]](((000)))
|
{{{}}}[[[]]](((000)))
|
||||||
|
|||||||
@@ -467,14 +467,10 @@ void Editor::render(std::vector<ScreenCell> &buffer, Coord size, Coord pos) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
set_cursor(cursor.row, cursor.col, type, true);
|
set_cursor(cursor.row, cursor.col, type, true);
|
||||||
// if (this->completion.active && !this->completion.box.hidden)
|
|
||||||
// this->completion.box.render(cursor);
|
|
||||||
// else if (this->hover_active)
|
|
||||||
// this->hover.render(cursor);
|
|
||||||
// else if (this->diagnostics_active)
|
|
||||||
// this->diagnostics.render(cursor);
|
|
||||||
if (!this->hover_popup->hidden)
|
if (!this->hover_popup->hidden)
|
||||||
this->hover_popup->pos = cursor;
|
this->hover_popup->pos = cursor;
|
||||||
|
if (!this->diagnostic_popup->hidden)
|
||||||
|
this->diagnostic_popup->pos = cursor;
|
||||||
}
|
}
|
||||||
free(it->buffer);
|
free(it->buffer);
|
||||||
free(it);
|
free(it);
|
||||||
|
|||||||
@@ -1,36 +1,33 @@
|
|||||||
#include "editor/editor.h"
|
#include "editor/editor.h"
|
||||||
|
|
||||||
// void hover_diagnostic(Editor *editor) {
|
void hover_diagnostic(Editor *editor) {
|
||||||
// static uint32_t last_line = UINT32_MAX;
|
static uint32_t last_line = UINT32_MAX;
|
||||||
// if (last_line == editor->cursor.row && !editor->warnings_dirty)
|
if (last_line == editor->cursor.row && !editor->warnings_dirty)
|
||||||
// return;
|
return;
|
||||||
// VWarn dummy;
|
VWarn dummy;
|
||||||
// dummy.line = editor->cursor.row;
|
dummy.line = editor->cursor.row;
|
||||||
// editor->warnings_dirty = false;
|
editor->warnings_dirty = false;
|
||||||
// last_line = editor->cursor.row;
|
last_line = editor->cursor.row;
|
||||||
// auto first =
|
auto first =
|
||||||
// std::lower_bound(editor->warnings.begin(), editor->warnings.end(),
|
std::lower_bound(editor->warnings.begin(), editor->warnings.end(), dummy);
|
||||||
// dummy);
|
auto last =
|
||||||
// auto last =
|
std::upper_bound(editor->warnings.begin(), editor->warnings.end(), dummy);
|
||||||
// std::upper_bound(editor->warnings.begin(), editor->warnings.end(),
|
std::vector<VWarn> warnings_at_line(first, last);
|
||||||
// dummy);
|
if (warnings_at_line.size() == 0) {
|
||||||
// std::vector<VWarn> warnings_at_line(first, last);
|
editor->diagnostic_popup->hidden = true;
|
||||||
// if (warnings_at_line.size() == 0) {
|
return;
|
||||||
// editor->diagnostics_active = false;
|
}
|
||||||
// return;
|
editor->diagnostic_popup->clear();
|
||||||
// }
|
editor->diagnostic_popup->warnings.swap(warnings_at_line);
|
||||||
// editor->diagnostics.clear();
|
editor->diagnostic_popup->hidden = false;
|
||||||
// editor->diagnostics.warnings.swap(warnings_at_line);
|
}
|
||||||
// editor->diagnostics.render_first();
|
|
||||||
// editor->diagnostics_active = true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
void Editor::work() {
|
void Editor::work() {
|
||||||
if (!this->root)
|
if (!this->root)
|
||||||
return;
|
return;
|
||||||
if (this->parser)
|
if (this->parser)
|
||||||
this->parser->work();
|
this->parser->work();
|
||||||
// hover_diagnostic(this);
|
hover_diagnostic(this);
|
||||||
// if (this->completion.active && this->completion.hover_dirty) {
|
// if (this->completion.active && this->completion.hover_dirty) {
|
||||||
// this->completion.hover.render_first();
|
// this->completion.hover.render_first();
|
||||||
// this->completion.hover_dirty = false;
|
// this->completion.hover_dirty = false;
|
||||||
|
|||||||
187
src/extentions/diagnostics.cc
Normal file
187
src/extentions/diagnostics.cc
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
#include "extentions/diagnostics.h"
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
DiagnosticBox *init_diagnostic() {
|
||||||
|
auto diagnostic = std::make_unique<DiagnosticBox>();
|
||||||
|
diagnostic->pos = {0, 0};
|
||||||
|
diagnostic->size = {1, 1};
|
||||||
|
diagnostic->hidden = true;
|
||||||
|
DiagnosticBox *ptr = diagnostic.get();
|
||||||
|
layout::popups.push_back(std::move(diagnostic));
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DiagnosticBox::render(std::vector<ScreenCell> &buffer, Coord n_size,
|
||||||
|
Coord n_pos) {
|
||||||
|
pos = n_pos;
|
||||||
|
size = n_size;
|
||||||
|
int32_t start_row = (int32_t)pos.row - (int32_t)size.row;
|
||||||
|
if (start_row < 0)
|
||||||
|
start_row = pos.row + 1;
|
||||||
|
int32_t start_col = pos.col;
|
||||||
|
Coord screen_size = {io::rows, io::cols};
|
||||||
|
if (start_col + size.col > screen_size.col) {
|
||||||
|
start_col = screen_size.col - size.col;
|
||||||
|
if (start_col < 0)
|
||||||
|
start_col = 0;
|
||||||
|
}
|
||||||
|
pos.col = start_col;
|
||||||
|
pos.row = start_row;
|
||||||
|
if (warnings.empty())
|
||||||
|
return;
|
||||||
|
uint32_t longest_line = 8 + warnings[0].source.length();
|
||||||
|
for (auto &warn : warnings) {
|
||||||
|
uint32_t longest = 0;
|
||||||
|
uint32_t cur = 0;
|
||||||
|
for (char ch : warn.text_full)
|
||||||
|
if (ch == '\n') {
|
||||||
|
longest = MAX(longest, cur);
|
||||||
|
cur = 0;
|
||||||
|
} else {
|
||||||
|
if (ch == '\t')
|
||||||
|
cur += 3;
|
||||||
|
++cur;
|
||||||
|
}
|
||||||
|
longest = MAX(longest, cur);
|
||||||
|
longest_line = MAX(longest_line, longest + 7);
|
||||||
|
longest_line = MAX(longest_line, (uint32_t)warn.code.length() + 4);
|
||||||
|
for (auto &see_also : warn.see_also)
|
||||||
|
longest_line = MAX(longest_line, (uint32_t)see_also.length() + 4);
|
||||||
|
}
|
||||||
|
uint32_t content_width = MIN(longest_line, 150u);
|
||||||
|
size.col = content_width + 2;
|
||||||
|
auto set = [&](uint32_t r, uint32_t c, std::string text, uint32_t fg,
|
||||||
|
uint32_t bg, uint8_t flags, uint32_t width) {
|
||||||
|
if (r < 0 || r >= size.row || c < 0 || c >= size.col)
|
||||||
|
return;
|
||||||
|
r += pos.row;
|
||||||
|
c += pos.col;
|
||||||
|
if (r < 0 || r >= screen_size.row || c < 0 || c >= screen_size.col)
|
||||||
|
return;
|
||||||
|
ScreenCell &cell = buffer[r * screen_size.col + c];
|
||||||
|
cell.utf8 = std::move(text);
|
||||||
|
cell.width = width;
|
||||||
|
cell.fg = fg;
|
||||||
|
cell.bg = bg;
|
||||||
|
cell.flags = flags;
|
||||||
|
cell.ul_color = 0;
|
||||||
|
};
|
||||||
|
uint32_t base_bg = 0;
|
||||||
|
uint32_t border_fg = 0x82AAFF;
|
||||||
|
uint32_t r = 0;
|
||||||
|
if (warnings[0].source != "") {
|
||||||
|
std::string src_txt = "Source: ";
|
||||||
|
uint32_t i = 0;
|
||||||
|
for (; i < 8 && i < content_width; i++)
|
||||||
|
set(1, i + 1, (char[2]){src_txt[i], 0}, 0x3EAAFF, base_bg, 0, 1);
|
||||||
|
for (; i < 8 + warnings[0].source.length() && i < content_width; i++)
|
||||||
|
set(1, i + 1, (char[2]){warnings[0].source[i - 8], 0}, 0xffffff, base_bg,
|
||||||
|
0, 1);
|
||||||
|
while (i < content_width)
|
||||||
|
set(1, ++i, " ", 0xffffff, base_bg, 0, 1);
|
||||||
|
r++;
|
||||||
|
}
|
||||||
|
int idx = 1;
|
||||||
|
for (auto &warn : warnings) {
|
||||||
|
char buf[4];
|
||||||
|
std::snprintf(buf, sizeof(buf), "%2d", idx % 100);
|
||||||
|
std::string line_txt = std::string(buf) + ". ";
|
||||||
|
for (uint32_t i = 0; i < line_txt.length(); i++)
|
||||||
|
set(r + 1, i + 1, (char[2]){line_txt[i], 0}, 0xffffff, base_bg, 0, 1);
|
||||||
|
if (r >= 23)
|
||||||
|
break;
|
||||||
|
const char *err_sym = "";
|
||||||
|
uint32_t c_sym = 0xAAAAAA;
|
||||||
|
switch (warn.type) {
|
||||||
|
case 1:
|
||||||
|
err_sym = "";
|
||||||
|
c_sym = 0xFF0000;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
err_sym = "";
|
||||||
|
c_sym = 0xFFFF00;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
err_sym = "";
|
||||||
|
c_sym = 0xFF00FF;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
err_sym = "";
|
||||||
|
c_sym = 0xAAAAAA;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
std::string text = warn.text_full + " " + err_sym;
|
||||||
|
uint32_t i = 0;
|
||||||
|
while (i < text.length() && r < 23) {
|
||||||
|
uint32_t c = 4;
|
||||||
|
while (c < content_width && i < text.length()) {
|
||||||
|
if (text[i] == '\n') {
|
||||||
|
while (i < text.length() && text[i] == '\n')
|
||||||
|
i++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
uint32_t cluster_len = grapheme_next_character_break_utf8(
|
||||||
|
text.c_str() + i, text.length() - i);
|
||||||
|
std::string cluster = text.substr(i, cluster_len);
|
||||||
|
int width = display_width(cluster.c_str(), cluster_len);
|
||||||
|
if (c + width > content_width)
|
||||||
|
break;
|
||||||
|
set(r + 1, c + 1, cluster.c_str(), c_sym, base_bg, 0, width);
|
||||||
|
c += width;
|
||||||
|
i += cluster_len;
|
||||||
|
for (int w = 1; w < width; w++)
|
||||||
|
set(r + 1, c - w + 1, "\x1b", c_sym, base_bg, 0, 0);
|
||||||
|
}
|
||||||
|
while (c < content_width)
|
||||||
|
set(r + 1, ++c, " ", 0xffffff, base_bg, 0, 1);
|
||||||
|
r++;
|
||||||
|
}
|
||||||
|
if (r >= 23)
|
||||||
|
break;
|
||||||
|
if (warn.code != "") {
|
||||||
|
uint32_t i = 0;
|
||||||
|
for (; i < 5 && i < content_width; i++)
|
||||||
|
set(r + 1, i, " ", 0x81cdc6, base_bg, 0, 1);
|
||||||
|
for (; i < warn.code.length() + 5 && i < content_width; i++)
|
||||||
|
set(r + 1, i, (char[2]){warn.code[i - 5], 0}, 0x81cdc6, base_bg, 0, 1);
|
||||||
|
while (i <= content_width)
|
||||||
|
set(r + 1, i++, " ", 0x81cdc6, base_bg, 0, 1);
|
||||||
|
r++;
|
||||||
|
}
|
||||||
|
if (r >= 23)
|
||||||
|
break;
|
||||||
|
for (std::string &see_also : warn.see_also) {
|
||||||
|
uint32_t fg = 0xB55EFF;
|
||||||
|
uint8_t colon_count = 0;
|
||||||
|
uint32_t i = 0;
|
||||||
|
for (; i < 5 && i < content_width; i++)
|
||||||
|
set(r + 1, i, " ", 0x81cdc6, base_bg, 0, 1);
|
||||||
|
for (; i < see_also.length() + 5 && i < content_width; i++) {
|
||||||
|
set(r + 1, i, (char[2]){see_also[i - 5], 0}, fg, base_bg, 0, 1);
|
||||||
|
if (see_also[i] == ':')
|
||||||
|
colon_count++;
|
||||||
|
if (colon_count == 2)
|
||||||
|
fg = 0xFFFFFF;
|
||||||
|
}
|
||||||
|
while (i <= content_width)
|
||||||
|
set(r + 1, i++, " ", fg, base_bg, 0, 1);
|
||||||
|
r++;
|
||||||
|
if (r >= 23)
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
size.row = 2 + r;
|
||||||
|
set(0, 0, "┌", border_fg, base_bg, 0, 1);
|
||||||
|
for (uint32_t i = 1; i < size.col - 1; i++)
|
||||||
|
set(0, i, "─", border_fg, base_bg, 0, 1);
|
||||||
|
set(0, size.col - 1, "┐", border_fg, base_bg, 0, 1);
|
||||||
|
for (uint32_t r = 1; r < size.row - 1; r++) {
|
||||||
|
set(r, 0, "│", border_fg, base_bg, 0, 1);
|
||||||
|
set(r, size.col - 1, "│", border_fg, base_bg, 0, 1);
|
||||||
|
}
|
||||||
|
set(size.row - 1, 0, "└", border_fg, base_bg, 0, 1);
|
||||||
|
for (uint32_t i = 1; i < size.col - 1; i++)
|
||||||
|
set(size.row - 1, i, "─", border_fg, base_bg, 0, 1);
|
||||||
|
set(size.row - 1, size.col - 1, "┘", border_fg, base_bg, 0, 1);
|
||||||
|
}
|
||||||
@@ -36,7 +36,7 @@ void HoverBox::render(std::vector<ScreenCell> &buffer, Coord n_size,
|
|||||||
int32_t start_row = (int32_t)pos.row - (int32_t)size.row;
|
int32_t start_row = (int32_t)pos.row - (int32_t)size.row;
|
||||||
if (start_row < 0)
|
if (start_row < 0)
|
||||||
start_row = pos.row + 1;
|
start_row = pos.row + 1;
|
||||||
int32_t start_col = pos.col; // pos here is the cursor pos
|
int32_t start_col = pos.col;
|
||||||
Coord screen_size = {io::rows, io::cols};
|
Coord screen_size = {io::rows, io::cols};
|
||||||
if (start_col + size.col > screen_size.col) {
|
if (start_col + size.col > screen_size.col) {
|
||||||
start_col = screen_size.col - size.col;
|
start_col = screen_size.col - size.col;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ std::unordered_map<std::string, std::unique_ptr<LSPInstance>> active_lsps;
|
|||||||
std::unordered_set<std::string> opened;
|
std::unordered_set<std::string> opened;
|
||||||
Queue<std::string> need_opening;
|
Queue<std::string> need_opening;
|
||||||
std::vector<Editor *> new_editors;
|
std::vector<Editor *> new_editors;
|
||||||
|
Queue<std::unique_ptr<LSPMessage>> response_queue;
|
||||||
} // namespace lsp
|
} // namespace lsp
|
||||||
|
|
||||||
void lsp_worker() {
|
void lsp_worker() {
|
||||||
|
|||||||
51
src/main.cc
51
src/main.cc
@@ -44,34 +44,41 @@ int main(int argc, char *argv[]) {
|
|||||||
std::thread lsp_thread(background_lsp);
|
std::thread lsp_thread(background_lsp);
|
||||||
|
|
||||||
while (running) {
|
while (running) {
|
||||||
KeyEvent event = throttle(1ms, read_key);
|
uint8_t consumed = 0;
|
||||||
if (event.key_type != KEY_NONE) {
|
KeyEvent event;
|
||||||
if (event.key_type == KEY_CHAR && event.len == 1 &&
|
while (++consumed < 32 && (event = read_key()).key_type != KEY_NONE) {
|
||||||
event.c[0] == CTRL('q')) {
|
if (event.key_type != KEY_NONE) {
|
||||||
free(event.c);
|
if (event.key_type == KEY_CHAR && event.len == 1 &&
|
||||||
running = false;
|
event.c[0] == CTRL('q')) {
|
||||||
break;
|
free(event.c);
|
||||||
}
|
running = false;
|
||||||
if (mode != RUNNER) {
|
goto quit;
|
||||||
if (event.key_type == KEY_MOUSE) {
|
|
||||||
handle_click(event);
|
|
||||||
} else {
|
|
||||||
layout::focused_window->handle_event(event);
|
|
||||||
}
|
}
|
||||||
} else {
|
if (mode != RUNNER) {
|
||||||
ui::bar.handle_event(event);
|
if (event.key_type == KEY_MOUSE) {
|
||||||
|
handle_click(event);
|
||||||
|
} else {
|
||||||
|
layout::focused_window->handle_event(event);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ui::bar.handle_event(event);
|
||||||
|
}
|
||||||
|
if ((event.key_type == KEY_CHAR || event.key_type == KEY_PASTE) &&
|
||||||
|
event.c)
|
||||||
|
free(event.c);
|
||||||
}
|
}
|
||||||
if ((event.key_type == KEY_CHAR || event.key_type == KEY_PASTE) &&
|
|
||||||
event.c)
|
|
||||||
free(event.c);
|
|
||||||
}
|
}
|
||||||
for (auto &lsp_inst : lsp::active_lsps)
|
std::unique_ptr<LSPMessage> msg;
|
||||||
lsp_inst.second->callbacks();
|
while (lsp::response_queue.pop(msg)) {
|
||||||
|
msg->callback(*msg);
|
||||||
|
};
|
||||||
layout::focused_window->work();
|
layout::focused_window->work();
|
||||||
throttle(4ms, render);
|
render();
|
||||||
throttle(4ms, io_render);
|
throttle(8ms, io_render);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
quit:
|
||||||
|
|
||||||
if (lsp_thread.joinable())
|
if (lsp_thread.joinable())
|
||||||
lsp_thread.join();
|
lsp_thread.join();
|
||||||
|
|
||||||
|
|||||||
@@ -45,22 +45,27 @@ void Parser::work() {
|
|||||||
if (!editor || !editor->root)
|
if (!editor || !editor->root)
|
||||||
return;
|
return;
|
||||||
std::vector<uint32_t> batch;
|
std::vector<uint32_t> batch;
|
||||||
uint32_t c_line;
|
|
||||||
uint32_t line_count = editor->root->line_count + 1;
|
uint32_t line_count = editor->root->line_count + 1;
|
||||||
for (uint32_t i = MAX(0, (int64_t)scroll_max - MAX_LINES_LOOKBEHIND);
|
uint32_t min_line =
|
||||||
i <= scroll_max + 10 && i < line_count; ++i) {
|
scroll_max > MAX_LINES_LOOKAROUND ? scroll_max - MAX_LINES_LOOKAROUND : 0;
|
||||||
auto l_opt = line_map.at(i);
|
uint32_t max_line = MIN(scroll_max + MAX_LINES_LOOKAROUND, line_count - 1);
|
||||||
if (!l_opt || (l_opt && !l_opt->out_state))
|
bool sequential = false;
|
||||||
|
for (uint32_t i = min_line; i <= max_line; ++i) {
|
||||||
|
LineData *ld = line_map.at(i);
|
||||||
|
if ((!ld || !ld->in_state || !ld->out_state) && !sequential) {
|
||||||
batch.push_back(i);
|
batch.push_back(i);
|
||||||
i++;
|
sequential = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sequential = false;
|
||||||
}
|
}
|
||||||
for (uint32_t c_line : batch) {
|
for (uint32_t c_line : batch) {
|
||||||
if (!running.load(std::memory_order_relaxed))
|
if (!running.load(std::memory_order_relaxed))
|
||||||
break;
|
break;
|
||||||
uint32_t min_line = scroll_max > MAX_LINES_LOOKBEHIND
|
uint32_t min_line = scroll_max > MAX_LINES_LOOKAROUND
|
||||||
? scroll_max - MAX_LINES_LOOKBEHIND
|
? scroll_max - MAX_LINES_LOOKAROUND
|
||||||
: 0;
|
: 0;
|
||||||
uint32_t max_line = scroll_max + 10;
|
uint32_t max_line = scroll_max + MAX_LINES_LOOKAROUND;
|
||||||
if (c_line < min_line || c_line > max_line)
|
if (c_line < min_line || c_line > max_line)
|
||||||
continue;
|
continue;
|
||||||
uint32_t scroll_snapshot = scroll_max;
|
uint32_t scroll_snapshot = scroll_max;
|
||||||
@@ -79,8 +84,12 @@ void Parser::work() {
|
|||||||
break;
|
break;
|
||||||
if (scroll_snapshot != scroll_max)
|
if (scroll_snapshot != scroll_max)
|
||||||
break;
|
break;
|
||||||
if (cur_line < min_line || cur_line > max_line)
|
if (cur_line < min_line || cur_line > max_line) {
|
||||||
|
LineData *line_data = line_map.at(cur_line);
|
||||||
|
if (line_data)
|
||||||
|
line_data->out_state = nullptr;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
char *line = next_line(it, &len);
|
char *line = next_line(it, &len);
|
||||||
if (!line)
|
if (!line)
|
||||||
|
|||||||
@@ -1,164 +0,0 @@
|
|||||||
// #include "ui/diagnostics.h"
|
|
||||||
//
|
|
||||||
// void DiagnosticBox::clear() {
|
|
||||||
// warnings.clear();
|
|
||||||
// cells.clear();
|
|
||||||
// size = {0, 0};
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// void DiagnosticBox::render_first() {
|
|
||||||
// if (warnings.empty())
|
|
||||||
// return;
|
|
||||||
// uint32_t longest_line = 8 + warnings[0].source.length();
|
|
||||||
// for (auto &warn : warnings) {
|
|
||||||
// uint32_t longest = 0;
|
|
||||||
// uint32_t cur = 0;
|
|
||||||
// for (char ch : warn.text_full)
|
|
||||||
// if (ch == '\n') {
|
|
||||||
// longest = MAX(longest, cur);
|
|
||||||
// cur = 0;
|
|
||||||
// } else {
|
|
||||||
// if (ch == '\t')
|
|
||||||
// cur += 3;
|
|
||||||
// ++cur;
|
|
||||||
// }
|
|
||||||
// longest = MAX(longest, cur);
|
|
||||||
// longest_line = MAX(longest_line, longest + 7);
|
|
||||||
// longest_line = MAX(longest_line, (uint32_t)warn.code.length() + 4);
|
|
||||||
// for (auto &see_also : warn.see_also)
|
|
||||||
// longest_line = MAX(longest_line, (uint32_t)see_also.length() + 4);
|
|
||||||
// }
|
|
||||||
// uint32_t content_width = MIN(longest_line, 150u);
|
|
||||||
// size.col = content_width + 2;
|
|
||||||
// cells.assign(size.col * 25, {" ", 0, 0, 0, 0, 0});
|
|
||||||
// auto set = [&](uint32_t r, uint32_t c, const char *text, uint32_t fg,
|
|
||||||
// uint32_t bg, uint8_t flags) {
|
|
||||||
// cells[r * size.col + c] = {std::string(text), 0, fg, bg, flags, 0};
|
|
||||||
// };
|
|
||||||
// uint32_t base_bg = 0;
|
|
||||||
// uint32_t border_fg = 0x82AAFF;
|
|
||||||
// uint32_t r = 0;
|
|
||||||
// if (warnings[0].source != "") {
|
|
||||||
// std::string src_txt = "Source: ";
|
|
||||||
// for (uint32_t i = 0; i < src_txt.length() && i < content_width; i++)
|
|
||||||
// set(1, i + 1, (char[2]){src_txt[i], 0}, 0x3EAAFF, base_bg, 0);
|
|
||||||
// for (uint32_t i = 0; i < warnings[0].source.length() && i <
|
|
||||||
// content_width;
|
|
||||||
// i++)
|
|
||||||
// set(1, i + 1 + src_txt.length(), (char[2]){warnings[0].source[i], 0},
|
|
||||||
// 0xffffff, base_bg, 0);
|
|
||||||
// r++;
|
|
||||||
// }
|
|
||||||
// int idx = 1;
|
|
||||||
// for (auto &warn : warnings) {
|
|
||||||
// char buf[4];
|
|
||||||
// std::snprintf(buf, sizeof(buf), "%2d", idx % 100);
|
|
||||||
// std::string line_txt = std::string(buf) + ". ";
|
|
||||||
// for (uint32_t i = 0; i < line_txt.length(); i++)
|
|
||||||
// set(r + 1, i + 1, (char[2]){line_txt[i], 0}, 0xffffff, base_bg, 0);
|
|
||||||
// if (r >= 23)
|
|
||||||
// break;
|
|
||||||
// const char *err_sym = "";
|
|
||||||
// uint32_t c_sym = 0xAAAAAA;
|
|
||||||
// switch (warn.type) {
|
|
||||||
// case 1:
|
|
||||||
// err_sym = "";
|
|
||||||
// c_sym = 0xFF0000;
|
|
||||||
// break;
|
|
||||||
// case 2:
|
|
||||||
// err_sym = "";
|
|
||||||
// c_sym = 0xFFFF00;
|
|
||||||
// break;
|
|
||||||
// case 3:
|
|
||||||
// err_sym = "";
|
|
||||||
// c_sym = 0xFF00FF;
|
|
||||||
// break;
|
|
||||||
// case 4:
|
|
||||||
// err_sym = "";
|
|
||||||
// c_sym = 0xAAAAAA;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// std::string text = warn.text_full + " " + err_sym;
|
|
||||||
// uint32_t i = 0;
|
|
||||||
// while (i < text.length() && r < 23) {
|
|
||||||
// uint32_t c = 4;
|
|
||||||
// while (c < content_width && i < text.length()) {
|
|
||||||
// if (text[i] == '\n') {
|
|
||||||
// while (i < text.length() && text[i] == '\n')
|
|
||||||
// i++;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// uint32_t cluster_len = grapheme_next_character_break_utf8(
|
|
||||||
// text.c_str() + i, text.length() - i);
|
|
||||||
// std::string cluster = text.substr(i, cluster_len);
|
|
||||||
// int width = display_width(cluster.c_str(), cluster_len);
|
|
||||||
// if (c + width > content_width)
|
|
||||||
// break;
|
|
||||||
// set(r + 1, c + 1, cluster.c_str(), c_sym, base_bg, 0);
|
|
||||||
// c += width;
|
|
||||||
// i += cluster_len;
|
|
||||||
// for (int w = 1; w < width; w++)
|
|
||||||
// set(r + 1, c - w + 1, "\x1b", c_sym, base_bg, 0);
|
|
||||||
// }
|
|
||||||
// r++;
|
|
||||||
// }
|
|
||||||
// if (r >= 23)
|
|
||||||
// break;
|
|
||||||
// if (warn.code != "") {
|
|
||||||
// for (uint32_t i = 0; i < warn.code.length() && i + 5 < content_width;
|
|
||||||
// i++)
|
|
||||||
// set(r + 1, i + 5, (char[2]){warn.code[i], 0}, 0x81cdc6, base_bg, 0);
|
|
||||||
// r++;
|
|
||||||
// }
|
|
||||||
// if (r >= 23)
|
|
||||||
// break;
|
|
||||||
// for (std::string &see_also : warn.see_also) {
|
|
||||||
// uint32_t fg = 0xB55EFF;
|
|
||||||
// uint8_t colon_count = 0;
|
|
||||||
// for (uint32_t i = 0; i < see_also.length() && i + 5 < content_width;
|
|
||||||
// i++) {
|
|
||||||
// set(r + 1, i + 5, (char[2]){see_also[i], 0}, fg, base_bg, 0);
|
|
||||||
// if (see_also[i] == ':')
|
|
||||||
// colon_count++;
|
|
||||||
// if (colon_count == 2)
|
|
||||||
// fg = 0xFFFFFF;
|
|
||||||
// }
|
|
||||||
// r++;
|
|
||||||
// if (r >= 23)
|
|
||||||
// break;
|
|
||||||
// };
|
|
||||||
// idx++;
|
|
||||||
// }
|
|
||||||
// size.row = 2 + r;
|
|
||||||
// set(0, 0, "┌", border_fg, base_bg, 0);
|
|
||||||
// for (uint32_t i = 1; i < size.col - 1; i++)
|
|
||||||
// set(0, i, "─", border_fg, base_bg, 0);
|
|
||||||
// set(0, size.col - 1, "┐", border_fg, base_bg, 0);
|
|
||||||
// for (uint32_t r = 1; r < size.row - 1; r++) {
|
|
||||||
// set(r, 0, "│", border_fg, base_bg, 0);
|
|
||||||
// set(r, size.col - 1, "│", border_fg, base_bg, 0);
|
|
||||||
// }
|
|
||||||
// set(size.row - 1, 0, "└", border_fg, base_bg, 0);
|
|
||||||
// for (uint32_t i = 1; i < size.col - 1; i++)
|
|
||||||
// set(size.row - 1, i, "─", border_fg, base_bg, 0);
|
|
||||||
// set(size.row - 1, size.col - 1, "┘", border_fg, base_bg, 0);
|
|
||||||
// cells.resize(size.col * size.row);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void DiagnosticBox::render(Coord pos) {
|
|
||||||
// int32_t start_row = (int32_t)pos.row - (int32_t)size.row;
|
|
||||||
// if (start_row < 0)
|
|
||||||
// start_row = pos.row + 1;
|
|
||||||
// int32_t start_col = pos.col;
|
|
||||||
// Coord screen_size = get_size();
|
|
||||||
// if (start_col + size.col > screen_size.col) {
|
|
||||||
// start_col = screen_size.col - size.col;
|
|
||||||
// if (start_col < 0)
|
|
||||||
// start_col = 0;
|
|
||||||
// }
|
|
||||||
// for (uint32_t r = 0; r < size.row; r++)
|
|
||||||
// for (uint32_t c = 0; c < size.col; c++)
|
|
||||||
// update(start_row + r, start_col + c, cells[r * size.col + c].utf8,
|
|
||||||
// cells[r * size.col + c].fg, cells[r * size.col + c].bg,
|
|
||||||
// cells[r * size.col + c].flags);
|
|
||||||
// }
|
|
||||||
Reference in New Issue
Block a user