void screen_prev_line(struct te_buffer *buf) { if (buf == NULL) return; if (buf->y > 0) { buf->y--; buf->x = screen_line_length(buf->contents, buf->point); } else { if (bstrrchrp(buf->contents, '\n', buf->point) == BSTR_ERR) /* is it the first line of the file ? */ return; scroll_down(buffer_win); bstring s = current_line_as_bstring(buf->contents, buf->point - 1); draw_line(s, 0); bdestroy(s); /* update buf->top_char */ s = current_line_as_bstring(buf->contents, buf->top_char); buf->top_char -= blength(s); buf->top_char = max(buf->top_char, 0); bdestroy(s); } }
void Parse_print_error(const char *message, bstring content, int at, int line_number) { int prev_nl = bstrrchrp(content, '\n', at); int next_nl = bstrchrp(content, '\n', at); if(prev_nl < 0) { log_err("%s AT '%c' on line %d:\n%.*s\n%*s", message, bchar(content, at), line_number-1, next_nl, bdata(content), at, "^"); } else { log_err("%s AT '%c' on line %d:%.*s\n%*s", message, bchar(content, at), line_number, next_nl - prev_nl, bdataofs(content, prev_nl), at - prev_nl, "^"); } }