forked from SublimeText/WinMerge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WinMerge.py
31 lines (25 loc) · 931 Bytes
/
WinMerge.py
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
import sublime, sublime_plugin
import os
from subprocess import Popen
import _winreg
WINMERGE = _winreg.QueryValue(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinMergeU.exe')
if not WINMERGE:
if os.path.exists("%s\WinMerge\WinMergeU.exe" % os.environ['ProgramFiles(x86)']):
WINMERGE = '"%s\WinMerge\WinMergeU.exe"' % os.environ['ProgramFiles(x86)']
else:
WINMERGE = '"%s\WinMerge\WinMergeU.exe"' % os.environ['ProgramFiles']
fileA = fileB = None
def recordActiveFile(f):
global fileA
global fileB
fileB = fileA
fileA = f
class WinMergeCommand(sublime_plugin.ApplicationCommand):
def run(self):
cmd_line = '%s /e /ul /ur "%s" "%s"' % (WINMERGE, fileA, fileB)
print "WinMerge command: " + cmd_line
Popen(cmd_line)
class WinMergeFileListener(sublime_plugin.EventListener):
def on_activated(self, view):
if view.file_name() != fileA:
recordActiveFile(view.file_name())