diff --git a/c_clipboard.c b/c_clipboard.c index 99ba56e..c044e8b 100644 --- a/c_clipboard.c +++ b/c_clipboard.c @@ -22,3 +22,14 @@ c_copy(char *c) { } } +void +c_paste(char *c) { + Row *line = b_getline(buffer, atoi(c + 2)); + if (line == NULL) {puts("invalid line."); return; } + if (clipboard == NULL) {puts("empty clipboard"); return; } + for (Row *cb = clipboard; cb->n != NULL; cb = cb->n) { + line = b_insert(line); + memcpy(line->text, cb->text, ROW_SIZE); + } +} + diff --git a/commands.c b/commands.c index dceba32..4ccca99 100644 --- a/commands.c +++ b/commands.c @@ -10,6 +10,8 @@ NULL, [']'] = c_indent, ['d'] = c_delete, ['c'] = c_copy, +['v'] = c_paste, }; +