在編寫程式碼時,你會經常需要轉換十進制和十六進制,SciteConvertDecHex 會將選取的文字轉換為十進制或十六進制。你不再需要使用外部的程式計算器應用程式,以及進行複製和貼上的動作。
scite_Command {
'Convert Dec/Hex|ConvertDecHex|Alt+Shift+C',
}
function IsHexString (s)
local header = string.sub(s, 1, 2)
if "0x" == header or "0X" == header then
return true
else
return false
end
end
function ConvertDecHex ()
local current_selected_text, current_selected_length = editor:GetSelText()
local converted_number = tonumber(current_selected_text)
if not (converted_number == nil) then
local converted_text = nil
if IsHexString(current_selected_text) then
converted_text = tostring(converted_number)
else
converted_text = string.format("0x%X", converted_number)
end
editor:ReplaceSel(converted_text)
end
end
RecentChanges · 偏好設定
編輯 · 歷史
上次編輯於 2013 年 4 月 6 日星期六 上午 10:27 GMT (diff)