Compare commits
No commits in common. "8f917f058c459d2470a43a3ad40c2855080ba69a" and "5c19952c66c40c3d13a50d48b8979f86e66d776d" have entirely different histories.
8f917f058c
...
5c19952c66
|
@ -1,35 +0,0 @@
|
|||
void
|
||||
c_copy(char *c) {
|
||||
c += 2;
|
||||
int start = atoi(c);
|
||||
for(; *c != '\0' && *c != ' '; c++);
|
||||
int end = atoi(c);
|
||||
Row *cpy_start = b_getline(buffer, start);
|
||||
if(cpy_start == NULL || b_getline(buffer, end) == NULL) {
|
||||
puts("invalid line.");
|
||||
return;
|
||||
}
|
||||
if (clipboard != NULL) {
|
||||
b_truncate(clipboard);
|
||||
free(clipboard);
|
||||
}
|
||||
clipboard = calloc(1, sizeof(Row));
|
||||
Row *dest = clipboard;
|
||||
for (int i = start; i <= end; i++) {
|
||||
memcpy(dest->text, cpy_start->text, ROW_SIZE);
|
||||
cpy_start = cpy_start->n;
|
||||
dest = b_insert(dest);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,6 @@ c_unindent(char *c) {
|
|||
for(int i = 0; i < ROW_SIZE - 1; i++) {
|
||||
row->text[i] = row->text[i + 1];
|
||||
}
|
||||
row->text[ROW_SIZE - 1] = 0;
|
||||
row->text[ROW_SIZE] = 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -9,9 +9,5 @@ NULL,
|
|||
['['] = c_unindent,
|
||||
[']'] = c_indent,
|
||||
['d'] = c_delete,
|
||||
['c'] = c_copy,
|
||||
['v'] = c_paste,
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
|
2
efn.c
2
efn.c
|
@ -22,7 +22,5 @@
|
|||
#include "c_indent.c"
|
||||
#include "c_delete.c"
|
||||
|
||||
#include "c_clipboard.c"
|
||||
#include "commands.c"
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue