From a24563042236b0d73fa6d7d9e2ee884f183e0128 Mon Sep 17 00:00:00 2001 From: poire-z Date: Tue, 15 Jan 2019 18:40:36 +0100 Subject: [PATCH] Implement generic internal clipboard for all devices Will allow copying selected text from a book to the TextEditor. Will be overriden on devices that implement interactions with the system clipboard. --- frontend/device/generic/device.lua | 2 +- frontend/device/input.lua | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/frontend/device/generic/device.lua b/frontend/device/generic/device.lua index c592b39e8..e6d536b5b 100644 --- a/frontend/device/generic/device.lua +++ b/frontend/device/generic/device.lua @@ -24,7 +24,7 @@ local Device = { isTouchDevice = no, hasFrontlight = no, needsTouchScreenProbe = no, - hasClipboard = no, + hasClipboard = yes, -- generic internal clipboard on all devices hasColorScreen = no, hasBGRFrameBuffer = no, canToggleGSensor = no, diff --git a/frontend/device/input.lua b/frontend/device/input.lua index b87a7a6a0..5d130ec00 100755 --- a/frontend/device/input.lua +++ b/frontend/device/input.lua @@ -75,6 +75,8 @@ local MSC_RAW_GSENSOR_FRONT = 0x1c -- luacheck: pop +local _internal_clipboard_text = nil -- holds the last copied text + local Input = { -- this depends on keyboard layout and should be overridden: event_map = {}, @@ -141,6 +143,17 @@ local Input = { } }, gesture_detector = nil, + + -- simple internal clipboard implementation, can be overidden to use system clipboard + hasClipboardText = function() + return _internal_clipboard_text ~= nil and _internal_clipboard_text ~= "" + end, + getClipboardText = function() + return _internal_clipboard_text + end, + setClipboardText = function(text) + _internal_clipboard_text = text + end, } function Input:new(o)