Files
rosetta/toolchain/mxdbg/client/line-ed/buffer.c
T

45 lines
650 B
C

#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;
}