Total Commander Forum Index Total Commander
Форум поддержки пользователей Total Commander
Сайты: Все о Total Commander | Totalcmd.net | Ghisler.com | RU.TCKB
 
 RulesRules   SearchSearch   FAQFAQ   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Single Post  Topic: Script plugin-maker 0.5.1 
Author Message
Lev



PostPosted: Thu Jul 07, 2005 19:34    Post subject: Script plugin-maker 0.5.1 Reply with quote

Решил поделиться своими наработочками для Script plugin-maker 0.5.1 (к сожалению, плагин давно не обновлялся), может кто, в свою очередь, поделится своими.
Code:
'wlx_vbscript.vb
'simple plugin on VBScript

font_name="Fixedsys"
font_size=12
view_end = "false"
view_wrap = "true"
view_scroll = "both"
view_backgroundcolor = "white"
view_textcolor = "black"

result_text   = ""

Dim fso, ts, s
Set fso = CreateObject("Scripting.FileSystemObject")
sExt = lcase(fso.GetExtensionName(file_name))

Select Case sExt

case "bar"
'view_textcolor = "green"
readfile
process "button\d", vbCRLF+"$&" 'ставим перенос строки
process "\b(cmd|path|menu|iconic|param)\d", "   $&" 'добавляем отступ в 3 пробела

case "eps", "ai", "ps", "prn"
Set f = fso.GetFile(file_name)
if f.size>1000000 then
Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(file_name, ForReading)
s = ts.read(1000)
ts.Close
else
readfile
s=result_text
end if
'dim re
Set re = New RegExp
re.Global = True
re.IgnoreCase = True
re.MultiLine = True

sp = "\s+" 'at least one any space symbol
num = "(-?\d+\.?\d*)" 'any number like -3.51 or 4
spnum = sp + num
re.Pattern = "(%%BoundingBox:|%%PageBoundingBox:|%ADO_ImageableArea:|%%HiResBoundingBox:)" + spnum + spnum + spnum + spnum
if re.Test(s) then
Set tt = re.Execute(s)
re.Pattern = "-?\d+\.?\d*"
Set bb = re.Execute(tt(0))
sx= Round((bb(2)-bb(0))*0.352778)'25.4/72
sy= Round((bb(3)-bb(1))*0.352778)'25.4/72

'result_text= sx & " mm x " & sy& " mm"
result_text= sx & " x " & sy& " mm"
End if
'end case "eps", "ai", "ps", "prn"
Case Else
'result_text = sExt + " file type"
End Select

Sub readfile()
Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(file_name, ForReading)
s = ts.ReadAll
AddLine s
ts.Close
End Sub

Sub process (a,b)' замена в тексте a на b
Dim re
Set re = New RegExp
re.Global = True
re.IgnoreCase = True
re.MultiLine = False

re.Pattern = a
result_text = re.Replace(result_text,b)
End Sub

Здесь написан вьюер для "bar" файлов коммандера (для упражнения) и для "eps", "ai", "ps", "prn" файлов - пытается выдрать и показать размер файла, если файл содержит превью, то такие (binary) файлы VBScript не обрабатывает и у меня они показываются с помощью Imagine
View user's profile Send private message


Powered by phpBB © 2001, 2005 phpBB Group