Fix newlines being inserted at wrapping boundaries when copying. Fixes #55
This commit is contained in:
parent
96be8dcb2c
commit
ff966f667c
@ -196,12 +196,15 @@ class Selection: # {{{
|
|||||||
if y == b[0]:
|
if y == b[0]:
|
||||||
endx = max(0, min(b[1], endx))
|
endx = max(0, min(b[1], endx))
|
||||||
l = line(y)
|
l = line(y)
|
||||||
|
is_continued = l.is_continued()
|
||||||
if endx - startx >= linebuf.xnum - 1:
|
if endx - startx >= linebuf.xnum - 1:
|
||||||
l = str(l).rstrip(' ')
|
l = str(l).rstrip(' ')
|
||||||
else:
|
else:
|
||||||
l = ''.join(l[x] for x in range(startx, endx + 1))
|
l = ''.join(l[x] for x in range(startx, endx + 1))
|
||||||
|
if not is_continued and startx == 0 and len(lines) > 0:
|
||||||
|
l = '\n' + l
|
||||||
lines.append(l)
|
lines.append(l)
|
||||||
return '\n'.join(lines)
|
return ''.join(lines)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
18
kitty/line.c
18
kitty/line.c
@ -200,6 +200,14 @@ as_ansi(Line* self) {
|
|||||||
return ans;
|
return ans;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject*
|
||||||
|
is_continued(Line* self) {
|
||||||
|
#define is_continued_doc "Return the line's continued flag"
|
||||||
|
PyObject *ans = self->continued ? Py_True : Py_False;
|
||||||
|
Py_INCREF(ans);
|
||||||
|
return ans;
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
__repr__(Line* self) {
|
__repr__(Line* self) {
|
||||||
PyObject *s = as_unicode(self);
|
PyObject *s = as_unicode(self);
|
||||||
@ -305,7 +313,8 @@ cursor_from(Line* self, PyObject *args) {
|
|||||||
return (PyObject*)ans;
|
return (PyObject*)ans;
|
||||||
}
|
}
|
||||||
|
|
||||||
void line_clear_text(Line *self, unsigned int at, unsigned int num, int ch) {
|
void
|
||||||
|
line_clear_text(Line *self, unsigned int at, unsigned int num, int ch) {
|
||||||
const char_type repl = ((char_type)ch & CHAR_MASK) | (1 << ATTRS_SHIFT);
|
const char_type repl = ((char_type)ch & CHAR_MASK) | (1 << ATTRS_SHIFT);
|
||||||
for (index_type i = at; i < MIN(self->xnum, at + num); i++) {
|
for (index_type i = at; i < MIN(self->xnum, at + num); i++) {
|
||||||
self->chars[i] = (self->chars[i] & ATTRS_MASK_WITHOUT_WIDTH) | repl;
|
self->chars[i] = (self->chars[i] & ATTRS_MASK_WITHOUT_WIDTH) | repl;
|
||||||
@ -323,7 +332,8 @@ clear_text(Line* self, PyObject *args) {
|
|||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void line_apply_cursor(Line *self, Cursor *cursor, unsigned int at, unsigned int num, bool clear_char) {
|
void
|
||||||
|
line_apply_cursor(Line *self, Cursor *cursor, unsigned int at, unsigned int num, bool clear_char) {
|
||||||
char_type attrs = CURSOR_TO_ATTRS(cursor, 1);
|
char_type attrs = CURSOR_TO_ATTRS(cursor, 1);
|
||||||
color_type col = (cursor->fg & COL_MASK) | ((color_type)(cursor->bg & COL_MASK) << COL_SHIFT);
|
color_type col = (cursor->fg & COL_MASK) | ((color_type)(cursor->bg & COL_MASK) << COL_SHIFT);
|
||||||
decoration_type dfg = cursor->decoration_fg & COL_MASK;
|
decoration_type dfg = cursor->decoration_fg & COL_MASK;
|
||||||
@ -390,7 +400,8 @@ left_shift(Line *self, PyObject *args) {
|
|||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void line_set_char(Line *self, unsigned int at, uint32_t ch, unsigned int width, Cursor *cursor) {
|
void
|
||||||
|
line_set_char(Line *self, unsigned int at, uint32_t ch, unsigned int width, Cursor *cursor) {
|
||||||
char_type attrs;
|
char_type attrs;
|
||||||
if (cursor == NULL) {
|
if (cursor == NULL) {
|
||||||
attrs = (((self->chars[at] >> ATTRS_SHIFT) & ~3) | (width & 3)) << ATTRS_SHIFT;
|
attrs = (((self->chars[at] >> ATTRS_SHIFT) & ~3) | (width & 3)) << ATTRS_SHIFT;
|
||||||
@ -470,6 +481,7 @@ static PyMethodDef methods[] = {
|
|||||||
METHOD(set_attribute, METH_VARARGS)
|
METHOD(set_attribute, METH_VARARGS)
|
||||||
METHOD(as_base_text, METH_NOARGS)
|
METHOD(as_base_text, METH_NOARGS)
|
||||||
METHOD(as_ansi, METH_NOARGS)
|
METHOD(as_ansi, METH_NOARGS)
|
||||||
|
METHOD(is_continued, METH_NOARGS)
|
||||||
METHOD(width, METH_O)
|
METHOD(width, METH_O)
|
||||||
METHOD(basic_cell_data, METH_O)
|
METHOD(basic_cell_data, METH_O)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user