CC=gcc
-CFLAGS=-c -g
-LDFLAGS=-lcurses
-OBJS=main.o errors.o screen.o buffer.o keyb.o bstrlib.o
+CFLAGS=-c -g `lua-config --include`
+LDFLAGS=-lcurses `lua-config --libs`
+OBJS=main.o errors.o screen.o buffer.o keyb.o bstrlib.o lua-api.o
te: $(OBJS)
$(CC) $(LDFLAGS) -o te $(OBJS)
bstrlib.o: bstrlib.c
$(CC) $(CFLAGS) bstrlib.c
+lua-api.o: lua-api.c
+ $(CC) $(CFLAGS) lua-api.c
+
clean:
rm $(OBJS)
rm *~
int s_offset = bstrrchrp(b, '\n', max(point - 1, 0));
- for (i = s_offset + 1; bchar(b, i) != '\n'; i++) {
+ for (i = s_offset + 1; bchar(b, i) != '\n' && i < blength(b); i++) {
if (bchar(b, i) == '\t')
count += TAB_LEN;
else
screen_delete_char(current_buf);
break;
- case 'u':
- wscrl(buffer_win, -10);
- touchwin(stdscr);
+ case 'w':
+ write_buffer(current_buf);
break;
default:
screen_insert_char(current_buf, c);
init_buffers();
init_windows();
- current_buf = load_buffer("buffer.c");
+ current_buf = load_buffer("README");
paint_buffer(current_buf);
refresh();
input_loop();
}
}
-void screen_move_left(struct te_buffer *buf)
+int screen_move_left(struct te_buffer *buf)
{
if (buf == NULL)
- return;
+ return ERR;
if(move_left(buf) == ERR)
- return;
+ return ERR;
if (curr_char(buf) == '\n') {
screen_prev_line(buf);
}
move(buf->y, buf->x);
+ return OK;
}
-void screen_move_right(struct te_buffer *buf)
+int screen_move_right(struct te_buffer *buf)
{
if (buf == NULL)
- return;
+ return ERR;
if (move_right(buf) == ERR) /* last char of the document */
- return;
+ return ERR;
if (prev_char(buf) == '\n') {
screen_next_line(buf);
}
move(buf->y, buf->x);
+ return OK;
}
void screen_move_up(struct te_buffer *buf)
/* move until the first character of the line */
while(prev_char(buf) != '\n') {
-
if(move_left(buf) == ERR)
break;
}
/* then, move to the beginning of the previous line */
while(prev_char(buf) != '\n') {
-
if(move_left(buf) == ERR)
break;
}
/* mimic emacs' behaviour of moving the user to the exact offset we were on */
while(buf->x < old_x && next_char(buf) != '\n' && curr_char(buf) != '\n') {
- screen_move_right(buf);
+ if (screen_move_right(buf) == ERR)
+ break;
}
move(buf->y, buf->x);
if (buf == NULL)
return;
+ if (buf->point == blength(buf->contents))
+ return;
+
int i = 0;
int old_x = buf->x;
/* mimic emacs' behaviour of moving the user to the exact offset we were on */
while (buf->x < old_x && curr_char(buf) != '\n') {
- screen_move_right(buf);
+ if(screen_move_right(buf) == ERR)
+ return;
}
move(buf->y, buf->x);
void scroll_up(struct te_buffer *buf);
void scroll_down(struct te_buffer *buf);
-void screen_move_left(struct te_buffer *buf);
-void screen_move_right(struct te_buffer *buf);
+int screen_move_left(struct te_buffer *buf);
+int screen_move_right(struct te_buffer *buf);
void screen_move_up(struct te_buffer *buf);
void screen_move_down(struct te_buffer *buf);
void statusprintf(char *fmt, ...);
void miniprintf(char *fmt, ...);
+void notifyprintf(char *fmt, ...);
void console_signal_handler(int sig);