aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/clipboard
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2023-11-14 05:15:45 -0800
committerGitHub <noreply@github.com>2023-11-14 05:15:45 -0800
commitb73a829837bbc05840ae00cbe514fb1786695614 (patch)
treebe21628b373bbec5c6dc2fe42d24eb2dd3b125b5 /runtime/lua/vim/clipboard
parent5b45efbee6ebb64269469b636baac5248e83421f (diff)
downloadrneovim-b73a829837bbc05840ae00cbe514fb1786695614.tar.gz
rneovim-b73a829837bbc05840ae00cbe514fb1786695614.tar.bz2
rneovim-b73a829837bbc05840ae00cbe514fb1786695614.zip
refactor: vim.ui.clipboard #26040
Problem: Platform-specific UI providers should live in `vim.ui.*`. #24164 Solution: - Move `vim.clipboard.osc52` module to `vim.ui.clipboard.osc52`. - TODO: move all of `clipboard.vim` to `vim.ui.clipboard`. ref #25872
Diffstat (limited to 'runtime/lua/vim/clipboard')
-rw-r--r--runtime/lua/vim/clipboard/osc52.lua60
1 files changed, 0 insertions, 60 deletions
diff --git a/runtime/lua/vim/clipboard/osc52.lua b/runtime/lua/vim/clipboard/osc52.lua
deleted file mode 100644
index 035a6abb86..0000000000
--- a/runtime/lua/vim/clipboard/osc52.lua
+++ /dev/null
@@ -1,60 +0,0 @@
-local M = {}
-
-function M.copy(lines)
- local s = table.concat(lines, '\n')
- io.stdout:write(string.format('\027]52;;%s\027\\', vim.base64.encode(s)))
-end
-
-function M.paste()
- local contents = nil
- local id = vim.api.nvim_create_autocmd('TermResponse', {
- callback = function(args)
- local resp = args.data ---@type string
- local encoded = resp:match('\027%]52;%w?;([A-Za-z0-9+/=]*)')
- if encoded then
- contents = vim.base64.decode(encoded)
- return true
- end
- end,
- })
-
- io.stdout:write('\027]52;;?\027\\')
-
- local ok, res
-
- -- Wait 1s first for terminals that respond quickly
- ok, res = vim.wait(1000, function()
- return contents ~= nil
- end)
-
- if res == -1 then
- -- If no response was received after 1s, print a message and keep waiting
- vim.api.nvim_echo(
- { { 'Waiting for OSC 52 response from the terminal. Press Ctrl-C to interrupt...' } },
- false,
- {}
- )
- ok, res = vim.wait(9000, function()
- return contents ~= nil
- end)
- end
-
- if not ok then
- vim.api.nvim_del_autocmd(id)
- if res == -1 then
- vim.notify(
- 'Timed out waiting for a clipboard response from the terminal',
- vim.log.levels.WARN
- )
- elseif res == -2 then
- -- Clear message area
- vim.api.nvim_echo({ { '' } }, false, {})
- end
- return 0
- end
-
- -- If we get here, contents should be non-nil
- return vim.split(assert(contents), '\n')
-end
-
-return M