OSDN Git Service

editor addin.sct: ExecFilterCommand: Specify the previously entered command as the...
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Wed, 5 May 2021 14:24:16 +0000 (23:24 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Wed, 5 May 2021 14:24:16 +0000 (23:24 +0900)
Plugins/dlls/editor addin.sct

index 252577b..c014d2b 100644 (file)
 <script language="VBS">
 Option Explicit
 
+Const WinMergeRegKeyPath = "HKCU\Software\Thingamahoochie\WinMerge\"
+Const PluginRegKeyPath = "HKCU\Software\Thingamahoochie\WinMerge\Plugins\editor addin.sct\"
+
+Dim wsh: Set wsh = CreateObject("WScript.Shell")
+
 Function get_PluginEvent()
          get_PluginEvent = "EDITOR_SCRIPT"
 End Function
@@ -25,12 +30,17 @@ Function get_PluginDescription()
          get_PluginDescription = "Basic text functions for the context menu"
 End Function
 
+Function regRead(Key, DefaultValue)
+       regRead = DefaultValue
+       On Error Resume Next
+       regRead = wsh.RegRead(Key)
+End Function
+
 Function IsLangJapanese()
-    Dim languageId
-    languageId = 1033
-    On Error Resume Next
-    languageId = CLng(wsh.RegRead(REGKEY_PATH & "\Locale\LanguageId"))
-    IsLangJapanese = (languageId = 1041)
+       Dim languageId
+       On Error Resume Next
+       languageId = CLng(regRead(WinMergeRegKeyPath & "Locale\LanguageId", 1033))
+       IsLangJapanese = (languageId = 1041)
 End Function
 
 ' transformation functions
@@ -44,10 +54,11 @@ End Function
 
 Function ExecFilterCommand(Text)
        Dim cmd
+       cmd = regRead(PluginRegKeyPath & "ExecFilterCommand", "")
        If IsLangJapanese() Then
-               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")
+               cmd = InputBox("\83t\83B\83\8b\83^\83R\83}\83\93\83h\82ð\93ü\97Í\82µ\82Ä\82­\82¾\82³\82¢", "ExecFilterCommand", cmd)
        Else
-               cmd = InputBox("Enter filter command to replace the selection.")
+               cmd = InputBox("Enter filter command", "ExecFilterCommand", cmd)
        End If
        If cmd = "" Then
                If IsLangJapanese() Then
@@ -60,9 +71,7 @@ Function ExecFilterCommand(Text)
 
        On Error Resume Next
 
-       Dim wsh
        Dim path
-       Set wsh = CreateObject("WScript.Shell")
        path = wsh.ExpandEnvironmentStrings("%TEMP%\_winmerge_addin_temp_.txt")
 
        Dim fso
@@ -94,6 +103,8 @@ Function ExecFilterCommand(Text)
 
        fso.DeleteFile path
 
+       wsh.RegWrite PluginRegKeyPath & "ExecFilterCommand", cmd
+
 End Function