Allow ruby based configs and custom syntax parsers

This commit is contained in:
2026-01-22 19:25:15 +00:00
parent 6dc0813b49
commit cca0177929
29 changed files with 1016 additions and 789 deletions

View File

@@ -4,7 +4,8 @@
#include "syntax/langs.h"
#include "utils/utils.h"
Editor *new_editor(const char *filename_arg, Coord position, Coord size) {
Editor *new_editor(const char *filename_arg, Coord position, Coord size,
bool unix_eol) {
Editor *editor = new Editor();
if (!editor)
return nullptr;
@@ -15,6 +16,7 @@ Editor *new_editor(const char *filename_arg, Coord position, Coord size) {
free_editor(editor);
return nullptr;
}
editor->unix_eol = unix_eol;
editor->filename = filename;
editor->uri = path_to_file_uri(filename);
editor->position = position;
@@ -61,7 +63,15 @@ void save_file(Editor *editor) {
return;
lock.unlock();
std::ofstream out(editor->filename);
out.write(str, char_count);
if (!editor->unix_eol) {
for (uint32_t i = 0; i < char_count; ++i) {
if (str[i] == '\n')
out.put('\r');
out.put(str[i]);
}
} else {
out.write(str, char_count);
}
out.close();
free(str);
if (editor->lsp) {
@@ -109,7 +119,15 @@ void save_file(Editor *editor) {
return;
lock.unlock();
std::ofstream out(editor->filename);
out.write(str, char_count);
if (!editor->unix_eol) {
for (uint32_t i = 0; i < char_count; ++i) {
if (str[i] == '\n')
out.put('\r');
out.put(str[i]);
}
} else {
out.write(str, char_count);
}
out.close();
free(str);
lsp_send(editor->lsp, save_msg, nullptr);

View File

@@ -186,8 +186,6 @@ void handle_editor_event(Editor *editor, KeyEvent event) {
break;
case SELECT:
if (event.key_type == KEY_CHAR && event.len == 1) {
uint32_t len;
char *text;
switch (event.c[0]) {
case 0x1B:
case 's':

View File

@@ -357,7 +357,6 @@ void handle_mouse(Editor *editor, KeyEvent event) {
std::chrono::steady_clock::now();
static uint32_t click_count = 0;
static Coord last_click_pos = {UINT32_MAX, UINT32_MAX};
uint8_t old_mode = mode;
if (event.key_type == KEY_MOUSE) {
auto now = std::chrono::steady_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(