Updating a bunch of stuff.
This commit is contained in:
1
erow.c
1
erow.c
@@ -91,6 +91,7 @@ erow_insert(int at, char *s, int len)
|
|||||||
assert(editor->row != NULL);
|
assert(editor->row != NULL);
|
||||||
|
|
||||||
if (at < editor->nrows) {
|
if (at < editor->nrows) {
|
||||||
|
printf("%d, %d\n", at, editor->nrows);
|
||||||
memmove(&editor->row[at+1], &editor->row[at],
|
memmove(&editor->row[at+1], &editor->row[at],
|
||||||
sizeof(struct erow) * (editor->nrows - at + 1));
|
sizeof(struct erow) * (editor->nrows - at + 1));
|
||||||
}
|
}
|
||||||
|
|||||||
28
main.c
28
main.c
@@ -40,6 +40,8 @@
|
|||||||
void editor_set_status(const char *fmt, ...);
|
void editor_set_status(const char *fmt, ...);
|
||||||
void display_refresh();
|
void display_refresh();
|
||||||
char *editor_prompt(char *, void (*cb)(char *, int16_t));
|
char *editor_prompt(char *, void (*cb)(char *, int16_t));
|
||||||
|
void init_editor();
|
||||||
|
void process_normal(int16_t c);
|
||||||
|
|
||||||
|
|
||||||
enum KeyPress {
|
enum KeyPress {
|
||||||
@@ -547,6 +549,24 @@ editor_find()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
editor_openfile()
|
||||||
|
{
|
||||||
|
char *filename;
|
||||||
|
|
||||||
|
/* TODO(kyle): combine with dirutils for tab-completion */
|
||||||
|
filename = editor_prompt("Load file: %s", NULL);
|
||||||
|
if (filename == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(editor->row);
|
||||||
|
init_editor();
|
||||||
|
|
||||||
|
open_file(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
move_cursor(int16_t c)
|
move_cursor(int16_t c)
|
||||||
{
|
{
|
||||||
@@ -667,10 +687,18 @@ process_kcommand(int16_t c)
|
|||||||
case 'w':
|
case 'w':
|
||||||
exit(save_file());
|
exit(save_file());
|
||||||
case 'd':
|
case 'd':
|
||||||
|
while ((editor->row[editor->cury].size - editor->curx) > 0) {
|
||||||
|
process_normal(DEL_KEY);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case CTRL_KEY('\\'):
|
case CTRL_KEY('\\'):
|
||||||
/* sometimes it's nice to dump core */
|
/* sometimes it's nice to dump core */
|
||||||
disable_termraw();
|
disable_termraw();
|
||||||
abort();
|
abort();
|
||||||
|
case 'e':
|
||||||
|
case CTRL_KEY('e'):
|
||||||
|
editor_openfile();
|
||||||
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
editor_find();
|
editor_find();
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user