forked from dail8859/LuaScript
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopen_source.lua
More file actions
Latest commit
48 lines (38 loc) · 1.06 KB
/
Copy pathopen_source.lua
File metadata and controls
48 lines (38 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
-- open corresponding header (.h, .hpp) or source (.c, .cpp) file
-- скрипт для Notepad++, открывает соотвтествующий файл заголовка или исх. кода по названию
localfunctionget_index(tbl, val)
fori, vinipairs(tbl) do
ifv==valthen
returni
end
end
end
localfunctionsplit_ext(file_path)
returnstring.match(file_path, "^(.+)(%..+)$")
end
localfunctionfile_exist(file_path)
localf=io.open(file_path, "r")
iff~=nilthen
io.close(f)
returntrue
else
returnfalse
end
end
-- ======================================================
localKNOWN_EXTENSIONS= {'.h', '.hpp', '.cpp', '.c'}
npp.AddShortcut("Open Source", "", function()
localfile_name, file_ext=split_ext(npp:GetFullCurrentPath())
ifget_index(KNOWN_EXTENSIONS, file_ext) then
fori, extinipairs(KNOWN_EXTENSIONS) do
ifext~=file_extthen
localtmp_path=file_name..ext
-- print(tmp_path)
iffile_exist(tmp_path) then
npp:DoOpen(tmp_path)
break
end
end
end
end
end)