Skip to content

Commit b835f0e

Browse files
committed
revise
1 parent 7c05c8a commit b835f0e

File tree

4 files changed

+37
-37
lines changed

4 files changed

+37
-37
lines changed

allfiles/lua/f_components/f_get_os_name.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
local function get_os_name()
44

55
local raw_os_name = ''
6-
if package.config:sub(1,1) == '\\' then
6+
if string.sub(package.config, 1,1) == '\\' then
77
-- Windows
88
local env_OS = os.getenv('OS')
99
if env_OS then
@@ -14,7 +14,7 @@ local function get_os_name()
1414
raw_os_name = io.popen('uname -s','r'):read('*l')
1515
end
1616

17-
local raw_os_name = (raw_os_name):lower()
17+
local raw_os_name = string.lower(raw_os_name)
1818

1919
local os_patterns = {
2020
['windows'] = 'Windows',
@@ -30,7 +30,7 @@ local function get_os_name()
3030

3131
local os_name = 'unknown'
3232
for pattern, name in pairs(os_patterns) do
33-
if raw_os_name:match(pattern) then
33+
if string.match(raw_os_name, pattern) then
3434
os_name = name
3535
break
3636
end

allfiles/lua/f_components/f_get_os_name_simple.lua

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ local function get_os_name_simple()
1818
-- raw_os_name = io.popen('uname -s','r'):read('*l') or ""
1919
-- end
2020

21-
-- local raw_os_name = (raw_os_name):lower()
21+
-- local raw_os_name = string.lower(raw_os_name)
2222

2323
--------------------------------------------------------
2424

@@ -36,7 +36,7 @@ local function get_os_name_simple()
3636

3737
-- local os_name = "unknown"
3838
-- for pattern, name in pairs(os_patterns) do
39-
-- if raw_os_name:match(pattern) then
39+
-- if string.match(raw_os_name, pattern) then
4040
-- os_name = name
4141
-- break
4242
-- end
@@ -46,23 +46,23 @@ local function get_os_name_simple()
4646
-- 用當前用戶的家目錄路徑判斷 os 系統名稱
4747
--------------------------------------------------------
4848
local os_name = os.getenv("USERPROFILE") and "Windows" or
49-
os.getenv("HOME") and os.getenv("HOME"):sub(1,7) == "/Users/" and "Mac" or
50-
os.getenv("HOME") and os.getenv("HOME"):sub(1,6) == "/home/" and "Linux" or
49+
os.getenv("HOME") and string.sub(os.getenv("HOME"), 1,7) == "/Users/" and "Mac" or
50+
os.getenv("HOME") and string.sub(os.getenv("HOME"), 1,6) == "/home/" and "Linux" or
5151
--------------------------------------------------------
52-
-- raw_os_name:match("windows$") and "Windows" or
53-
-- raw_os_name:match("linux$") and "Linux" or
54-
-- raw_os_name:match("osx$") and "Mac" or
55-
-- raw_os_name:match("mac") and "Mac" or
56-
-- raw_os_name:match("darwin") and "Mac" or
57-
-- raw_os_name:match("^mingw$") and "Windows" or
58-
-- raw_os_name:match("^cygwin$") and "Windows" or
59-
-- raw_os_name:match("bsd$") and "BSD" or
60-
-- raw_os_name:match("sunos") and "Solaris" or
52+
-- string.match(raw_os_name, "windows$") and "Windows" or
53+
-- string.match(raw_os_name, "linux$") and "Linux" or
54+
-- string.match(raw_os_name, "osx$") and "Mac" or
55+
-- string.match(raw_os_name, "mac") and "Mac" or
56+
-- string.match(raw_os_name, "darwin") and "Mac" or
57+
-- string.match(raw_os_name, "^mingw$") and "Windows" or
58+
-- string.match(raw_os_name, "^cygwin$") and "Windows" or
59+
-- string.match(raw_os_name, "bsd$") and "BSD" or
60+
-- string.match(raw_os_name, "sunos") and "Solaris" or
6161
--------------------------------------------------------
6262
"unknown"
6363
-- 測試 Windows 之 os.getenv("HOME") 為 nil,但網路資訊說明某些 Win 版本不為 nil?
6464
-- os.getenv("USERPROFILE")只在 Win 不為 nil。
65-
-- os.getenv()可能為 nil,不可直接「:sub()」或「lower()」,會報錯!
65+
-- os.getenv()可能為 nil,不可直接「sub()」或「lower()」,會報錯!
6666
--------------------------------------------------------
6767
--------------------------------------------------------
6868

allfiles/lua/p_components/p_generic_open.lua

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
-- ---- 新的寫法(「三種 os 跑法」全跑一遍)
6060
-- local function generic_open(dest)
6161
-- -- 以下處理「-removeopen 」,為特此標示去移除開頭之「open和start等」,有些指令不能有開頭command!
62-
-- if dest:match("^-removeopen ") then
63-
-- local dest = dest:gsub("^-removeopen ", "")
62+
-- if string.match(dest, "^-removeopen ") then
63+
-- local dest = string.gsub(dest, "^-removeopen ", "")
6464
-- -- local f = io.popen(dest)
6565
-- -- f = nil
6666
-- return io.popen(dest) and true or false
@@ -125,38 +125,38 @@ local oscmd = cmd_table[os_name]
125125
---------------------------------------------------------------
126126
-- --- 用 Rime 名稱判斷 os(會有不知名 Rime 輸入法軟體無法辨識的問題)
127127
-- local d_c_name = rime_api.get_distribution_code_name() or "none"
128-
-- local oscmd = d_c_name:find("Weasel") and 'start "" ' or -- weasel
129-
-- d_c_name:find("windows") and 'start "" ' or -- fcitx5-windows
130-
-- d_c_name:find("Squirrel") and 'open ' or -- squirrel
131-
-- d_c_name:find("macos") and 'open ' or -- fcitx5-macos
132-
-- d_c_name:find("ibus") and 'xdg-open ' or -- ibus-rime
128+
-- local oscmd = string.find(d_c_name, "Weasel") and 'start "" ' or -- weasel
129+
-- string.find(d_c_name, "windows") and 'start "" ' or -- fcitx5-windows
130+
-- string.find(d_c_name, "Squirrel") and 'open ' or -- squirrel
131+
-- string.find(d_c_name, "macos") and 'open ' or -- fcitx5-macos
132+
-- string.find(d_c_name, "ibus") and 'xdg-open ' or -- ibus-rime
133133
-- -- -- 以下防名稱有疏漏,且避免小狼毫問題當機!於此判定是否為 windows!
134-
-- -- -- os.getenv()可能為 nil,不可直接lower「:lower()」,會報錯!
135-
-- os.getenv('OS') and os.getenv('OS'):lower():match("windows") and 'start "" ' or
136-
-- os.getenv('OS') and os.getenv('OS'):lower():match("^mingw") and 'start "" ' or
137-
-- os.getenv('OS') and os.getenv('OS'):lower():match("^cygwin") and 'start "" ' or
138-
-- -- package.config:sub(1,1) == '\\' and 'start "" ' or -- 該條目會拖慢呼叫速度!!!
134+
-- -- -- os.getenv()可能為 nil,不可直接「sub()」或「lower()」,會報錯!
135+
-- os.getenv('OS') and string.match(string.lower(os.getenv('OS')), "windows") and 'start "" ' or
136+
-- os.getenv('OS') and string.match(string.lower(os.getenv('OS')), "^mingw") and 'start "" ' or
137+
-- os.getenv('OS') and string.match(string.lower(os.getenv('OS')), "^cygwin") and 'start "" ' or
138+
-- -- string.sub(package.config, 1,1) == '\\' and 'start "" ' or -- 該條目會拖慢呼叫速度!!!
139139
-- 'xdg-open '
140140
---------------------------------------------------------------
141141
-- --- 用 os.getenv 參數判斷 os
142142
-- local oscmd = os.getenv("USERPROFILE") and 'start "" ' or -- Windows
143-
-- os.getenv("HOME") and os.getenv("HOME"):sub(1,7) == '/Users/' and 'open ' or -- Mac
144-
-- os.getenv("HOME") and os.getenv("HOME"):sub(1,6) == '/home/' and 'xdg-open ' or -- Linux
143+
-- os.getenv("HOME") and string.sub(os.getenv("HOME"), 1,7) == '/Users/' and 'open ' or -- Mac
144+
-- os.getenv("HOME") and string.sub(os.getenv("HOME"), 1,6) == '/home/' and 'xdg-open ' or -- Linux
145145
-- 'xdg-open '
146146
-- -- nil -- 設 nil 可使無法判斷之 os 不亂跑無效執行!
147147
-- -- 測試 Windows 之 os.getenv("HOME") 為 nil,但網路資訊說明某些 Win 版本不為 nil?
148148
-- -- os.getenv("USERPROFILE")只在 Win 不為 nil。
149-
-- -- os.getenv()可能為 nil,不可直接「:sub()」或「lower()」,會報錯!
149+
-- -- os.getenv()可能為 nil,不可直接「sub()」或「lower()」,會報錯!
150150
---------------------------------------------------------------
151151
local function generic_open(dest)
152-
if oscmd ~= nil and not dest:match("^-removeopen ") then
153-
-- local f = io.popen( oscmd .. dest)
152+
if oscmd ~= nil and not string.match(dest, "^-removeopen ") then
153+
-- local f = io.popen( oscmd .. dest )
154154
-- f:close() -- 不能使用,於 0.17.0 以上之小狼毫會當機崩潰
155155
-- f = nil
156-
return io.popen( oscmd .. dest) and true or false
156+
return io.popen( oscmd .. dest ) and true or false
157157
-- 以下處理「-removeopen 」,為特此標示去移除開頭之「open和start等」,有些指令不能有開頭command!
158158
elseif oscmd ~= nil then
159-
local dest = dest:gsub("^-removeopen ", "")
159+
local dest = string.gsub(dest, "^-removeopen ", "")
160160
-- local f = io.popen(dest)
161161
-- f:close() -- 不能使用,於 0.17.0 以上之小狼毫會當機崩潰
162162
-- f = nil

allfiles/lua/translator_multifunction_translator.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3260,7 +3260,7 @@ local function translate(input, seg, env)
32603260
local s_output = simple_calculator(input_exp)[3]
32613261

32623262
local preedittext = env.prefix .. " " .. c_preedit .. "\t 【計算機】"
3263-
if (c_output:sub(1,1)=="E" or c_output:sub(1,1)=="W") then
3263+
if (string.sub(c_output, 1,1)=="E" or string.sub(c_output, 1,1)=="W") then
32643264
yield_c( "", c_output.."〔結果〕", preedittext) -- yield(cc_out_error)
32653265
yield_c( s_output, "〔 Waring 結果〕", preedittext) -- yield(cc_out_shadow)
32663266
yield_c( output_exp .. "=" .. s_output, "〔 Waring 規格化算式〕", preedittext) -- yield(cc_exp_error)

0 commit comments

Comments
 (0)