summaryrefslogtreecommitdiff
path: root/lua/telescope/utils.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/telescope/utils.lua')
-rw-r--r--lua/telescope/utils.lua94
1 files changed, 10 insertions, 84 deletions
diff --git a/lua/telescope/utils.lua b/lua/telescope/utils.lua
index d9e4ec0..3938bae 100644
--- a/lua/telescope/utils.lua
+++ b/lua/telescope/utils.lua
@@ -377,94 +377,20 @@ function utils.get_os_command_output(cmd, cwd)
return stdout, ret, stderr
end
-utils.strdisplaywidth = (function()
- if jit and pathlib.separator ~= '\\' then
- local ffi = require('ffi')
- ffi.cdef[[
- typedef unsigned char char_u;
- int linetabsize_col(int startcol, char_u *s);
- ]]
-
- return function(str, col)
- local startcol = col or 0
- str = tostring(str)
- local s = ffi.new('char[?]', #str + 1)
- ffi.copy(s, str)
- return ffi.C.linetabsize_col(startcol, s) - startcol
- end
- else
- return function(str, col)
- return #(tostring(str)) - (col or 0)
- end
- end
-end)()
-
-utils.utf_ptr2len = (function()
- if jit and pathlib.separator ~= '\\' then
- local ffi = require('ffi')
- ffi.cdef[[
- typedef unsigned char char_u;
- int utf_ptr2len(const char_u *const p);
- ]]
-
- return function(str)
- local c_str = ffi.new('char[?]', #str + 1)
- ffi.copy(c_str, str)
- return ffi.C.utf_ptr2len(c_str)
- end
- else
- return function(str)
- return str == '' and 0 or 1
- end
- end
-end)()
-
-function utils.strcharpart(str, nchar, charlen)
- local nbyte = 0
- if nchar > 0 then
- while nchar > 0 and nbyte < #str do
- nbyte = nbyte + utils.utf_ptr2len(str:sub(nbyte + 1))
- nchar = nchar - 1
- end
- else
- nbyte = nchar
- end
-
- local len = 0
- if charlen then
- while charlen > 0 and nbyte + len < #str do
- local off = nbyte + len
- if off < 0 then
- len = len + 1
- else
- len = len + utils.utf_ptr2len(str:sub(off + 1))
- end
- charlen = charlen - 1
- end
- else
- len = #str - nbyte
- end
+utils.strdisplaywidth = function()
+ error("strdisplaywidth deprecated. please use plenary.strings.strdisplaywidth")
+end
- if nbyte < 0 then
- len = len + nbyte
- nbyte = 0
- elseif nbyte > #str then
- nbyte = #str
- end
- if len < 0 then
- len = 0
- elseif nbyte + len > #str then
- len = #str - nbyte
- end
+utils.utf_ptr2len = function()
+ error("utf_ptr2len deprecated. please use plenary.strings.utf_ptr2len")
+end
- return str:sub(nbyte + 1, nbyte + len)
+utils.strcharpart = function()
+ error("strcharpart deprecated. please use plenary.strings.strcharpart")
end
-utils.align_str = function(string, width, right_justify)
- local str_len = utils.strdisplaywidth(string)
- return right_justify
- and string.rep(" ", width - str_len)..string
- or string..string.rep(" ", width - str_len)
+utils.align_str = function()
+ error("align_str deprecated. please use plenary.strings.align_str")
end
utils.transform_devicons = (function()