From c4a6ccf481d2664ce75ca9dbc820d5011aa07618 Mon Sep 17 00:00:00 2001 From: JuanZoran <1430359574@qq.com> Date: Sat, 21 Jan 2023 21:35:10 +0800 Subject: [PATCH] fix: fix window width and height and fix auto_play --- lua/Trans/content.lua | 2 +- lua/Trans/init.lua | 4 ++-- lua/Trans/view/hover.lua | 7 ++++--- tts/say.js | 4 +--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lua/Trans/content.lua b/lua/Trans/content.lua index f76ce9c..1f37151 100644 --- a/lua/Trans/content.lua +++ b/lua/Trans/content.lua @@ -102,7 +102,7 @@ local content = { load = function() assert(size > 1, 'no item need be loaded') local space = math.floor((self.window.width - width) / (size - 1)) - assert(space > 0, 'try to expand window width') + assert(space > 0, vim.inspect(items)) local interval = (' '):rep(space) local line = '' diff --git a/lua/Trans/init.lua b/lua/Trans/init.lua index e62de37..b1ff8dc 100644 --- a/lua/Trans/init.lua +++ b/lua/Trans/init.lua @@ -7,8 +7,8 @@ M.conf = { v = 'hover', }, hover = { - width = 36, - height = 26, + width = 37, + height = 27, border = 'rounded', title = { { '', 'TransTitleRound' }, diff --git a/lua/Trans/view/hover.lua b/lua/Trans/view/hover.lua index 68f5e48..253ff7c 100644 --- a/lua/Trans/view/hover.lua +++ b/lua/Trans/view/hover.lua @@ -270,9 +270,6 @@ return function(word) -- 目前只处理了本地数据库的查询 m_result = require('Trans.query.offline')(word) local hover = conf.hover - if hover.auto_play then - action.play() - end local opt = { relative = 'cursor', @@ -289,6 +286,10 @@ return function(word) m_content = m_window.contents[1] if m_result then + if hover.auto_play then + action.play() + end + for _, field in ipairs(conf.order) do process[field]() end diff --git a/tts/say.js b/tts/say.js index 34fc28d..1d4298b 100644 --- a/tts/say.js +++ b/tts/say.js @@ -1,6 +1,4 @@ const say = require('say') -word = process.argv - // console.log(word) -say.speak(word.slice(2)) +say.speak(process.argv.slice(2))