Cleanup
This commit is contained in:
@@ -21,7 +21,7 @@ curl https://syedm.dev/crib | sh
|
|||||||
```
|
```
|
||||||
|
|
||||||
Currently only for Linux.<br>
|
Currently only for Linux.<br>
|
||||||
*Tested with arch linux and ubuntu and void*<br>
|
*Tested with arch linux, ubuntu and void*<br>
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ struct VisualIterator {
|
|||||||
std::stack<std::pair<Coord, Coord>> prev_stack;
|
std::stack<std::pair<Coord, Coord>> prev_stack;
|
||||||
|
|
||||||
VisualIterator(Knot *root, Coord pos, uint32_t width)
|
VisualIterator(Knot *root, Coord pos, uint32_t width)
|
||||||
: it(begin_l_iter(root, pos.row)), offset(pos.col),
|
: it(begin_l_iter(root, pos.row)), line_index(pos.row - 1),
|
||||||
line_index(pos.row - 1), render_width(width) {}
|
offset(pos.col), render_width(width) {}
|
||||||
|
|
||||||
std::pair<Coord, Coord> prev() {
|
std::pair<Coord, Coord> prev() {
|
||||||
if (!it)
|
if (!it)
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ struct LSPInstance {
|
|||||||
if (pfd.revents & POLLIN) {
|
if (pfd.revents & POLLIN) {
|
||||||
json exit_msg = {{"jsonrpc", "2.0"}, {"method", "exit"}};
|
json exit_msg = {{"jsonrpc", "2.0"}, {"method", "exit"}};
|
||||||
send_raw(exit_msg);
|
send_raw(exit_msg);
|
||||||
int waited = 0;
|
uint32_t waited = 0;
|
||||||
while (waited < timeout) {
|
while (waited < timeout) {
|
||||||
int status;
|
int status;
|
||||||
pid_t res = waitpid(pid, &status, WNOHANG);
|
pid_t res = waitpid(pid, &status, WNOHANG);
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ std::string percent_encode(const std::string &s);
|
|||||||
std::string percent_decode(const std::string &s);
|
std::string percent_decode(const std::string &s);
|
||||||
uint32_t count_clusters(const char *line, size_t len, size_t from, size_t to);
|
uint32_t count_clusters(const char *line, size_t len, size_t from, size_t to);
|
||||||
std::string trim(const std::string &s);
|
std::string trim(const std::string &s);
|
||||||
|
std::string strip_newlines(const std::string &s);
|
||||||
std::string substitute_fence(const std::string &documentation,
|
std::string substitute_fence(const std::string &documentation,
|
||||||
const std::string &lang);
|
const std::string &lang);
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "syntax/decl.h"
|
#include "syntax/decl.h"
|
||||||
#include "windows/decl.h"
|
#include "windows/decl.h"
|
||||||
|
|
||||||
void Bar::log(std::string message) { log_line = message; }
|
void Bar::log(std::string message) { log_line = strip_newlines(message); }
|
||||||
|
|
||||||
void Bar::render(std::vector<ScreenCell> &buffer) {
|
void Bar::render(std::vector<ScreenCell> &buffer) {
|
||||||
USING(LSPInstance);
|
USING(LSPInstance);
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ char *load_file(const char *path, uint32_t *out_len, bool *out_eol) {
|
|||||||
bool has_utf8_bom = (bom[0] == 0xEF && bom[1] == 0xBB && bom[2] == 0xBF);
|
bool has_utf8_bom = (bom[0] == 0xEF && bom[1] == 0xBB && bom[2] == 0xBF);
|
||||||
uint32_t skip = has_utf8_bom ? 3 : 0;
|
uint32_t skip = has_utf8_bom ? 3 : 0;
|
||||||
uint32_t data_len = static_cast<uint32_t>(len) - skip;
|
uint32_t data_len = static_cast<uint32_t>(len) - skip;
|
||||||
|
file.clear();
|
||||||
file.seekg(skip, std::ios::beg);
|
file.seekg(skip, std::ios::beg);
|
||||||
char *buf = (char *)malloc(data_len + 1);
|
char *buf = (char *)malloc(data_len + 1);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
|
|||||||
@@ -91,6 +91,15 @@ std::string trim(const std::string &s) {
|
|||||||
return s.substr(start, end - start + 1);
|
return s.substr(start, end - start + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string strip_newlines(const std::string &s) {
|
||||||
|
std::string out;
|
||||||
|
out.reserve(s.size());
|
||||||
|
for (char c : s)
|
||||||
|
if (c != '\n' && c != '\r')
|
||||||
|
out.push_back(c);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
std::string clean_text(const std::string &input) {
|
std::string clean_text(const std::string &input) {
|
||||||
std::string result = input;
|
std::string result = input;
|
||||||
static const std::unordered_map<std::string, std::string> entities = {
|
static const std::unordered_map<std::string, std::string> entities = {
|
||||||
|
|||||||
Reference in New Issue
Block a user