mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-12 03:29:10 +02:00
A new option strip_trailing_spaces to optionally remove trailing spaces from lines when copying to clipboard.
This commit is contained in:
@@ -6,6 +6,9 @@ Changelog
|
||||
0.13.4 [future]
|
||||
---------------------
|
||||
|
||||
- A new option :opt:`strip_trailing_spaces` to optionally remove trailing
|
||||
spaces from lines when copying to clipboard.
|
||||
|
||||
- macOS: Fix :kbd:`cmd+period` key not working (:iss:`1318`)
|
||||
|
||||
|
||||
|
||||
@@ -398,6 +398,11 @@ such as macOS that do not have the concept of primary selections. Note
|
||||
that this is a security risk, as all programs, including websites open in your
|
||||
browser can read the contents of the clipboard.'''))
|
||||
|
||||
o('strip_trailing_spaces', 'never', option_type=choices('never', 'smart', 'always'), long_text=_('''
|
||||
Remove spaces at the end of lines when copying to clipboard.
|
||||
A value of :code:`smart` will do it when using normal selections, but not rectangle
|
||||
selections. :code:`always` will always do it.'''))
|
||||
|
||||
o('rectangle_select_modifiers', 'ctrl+alt', option_type=to_modifiers, long_text=_('''
|
||||
The modifiers to use rectangular selection (i.e. to select text in a
|
||||
rectangular block with the mouse)'''))
|
||||
|
||||
@@ -1918,6 +1918,13 @@ start_selection(Screen *self, PyObject *args) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
is_rectangle_select(Screen *self, PyObject *a UNUSED) {
|
||||
PyObject *ans = self->selection.rectangle_select ? Py_True : Py_False;
|
||||
Py_INCREF(ans);
|
||||
return ans;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
text_for_selection(Screen *self, PyObject *a UNUSED) {
|
||||
FullSelectionBoundary start, end;
|
||||
@@ -2211,6 +2218,7 @@ static PyMethodDef methods[] = {
|
||||
MND(set_margins, METH_VARARGS)
|
||||
MND(rescale_images, METH_NOARGS)
|
||||
MND(text_for_selection, METH_NOARGS)
|
||||
MND(is_rectangle_select, METH_NOARGS)
|
||||
MND(scroll, METH_VARARGS)
|
||||
MND(send_escape_code_to_child, METH_VARARGS)
|
||||
MND(toggle_alt_screen, METH_NOARGS)
|
||||
|
||||
@@ -451,7 +451,11 @@ class Window:
|
||||
# }}}
|
||||
|
||||
def text_for_selection(self):
|
||||
return ''.join(self.screen.text_for_selection())
|
||||
lines = self.screen.text_for_selection()
|
||||
if self.opts.strip_trailing_spaces == 'always' or (
|
||||
self.opts.strip_trailing_spaces == 'smart' and not self.screen.is_rectangle_select()):
|
||||
lines = [l.rstrip() for l in lines]
|
||||
return ''.join(lines)
|
||||
|
||||
def destroy(self):
|
||||
self.destroyed = True
|
||||
|
||||
Reference in New Issue
Block a user