This is the readme for te, a small text editor that tries to bring some innovation into a field
-that has been left still since the 70's
\ No newline at end of file
+that has been left still since the 70's. The Great Rock'n roll swindle !
\ No newline at end of file
bstring current_line_as_bstring(bstring b, int point)
{
+ if (point > blength(b) - 1)
+ point = blength(b) - 1;
+
int s_offset = bstrrchrp(b, '\n', max(point, 0));
if (s_offset == BSTR_ERR)
s_offset = 0;
int e_offset = bstrchrp(b, '\n', point + 1);
- if (e_offset == BSTR_ERR)
+ if (e_offset == BSTR_ERR) {
e_offset = blength(b);
+ }
- if (s_offset == 0) /* the first line of the file */
+ if (s_offset == 0) /* the first line of the file */
return bmidstr(b, s_offset, e_offset - s_offset);
- else
+ else if (e_offset == blength(b)) {
+ return bmidstr(b, s_offset + 1, e_offset + 1 - s_offset);
+ }
+ else /* otherwise, skip the first '\n' character */
return bmidstr(b, s_offset + 1, e_offset - s_offset);
}
for(i = 0; i < nlines; i++) {
s = current_line_as_bstring(buf->contents, count);
draw_line(s, i);
- count += blength(s);
+ count += blength(s) + 1;
bdestroy(s);
if (count >= blength(buf->contents))
break;
}
-
+
+ miniprintf("count %d", count);
restoreyx();
refresh();
else {
scroll_up(buffer_win);
bstring s = current_line_as_bstring(buf->contents, buf->point - 1);
+ if (biseq(bfromcstr(""), s))
+ return;
+
draw_line(s, LINES - 4);
bdestroy(s);