summaryrefslogtreecommitdiff
path: root/lua/clever_f/feedback_service.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/clever_f/feedback_service.lua')
-rw-r--r--lua/clever_f/feedback_service.lua17
1 files changed, 13 insertions, 4 deletions
diff --git a/lua/clever_f/feedback_service.lua b/lua/clever_f/feedback_service.lua
index a06f6d8..e8c387d 100644
--- a/lua/clever_f/feedback_service.lua
+++ b/lua/clever_f/feedback_service.lua
@@ -88,6 +88,7 @@ local function require_host(host)
or type(host.define_highlight_group) ~= "function"
or type(host.create_highlight) ~= "function"
or type(host.remove_highlight) ~= "function"
+ or type(host.supports_cursor_presentation) ~= "function"
or type(host.suppress_cursor_presentation) ~= "function"
or type(host.restore_cursor_presentation) ~= "function"
then
@@ -111,6 +112,7 @@ local function require_policy(service, host)
service = service or policy.new(host)
if type(service) ~= "table"
or type(service.evaluate_highlight_links) ~= "function"
+ or type(service.sample_acquisition) ~= "function"
then
fail("FeedbackService policy must evaluate highlight links", 3)
end
@@ -160,9 +162,9 @@ local cursor_lease_metatable = {
__metatable = "clever_f.feedback_service.CursorPresentationLease",
}
-local function new_cursor_presentation_lease(host)
+local function new_cursor_presentation_lease(host, suppress)
local lease = setmetatable({}, cursor_lease_metatable)
- local identity = host:suppress_cursor_presentation()
+ local identity = suppress and host:suppress_cursor_presentation() or nil
cursor_lease_records[lease] = {
host = host,
identity = identity,
@@ -188,8 +190,15 @@ function CursorPresentationLease:release()
return true
end
-function FeedbackService:create_cursor_presentation_lease()
- return new_cursor_presentation_lease(service_records[self].host)
+function FeedbackService:create_cursor_presentation_lease(enabled)
+ local record = service_records[self]
+ if enabled == nil then
+ enabled = record.policy:sample_acquisition().hide_cursor_on_cmdline
+ elseif type(enabled) ~= "boolean" then
+ fail("cursor presentation policy must be a Boolean", 2)
+ end
+ local supported = enabled and record.host:supports_cursor_presentation()
+ return new_cursor_presentation_lease(record.host, supported == true)
end
function FeedbackService:create_cursor_marker(position, window)