vimio's C language acceleration module
vimio_c/
├── Makefile
├── vimio.h
├── vimio.c
├── uthash.h ← download from https://troydhanson.github.io/uthash/
├── cJSON.h ← download from https://github.com/DaveGamble/cJSON
├── cJSON.c- input data
{"10,74":["━","─"],"10,75":["━","┼"],"10,76":["━","─"],"10,77":["━","─"],"10,78":["━","┼"],"10,79":["━","─"]}
{"11,75":["│"],"10,74":["━","─"],"10,75":["━","┼"],"10,76":["━","─"],"10,77":["━","─"],"10,78":["━","┼"],"10,79":["━","─"],"9,75":["│"],"10,80":["─"],"9,78":["│"],"11,78":["│"]}
0It is a string divided into three lines.
- The first line is a serialized JSON string representing the coordinates and characters of the current environment's intersection points (there may be multiple characters, hence it is a list).
- The second line is also a serialized JSON string representing all character information in the current environment (there may be multiple characters at each coordinate point, hence it is also a list), with the characters at the front of the array being at the topmost layer, descending accordingly.
- The third line is a numeric string, either 0 or 1, indicating whether to use normal mode or super mode (super mode offers more intersection possibilities but requires a specific font).
- output data
{"10,75":"┿","10,78":"┿"}A serialized JSON string representing the intersection characters that need to be filled for certain specific coordinates.
Example of calling this library in a Vim script:
vimio/autoload/vimio/utils.vim:
let s:vimio_cached_lib_path = ''
function! vimio#utils#get_vimio_libs_path() abort
if empty(s:vimio_cached_lib_path)
let plugin_root = vimio#utils#get_plugin_root()
if has('win32') || has('win64')
let s:vimio_cached_lib_path = plugin_root . '/libs/libvimio.dll'
elseif has('mac')
let s:vimio_cached_lib_path = plugin_root . '/libs/libvimio.dylib'
else
let s:vimio_cached_lib_path = plugin_root . '/libs/libvimio.so'
endif
endif
return s:vimio_cached_lib_path
endfunction
vimio/autoload/vimio/scene.vim:
function! vimio#scene#get_cross_chars_native(cross_point, all_chars) abort
let cross_json = json_encode(a:cross_point)
let all_json = json_encode(a:all_chars)
let mode = (g:vimio_vimiomono_super_slash_mode.index ==# 0)? '0' : '1'
let input = cross_json . "\n" . all_json . "\n" . mode
let result_json = libcall(vimio#utils#get_vimio_libs_path(), 'vimio_get_cross_chars', input)
return json_decode(result_json)
endfunction
function! vimio#scene#get_cross_chars(cross_point, all_chars) abort
let result = vimio#scene#get_cross_chars_native(a:cross_point, a:all_chars)
for [key, center_char] in items(result)
if has_key(g:vimio_config_draw_cross_styles[g:vimio_state_cross_style_index], center_char)
let result[key] = g:vimio_config_draw_cross_styles[g:vimio_state_cross_style_index][center_char]
endif
endfor
return result
endfunction
After compiling the dll, please do not use the cp command in the cygwin environment to copy it to the target path, as this may cause confusion in the dll file permissions and make it impossible to execute.
This project uses the following open-source libraries:
-
uthash
Copyright © Troy D. Hanson
Licensed under the BSD Revised License -
cJSON
Copyright © Dave Gamble and contributors
Licensed under the MIT License