diff --git a/denops/traqvim/main.ts b/denops/traqvim/main.ts index 1997cb8..73a3100 100644 --- a/denops/traqvim/main.ts +++ b/denops/traqvim/main.ts @@ -45,11 +45,26 @@ export async function main(denops: Denops) { // oauthの仮オブジェクト let oauth: OAuth; denops.dispatcher = { - async getFile(fileId: unknown): Promise { + async getFile( + fileId: unknown, + opts?: unknown, + ): Promise { assert(fileId, is.String); + assert( + opts, + is.OptionalOf(is.ObjectOf({ + maxWidth: is.Number, + maxHeight: is.Number, + })), + ); const file: Uint8Array = await downloadFile(fileId); // denops-sixel-view.vimのsixel_viewがUint8Arrayを受け取れる必要がある - const sixel = await denops.dispatch("sixel_view", "img2sixel", file); + const sixel = await denops.dispatch( + "sixel_view", + "img2sixel", + file, + opts, + ); assert( sixel, is.ObjectOf({ diff --git a/doc/traqvim.jax b/doc/traqvim.jax index 73bb4b1..ce3a13e 100644 --- a/doc/traqvim.jax +++ b/doc/traqvim.jax @@ -280,8 +280,18 @@ https://github.com/gw31415/denops-sixel-view.vim endfunction function s:preview_img(fileId) abort + let font_height = 12 + let font_width = font_height / 2 + let retina_scale = 2 " download the file and convert it to sixel data - let sixel = denops#request("traqvim", "getFile", [a:fileId]) + let sixel = denops#request("traqvim", "getFile", + \[ + \ a:fileId, + \ #{ + \ maxWidth: winwidth('.') * font_width / 2 * retina_scale, + \ maxHeight: winheight('.') * font_height / 2 * retina_scale, + \ } + \]) call sixel_view#view_sixel(sixel['data'], 0, 0) endfunction