-Te, a textawq editor
+Te, a text editor
=================
-This is the readme for te, a small text editor thatsqs 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.The Great Rock'n roll swindle !
\ No newline at end of file
+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
#include "util.h"
#include "keyb.h"
-static int scr_y, scr_x;
-
-#define saveyx() getyx(stdscr, scr_y, scr_x)
-#define restoreyx() move(scr_y, scr_x)
+#define saveyx() { int scr_y, scr_x; getyx(stdscr, scr_y, scr_x); do { } while(0)
+#define restoreyx() move(scr_y, scr_x); } do { } while(0)
void init_windows(void)
{
saveyx();
move(y, 0);
clrtoeol();
-
+
/* FIXME : wrap line if we go beyond COLS */
for (i = 0; i < blength(s); i++) {
+ if (i == COLS - 1) {
+ mvwaddch(buffer_win, y, screen_abs, '\\');
+ goto bail_out;
+ return;
+ }
+
if (bchar(s, i) == '\t') {
for (j = 0; j < TAB_LEN; j++)
mvwaddch(buffer_win, y, screen_abs++, ' ');
- } else if (i == COLS - 1) {
- mvwaddch(buffer_win, y, screen_abs, '\\');
- screen_next_line(current_buf);
- } else {
+ } else {
mvwaddch(buffer_win, y, screen_abs, bchar(s, i));
screen_abs++;
}
}
+
+bail_out:
restoreyx();
}
} else {
buf->x++;
}
+
+ if(buf->x == COLS - 1) {
+ bstring s = current_line_as_bstring(buf->contents, buf->point);
+ int off = screen_numchar_to_offset(s, COLS - 1);
+ bstring s2 = bmidstr(s, off, blength(s) - off);
+ draw_line(s2, buf->y);
+ bdestroy(s);
+ bdestroy(s2);
+ wmove(buffer_win, buf->y, 0);
+ refresh();
+ }
}
move(buf->y, buf->x);
bstring s = current_line_as_bstring(buf->contents, max(buf->point - 1, 0));
char c = curr_char(buf);
delete_char(buf);
- move_right(buf);
- if (buf->dirty < 1)
- buf->dirty = 1;
+
+ buf->dirty = 1;
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, buf->y);
+ clear_nfirst_lines(buffer_win, max(buf->y - 1, 0));
scroll_up(buffer_win);
paint_buffer_nlines(buf, buf->y + 1);
// screen_prev_line(buf);