OSDN Git Service

Add SortAscending, SortDescending and ExecFilterCommand to editor addin.sct
[winmerge-jp/winmerge-jp.git] / Plugins / dlls / editor addin.sct
1 <scriptlet>
2
3 <implements type="Automation" id="dispatcher">
4         <property name="PluginEvent">
5                   <get/>
6         </property>
7         <property name="PluginDescription">
8                   <get/>
9         </property>
10         <method name="MakeUpper"/>
11         <method name="MakeLower"/>
12         <method name="SortAscending"/>
13         <method name="SortDescending"/>
14         <method name="ExecFilterCommand"/>
15 </implements>
16
17 <script language="VBS">
18 Option Explicit
19
20 Function get_PluginEvent()
21          get_PluginEvent = "EDITOR_SCRIPT"
22 End Function
23
24 Function get_PluginDescription()
25          get_PluginDescription = "Basic text functions for the context menu"
26 End Function
27
28
29 ' transformation functions
30 Function MakeUpper(Text)
31         MakeUpper = UCase(Text)
32 End Function
33
34 Function MakeLower(Text)
35         MakeLower = LCase(Text)
36 End Function
37
38 Function ExecFilterCommand(Text)
39         Dim cmd
40         cmd = InputBox("\8c»\8dÝ\82Ì\91I\91ð\94Í\88Í\82Ì\95\8e\9a\97ñ\82ð\83t\83B\83\8b\83^\83R\83}\83\93\83h\82Å\8f\88\97\9d\82µ\82½\8c\8b\89Ê\82Å\92u\8a·\82µ\82Ü\82·\81B\83R\83}\83\93\83h\82ð\93ü\97Í\82µ\82Ä\82­\82¾\82³\82¢\81B")
41         If cmd = "" Then
42                 Err.Raise 30001, "\83L\83\83\83\93\83Z\83\8b\82³\82ê\82Ü\82µ\82½"
43                 Exit Function
44         End If
45
46         On Error Resume Next
47
48         Dim wsh
49         Dim path
50         Set wsh = CreateObject("WScript.Shell")
51         path = wsh.ExpandEnvironmentStrings("%TEMP%\_winmerge_addin_temp_.txt")
52
53         Dim fso
54         Dim ts
55         Set fso = CreateObject("Scripting.FileSystemObject")
56         Set ts = fso.CreateTextFile(path)
57         If ts Is Nothing Then
58                 Exit Function
59         End If
60         ts.Write Text
61         ts.Close
62
63         Dim exe
64         Set exe = wsh.Exec("cmd /c type """ & path & """  | " & cmd & " 2>&1")
65         If exe Is Nothing Then
66                 MsgBox "\83R\83}\83\93\83h " & cmd & " \82Ì\8eÀ\8ds\82É\8e¸\94s\82µ\82Ü\82µ\82½:" & Err.Description 
67                 fso.DeleteFile path
68                 Exit Function
69         End If
70
71         ExecFilterCommand = ""
72         Do Until exe.StdOut.AtEndOfStream
73                 ExecFilterCommand = ExecFilterCommand & exe.StdOut.ReadLine & vbCrLf
74         Loop
75
76         fso.DeleteFile path
77
78 End Function
79
80
81 </script>
82
83 <script language="JScript">
84
85 function SortAscending(Text) {
86         return Text.split("\n").sort().join("\n");
87 }
88
89 function SortDescending(Text) {
90         var lines = Text.split("\n");
91         lines.sort(function(a, b) { return a < b ? 1 : -1; });
92         return lines.join("\n");
93 }
94
95 </script>
96
97 </scriptlet>