Rewrite diagnostics popup with new api

This commit is contained in:
2026-02-11 19:51:45 +00:00
parent 5b66f503e4
commit e9d164d769
10 changed files with 239 additions and 231 deletions

View File

@@ -2,12 +2,12 @@
#define EDITOR_H
#include "editor/indents.h"
#include "extentions/diagnostics.h"
#include "extentions/hover.h"
#include "io/knot.h"
#include "io/sysio.h"
#include "syntax/extras.h"
#include "syntax/parser.h"
#include "ui/diagnostics.h"
#include "utils/utils.h"
#include "windows/decl.h"
@@ -39,7 +39,7 @@ struct Editor : Window {
std::shared_mutex lsp_mtx;
std::atomic<struct LSPInstance *> lsp = nullptr;
HoverBox *hover_popup = init_hover();
bool diagnostics_active = false;
DiagnosticBox *diagnostic_popup = init_diagnostic();
std::atomic<int> lsp_version = 1;
IndentationEngine indents = {};
Parser *parser = nullptr;

View 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

View File

@@ -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

View File

@@ -113,16 +113,6 @@ extern std::vector<std::unique_ptr<Popup>> popups;
extern std::vector<std::unique_ptr<TileBase>> floating_tiles;
} // 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 handle_click(KeyEvent event);