Material Theme/schemes/Material Theme Palenight.tmTheme
And all i need is the file name.
Iv'e got two kinds of lua scripts i am testing with.
One i found in the Rainmeter documentation, and i cannot remember where i got the other one from.
From Rainmeter documentation:
Code: Select all
function ParseFilePath(s)
assert(type(s) == 'string', 'ParseFilePath: string expected, got ' .. type(s) .. '.')
local t = {}
for Piece in s:gmatch('[^\\]+') do
table.insert(t, Piece)
end
-- VOLUME
if #t > 0 then
local UNCprefix = s:match('^(\\\\)') or ''
t.Vol = UNCprefix .. t[1] .. '\\'
end
-- NAME
if #t > 1 then
-- DETECT FOLDER OR SEPARATE EXTENSION
if s:match('\\$') then
t.Name = t[#t] .. '\\'
elseif t[#t]:match('.+%..+') then
t.Name, t.Ext = t[#t]:match('(.-)%.([^%.]-)$')
else
t.Name = t[#t]
end
end
-- FOLDER
if #t > 2 then
t.Dir = table.concat(t, '\\', 2, #t-1) .. '\\'
end
return t
end
Code: Select all
PROPERTIES = {
Input = '0';
InputVariable = '0';
InputMeasure = '0';
Output = '';
VariablePrefix = '';
}
function Initialize()
sInput = PROPERTIES.Input
sInputVariable = PROPERTIES.InputVariable
sInputMeasure = PROPERTIES.InputMeasure
sOutput = PROPERTIES.Output
sVariablePrefix = PROPERTIES.VariablePrefix
end
function Update()
if sInput ~= '0' then
sPath = sInput
elseif sInputVariable ~= '0' then
sPath = SKIN:GetVariable(sInputVariable)
elseif sInputMeasure ~= '0' then
msInput = SKIN:GetMeasure(sInputMeasure)
sPath = msInput:GetStringValue()
else
return 'Invalid input type.'
end
sDrive, sDir, sName, sExt = string.match(sPath, "(.):\\(.-)([^\\]-)%.([^%.]+)$")
sNameExt = sName..'.'..sExt
SKIN:Bang('!SetVariable "'..sVariablePrefix..'Drive" "'..sDrive..'"')
SKIN:Bang('!SetVariable "'..sVariablePrefix..'Dir" "'..sDir..'"')
SKIN:Bang('!SetVariable "'..sVariablePrefix..'Name" "'..sName..'"')
if sOutput == 'Drive' then
return sDrive
elseif sOutput == 'Dir' then
return sDir
elseif sOutput == 'Name' then
return sName
elseif sOutput == 'NameExt' then
return sNameExt
elseif sOutput == 'Ext' then
return sExt
else
return 'Invalid output type.'
end
end
But does not seem to work with the .tmTheme file extention.
Code: Select all
[MeasureScript]
Measure=Script
ScriptFile=#@#lua\PathParser.lua
DynamicVariables=1
Input=C:\Program Files\Sublime Text 3\sublime_text.exe
Output=Name
Code: Select all
[MeasureScript1]
Measure=Script
ScriptFile=#@#Lua\FilePathParser.lua
ParseFilePath=C:\Program Files\Sublime Text 3\sublime_text.exe]
But all i got is the path you see in the top of this post.
Maybe RegExpSubstitute is the answer in stead of lua?