=================
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. I'm not really proud of it but it works.
-I have to say that this is not everyone's text editor.
\ No newline at end of file
+that has been left still since the 70's. I'm not really proud of it but it works. I have to say that this is not everyone's text editor.
+Building
+========
+
+type 'make' in the te directory to build the te executable.
\ No newline at end of file
refresh();
-/* miniprintf("%c, line length: %d, y: %d, x%d", */
-/* (bchar(current_buf->contents, current_buf->point) == '\n') ? 'N' : bchar(current_buf->contents, current_buf->point), */
-/* screen_line_length(current_buf->contents, current_buf->point), */
-/* current_buf->y, current_buf->x); */
+ miniprintf("%c, line length: %d, y: %d, x%d",
+ (bchar(current_buf->contents, current_buf->point) == '\n') ? 'N' : bchar(current_buf->contents, current_buf->point),
+ screen_line_length(current_buf->contents, current_buf->point),
+ current_buf->y, current_buf->x);
}
break;
case 'i':
+ case 0x1B: /* escape */
case KEY_END:
/* switch between command and input mode */
command_mode = 0;
case KEY_UP:
screen_move_up(current_buf);
break;
-
+
+ case 0x1B: /* escape */
case KEY_END:
command_mode = 1;
miniprintf("-- COMMAND --");
endwin();
}
+void pause(void)
+{
+ /* used for debugging purposes */
+ getch();
+}
+
void paint_buffer(struct te_buffer *buf)
{
paint_buffer_nlines(buf, LINES - 2);
if (c == '\n') {
clrtoeol();
- clear_nfirst_lines(buffer_win, buf->y - 1);
+ clear_nfirst_lines(buffer_win, max(buf->y - 1, 0));
scroll_down(buffer_win);
paint_buffer_nlines(buf, buf->y + 1);
paint_nthline(buf, buf->y + 2, buf->y + 1);
return;
move_left(buf);
- bstring s = current_line_as_bstring(buf->contents, max(buf->point - 1, 0));
+ bstring previous_line = current_line_as_bstring(buf->contents, max(buf->point - 1, 0));
char c = curr_char(buf);
delete_char(buf);
-
-
- buf->dirty = 1;
+ bstring s = current_line_as_bstring(buf->contents, max(buf->point, 0));
if (c == '\n') {
- bstring s2 = current_line_as_bstring(buf->contents, max(buf->point - blength(s), 0));
statusprintf("s : %s", bstr2cstr(s, '\0'));
- clrtoeol();
- clear_nfirst_lines(buffer_win, max(buf->y - 1, 0));
+ clear_nfirst_lines(buffer_win, max(buf->y, 0));
scroll_up(buffer_win);
paint_buffer_nlines(buf, buf->y + 1);
-// screen_prev_line(buf);
screen_prev_line(buf);
- buf->x = screen_line_length(s, 0);
+ buf->x = max(screen_line_length(previous_line, 0) - 1, 0); /* max because scr_l_len("a") == 1 and coords begin at 0 */
+
move(buf->y, buf->x);
} else {
- bstring s = current_line_as_bstring(buf->contents, buf->point - 1);
draw_line(s, buf->y);
screen_move_left(buf);
move_right(buf); /* yes it's ugly but I don't feel like recoding screen_move_right atm */
}
+ bdestroy(previous_line);
+ bdestroy(s);
}
void screen_switch_buffer(struct te_buffer *buf)