toolchain: add new debugging tool using magenta_debug
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#include "buffer.h"
|
||||
|
||||
#include "line-ed.h"
|
||||
|
||||
#include <fx/stringstream.h>
|
||||
#include <fx/wstr.h>
|
||||
|
||||
const fx_wchar *line_start(struct line_ed *ed, size_t y)
|
||||
{
|
||||
const fx_wchar *line = ed->l_buf;
|
||||
|
||||
for (size_t i = 0; i < y; i++) {
|
||||
line += fx_wstrcspn(line, L"\n");
|
||||
|
||||
if (*line == '\n') {
|
||||
line++;
|
||||
}
|
||||
}
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
size_t line_length(struct line_ed *ed, size_t y)
|
||||
{
|
||||
const fx_wchar *line = ed->l_buf;
|
||||
|
||||
for (size_t i = 0; i < y; i++) {
|
||||
line += fx_wstrcspn(line, L"\n");
|
||||
if (*line == '\n') {
|
||||
line++;
|
||||
}
|
||||
}
|
||||
|
||||
if (*line == '\0') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t len = fx_wstrcspn(line, L"\n");
|
||||
if (line[len] == '\n') {
|
||||
len++;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
Reference in New Issue
Block a user