]> khamidou — GitHub mirrors - te.git/commitdiff
fixed this horrible display bug at last
authorkhamidou <karim@lambda-expr.org>
Thu, 25 Jun 2009 08:05:23 +0000 (10:05 +0200)
committerkhamidou <karim@lambda-expr.org>
Thu, 25 Jun 2009 08:05:23 +0000 (10:05 +0200)
buffer.c
keyb.c
screen.c

index 088865a3550873fdaabb8dde31c1becb826dabe2..f2e7418d3cc827df95bd9d8e83cefe6ded3c70df 100644 (file)
--- a/buffer.c
+++ b/buffer.c
@@ -79,15 +79,18 @@ int line_length(bstring b, int point)
 
 bstring current_line_as_bstring(bstring b, int point)
 {
-       int s_offset = bstrrchrp(b, '\n', max(point - 1, 0));
+       int s_offset = bstrrchrp(b, '\n', max(point, 0));
        if (s_offset == BSTR_ERR)
                s_offset = 0;
 
-       int e_offset = bstrchrp(b, '\n', point);
+       int e_offset = bstrchrp(b, '\n', point + 1);
        if (e_offset == BSTR_ERR)
                e_offset = blength(b);
 
-       return bmidstr(b, s_offset, e_offset - s_offset);
+       if (s_offset > 0)
+               return bmidstr(b, s_offset + 1, e_offset - s_offset);
+       else 
+               return bmidstr(b, s_offset, e_offset - s_offset);
 }
 
 /*
diff --git a/keyb.c b/keyb.c
index 82900eb0a0dda7e353faf8f5e2699bf259dda1fd..df14d384be1284d7bffe571272b38dadd3dc874e 100644 (file)
--- a/keyb.c
+++ b/keyb.c
@@ -23,15 +23,14 @@ void input_loop(void)
                        
                default:
                        screen_insert_char(current_buf, c);
-                       paint_buffer(current_buf);
                        refresh();
                        break;
                }
                
                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),  */
+/*             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); */
 
index 9885f7a2f38ac1c92bd1d81badf47822b0045cfc..a03bed5654a8a8c590ee3be0204bcc2877dfbff4 100644 (file)
--- a/screen.c
+++ b/screen.c
@@ -1,10 +1,10 @@
 #include "screen.h"
 
-static int y, x;
+static int scr_y, scr_x;
 
 
-#define saveyx() getyx(stdscr, y,x)
-#define restoreyx() move(y, x)
+#define saveyx() getyx(stdscr, scr_y, scr_x)
+#define restoreyx() move(scr_y, scr_x)
 
 void init_windows(void)
 {
@@ -62,15 +62,19 @@ void draw_line(bstring s, int y)
 {
        int i;
        int j;
+       saveyx();
+       move(y, 0);
+       clrtoeol();
+
        /* FIXME : wrap line if we go beyond COLS */
        for (i = 0; i < blength(s); i++)
-               /* if (bchar(s, i) == '\t') */
+/*             if (bchar(s, i) == '\t') */
 /*                     for (j = 0; j < TAB_LEN; j++) */
-/*                             mvwaddch(buffer_win, y, j, ' '); */
+/*                             mvwaddch(buffer_win, y, i++, ' '); */
 /*             else */
-//                     mvwaddch(buffer_win, y, i, bchar(s, i));
-               waddch(buffer_win, bchar(s, i));
+                       mvwaddch(buffer_win, y, i, bchar(s, i));
 
+       restoreyx();
 }
 
 void scroll_up(struct te_buffer *buf)
@@ -198,13 +202,12 @@ void screen_insert_char(struct te_buffer *buf, char c)
        if (buf == NULL)
                return;
 
-       statusprintf("buf x : %d, y : %d", buf->x, buf->y);
        insert_char(buf, c);
        
        bstring s = current_line_as_bstring(buf->contents, buf->point);
        miniprintf("%s", bstr2cstr(s, '\0'));
        draw_line(s, buf->y);
-
+       screen_move_right(buf);
        
 }
 
@@ -244,7 +247,7 @@ void statusprintf(char *fmt, ...)
 
 void miniprintf(char *fmt, ...)
 {
-       getyx(stdscr, y, x);
+       saveyx();
 
        va_list ap;
        va_start(ap, fmt);
@@ -254,7 +257,7 @@ void miniprintf(char *fmt, ...)
 
        wrefresh(minibuffer_win);
 
-       move(y, x);
+       restoreyx();
 }
 
 void console_signal_handler(int sig)