ref: 390569e0185d717594413aa0e7ce7265529d25e8
parent: e0f8528e10df8849cdfc14ead966698b15b941be
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Feb 24 17:30:00 EST 2020
plan9: ctrl+shift+v: paste with ignoring empty cells (do not overwrite destination if possible)
--- a/orca.man
+++ b/orca.man
@@ -104,6 +104,10 @@
.B Ctrl+v
Paste from the snarf buffer.
.TP
+.B Ctrl+Shift+v
+Paste from the snarf buffer, ignoring empty cells within it, thus not
+overwriting what's been at the destination if possible.
+.TP
.B Ctrl+z
Undo.
.TP
--- a/plan9.c
+++ b/plan9.c
@@ -287,16 +287,19 @@
selpasteb(Biobuf *b)
{
char *s;
- int cols, rows, i, n;
+ int cols, rows, i, n, off;
+ Glyph c;
for (cols = rows = 0; (s = Brdstr(b, '\n', 1)) != nil;) {
if ((n = Blinelen(b)) > cols)
cols = MIN(n, field.width-sel.min.x);
if (sel.min.y+rows < field.height) {
- for (i = 0; i < n; i++)
- if (!orca_is_valid_glyph(s[i]))
- s[i] = '.';
- memmove(&field.buffer[sel.min.x + field.width*(sel.min.y+rows)], s, MIN(n, field.width-sel.min.x));
+ off = sel.min.x + field.width*(sel.min.y+rows);
+ for (i = 0; i < MIN(n, field.width-sel.min.x); i++) {
+ c = orca_is_valid_glyph(s[i]) ? s[i] : '.';
+ if (c != '.' || !shiftdown)
+ field.buffer[off+i] = c;
+ }
rows++;
}
free(s);