return;
binsertch(buf->contents, buf->point, 1, c);
+ return;
+}
+
+void delete_char(struct te_buffer *buf)
+{
+ if (buf == NULL)
+ return;
+ bdelete(buf->contents, buf->point, 1);
+ move_left(buf);
return;
}
+void write_buffer(struct te_buffer *buf)
+{
+ if (buf == NULL)
+ return;
+
+ char *c = bstr2cstr(buf->contents, '\0');
+ FILE *fp = fopen(buf->name, "w+");
+
+ if (fp == NULL)
+ notifyprintf("Unable to open %s", buf->name);
+
+ fwrite(c, strlen(c), sizeof(char), fp);
+
+ free(c);
+}
int move_right(struct te_buffer *buf);
int move_left(struct te_buffer *buf);
void insert_char(struct te_buffer *buf, char c);
+void delete_char(struct te_buffer *buf);
#endif
screen_move_up(current_buf);
break;
+ case KEY_BACKSPACE:
+ screen_delete_char(current_buf);
+ break;
+
case 'u':
wscrl(buffer_win, -10);
touchwin(stdscr);
}
+void screen_delete_char(struct te_buffer *buf)
+{
+ if (buf == NULL)
+ return;
+
+ delete_char(buf);
+
+ bstring s = current_line_as_bstring(buf->contents, buf->point);
+ 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 */
+}
+
/*
display a message in the status bar.
*/
restoreyx();
}
+/*
+ notifyprintf : display a message in the minibuffer and wait that the user
+ presses a key.
+ */
+void notifyprintf(char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ miniprintf(fmt, ap);
+ va_end(ap);
+
+ getch(); /* discard input */
+}
+
+
void console_signal_handler(int sig)
{
switch(sig) {