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);
}
/*
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); */
#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)
{
{
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)
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);
}
void miniprintf(char *fmt, ...)
{
- getyx(stdscr, y, x);
+ saveyx();
va_list ap;
va_start(ap, fmt);
wrefresh(minibuffer_win);
- move(y, x);
+ restoreyx();
}
void console_signal_handler(int sig)