def update_clipboard(self, method: str, data: list):
"""Handles a clipboard request.
This is called on neovim's event loop, so modifications to GTK widgets
should be done through `GLib.idle_add()`.
:method: `get` to obtain the clipboard's contents or `set` to update
them.
:data: when the method is `set`, contains the lines to add to the
clipboard, else None.
:returns: the clipboard's contents when the method is `get`, else None.
"""
cb = Gtk.Clipboard.get_default(Gdk.Display.get_default())
if method == 'set':
text = '\n'.join(data[0])
return cb.set_text(text, len(text))
if method == 'get':
text = cb.wait_for_text()
return text.split('\n') if text else []
评论列表
文章目录