Cleanup and ui bar

This commit is contained in:
2026-01-03 17:46:04 +00:00
parent 0390a1bc5d
commit ac04754318
18 changed files with 210 additions and 77 deletions

View File

@@ -26,16 +26,16 @@ Editor *new_editor(const char *filename_arg, Coord position, Coord size) {
}
editor->root = load(str, len, optimal_chunk_size(len));
free(str);
Language language = language_for_file(filename.c_str());
if (language.name != "unknown" && len <= (1024 * 128)) {
editor->lang = language_for_file(filename.c_str());
if (editor->lang.name != "unknown" && len <= (1024 * 128)) {
editor->ts.parser = ts_parser_new();
editor->ts.language = language.fn();
editor->ts.language = editor->lang.fn();
ts_parser_set_language(editor->ts.parser, editor->ts.language);
editor->ts.query_file =
get_exe_dir() + "/../grammar/" + language.name + ".scm";
get_exe_dir() + "/../grammar/" + editor->lang.name + ".scm";
}
if (len <= (1024 * 28))
request_add_to_lsp(language, editor);
request_add_to_lsp(editor->lang, editor);
return editor;
}

View File

@@ -649,15 +649,6 @@ void handle_editor_event(Editor *editor, KeyEvent event) {
}
mode = NORMAL;
break;
case RUNNER:
if (event.key_type == KEY_CHAR && event.len == 1) {
switch (event.c[0]) {
case 0x1B:
mode = NORMAL;
break;
}
}
break;
}
ensure_scroll(editor);
if ((event.key_type == KEY_CHAR || event.key_type == KEY_PASTE) && event.c)

View File

@@ -42,11 +42,8 @@ void editor_lsp_handle(Editor *editor, json msg) {
auto pos = message.find('\n');
message =
(pos == std::string::npos) ? message : message.substr(0, pos);
std::string uri =
percent_decode(rel["location"]["uri"].get<std::string>());
auto pos2 = uri.find_last_of('/');
if (pos2 != std::string::npos)
uri = uri.substr(pos2 + 1);
std::string uri = filename_from_path(
percent_decode(rel["location"]["uri"].get<std::string>()));
std::string row = std::to_string(
rel["location"]["range"]["start"]["line"].get<int>());
w.see_also.push_back(uri + ":" + row + ": " + message);

View File

@@ -74,7 +74,7 @@ void editor_worker(Editor *editor) {
exit(ENOMEM);
std::shared_lock lockk(editor->knot_mtx);
std::vector<Match> results =
search_rope(editor->root, "(?:0x|#)[0-9a-fA-F]{6}");
search_rope(editor->root, "(?:0x|#)[0-9a-fA-F]{6,8}\\b");
if (results.size() > limit) {
limit = results.size() + 50;
free(hl_s);
@@ -91,7 +91,7 @@ void editor_worker(Editor *editor) {
s.start = results[i].start;
s.end = results[i].end;
int x = results[i].text[0] == '#' ? 1 : 2;
uint32_t bg = HEX(results[i].text.substr(x));
uint32_t bg = HEX(results[i].text.substr(x, 6));
uint8_t r = bg >> 16;
uint8_t g = (bg >> 8) & 0xFF;
uint8_t b = bg & 0xFF;