mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-07 09:38:16 +02:00
Implement copy to clipboard shortcut
This commit is contained in:
10
kitty/glfw.c
10
kitty/glfw.c
@@ -266,6 +266,15 @@ set_click_cursor(Window *self, PyObject *args) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
set_clipboard_string(Window *self, PyObject *args) {
|
||||
char *title;
|
||||
if(!PyArg_ParseTuple(args, "s", &title)) return NULL;
|
||||
glfwSetClipboardString(self->window, title);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
static PyObject*
|
||||
_set_title(Window *self, PyObject *args) {
|
||||
char *title;
|
||||
@@ -286,6 +295,7 @@ static PyMethodDef methods[] = {
|
||||
MND(set_input_mode, METH_VARARGS),
|
||||
MND(is_key_pressed, METH_VARARGS),
|
||||
MND(set_click_cursor, METH_VARARGS),
|
||||
MND(set_clipboard_string, METH_VARARGS),
|
||||
MND(make_context_current, METH_NOARGS),
|
||||
{"set_title", (PyCFunction)_set_title, METH_VARARGS, ""},
|
||||
{NULL} /* Sentinel */
|
||||
|
||||
@@ -208,6 +208,12 @@ class Window:
|
||||
text = text.decode('utf-8')
|
||||
self.paste(text)
|
||||
|
||||
def copy_to_clipboard(self):
|
||||
text = self.char_grid.text_for_selection()
|
||||
if text:
|
||||
tm = tab_manager()
|
||||
tm.queue_ui_action(tm.glfw_window.set_clipboard_string, text)
|
||||
|
||||
def scroll_line_up(self):
|
||||
self.char_grid.scroll('line', True)
|
||||
glfw_post_empty_event()
|
||||
|
||||
Reference in New Issue
Block a user