#include "buffer.h" #include "line-ed.h" const char *line_start(struct line_ed *ed, size_t y) { const char *line = ed->l_buf; for (size_t i = 0; i < y; i++) { line += strcspn(line, "\n"); if (*line == '\n') { line++; } } return line; } size_t line_length(struct line_ed *ed, size_t y) { const char *line = ed->l_buf; for (size_t i = 0; i < y; i++) { line += strcspn(line, "\n"); if (*line == '\n') { line++; } } if (*line == '\0') { return 0; } size_t len = strcspn(line, "\n"); if (line[len] == '\n') { len++; } return len; }