Server IP : 180.180.241.3 / Your IP : 216.73.216.252 Web Server : Microsoft-IIS/7.5 System : Windows NT NETWORK-NHRC 6.1 build 7601 (Windows Server 2008 R2 Standard Edition Service Pack 1) i586 User : IUSR ( 0) PHP Version : 5.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Program Files (x86)/Sublime Text 2/Pristine Packages/ |
Upload File : |
PK i>gI^ ^ Context.sublime-menu[ { "caption": "-" }, { "caption": "Show Unsaved Changes…", "command": "diff_changes" } ] PK ^?} diff.pyimport sublime, sublime_plugin import difflib import time import os.path import codecs class DiffFilesCommand(sublime_plugin.WindowCommand): def run(self, files): if len(files) != 2: return try: a = codecs.open(files[1], "r", "utf-8").readlines() b = codecs.open(files[0], "r", "utf-8").readlines() except UnicodeDecodeError: sublime.status_message("Diff only works with UTF-8 files") return adate = time.ctime(os.stat(files[1]).st_mtime) bdate = time.ctime(os.stat(files[0]).st_mtime) diff = difflib.unified_diff(a, b, files[1], files[0], adate, bdate) difftxt = u"".join(line for line in diff) if difftxt == "": sublime.status_message("Files are identical") else: v = self.window.new_file() v.set_name(os.path.basename(files[1]) + " -> " + os.path.basename(files[0])) v.set_scratch(True) v.set_syntax_file('Packages/Diff/Diff.tmLanguage') edit = v.begin_edit() v.insert(edit, 0, difftxt) v.end_edit(edit) def is_visible(self, files): return len(files) == 2 class DiffChangesCommand(sublime_plugin.TextCommand): def run(self, edit): fname = self.view.file_name(); try: a = codecs.open(fname, "r", "utf-8").read().splitlines() b = self.view.substr(sublime.Region(0, self.view.size())).splitlines() except UnicodeDecodeError: sublime.status_message("Diff only works with UTF-8 files") return adate = time.ctime(os.stat(fname).st_mtime) bdate = time.ctime() diff = difflib.unified_diff(a, b, fname, fname, adate, bdate,lineterm='') difftxt = u"\n".join(line for line in diff) if difftxt == "": sublime.status_message("No changes") return use_buffer = self.view.settings().get('diff_changes_to_buffer') if use_buffer: v = self.view.window().new_file() v.set_name("Unsaved Changes: " + os.path.basename(self.view.file_name())) v.set_scratch(True) v.set_syntax_file('Packages/Diff/Diff.tmLanguage') else: win = self.view.window() v = win.get_output_panel('unsaved_changes') v.set_syntax_file('Packages/Diff/Diff.tmLanguage') v.settings().set('word_wrap', self.view.settings().get('word_wrap')) edit = v.begin_edit() v.insert(edit, 0, difftxt) v.end_edit(edit) if not use_buffer: win.run_command("show_panel", {"panel": "output.unsaved_changes"}) def is_enabled(self): return self.view.is_dirty() and self.view.file_name() PK ݦ;@( Diff.tmLanguage<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>fileTypes</key> <array> <string>diff</string> <string>patch</string> </array> <key>firstLineMatch</key> <string>(?x)^ (===\ modified\ file |==== \s* // .+ \s - \s .+ \s+ ==== |Index:[ ] |---\ [^%] |\*\*\*.*\d{4}\s*$ |\d+(,\d+)* (a|d|c) \d+(,\d+)* $ |diff\ --git[ ] ) </string> <key>foldingStartMarker</key> <string>^\+\+\+</string> <key>foldingStopMarker</key> <string>^---|^$</string> <key>keyEquivalent</key> <string>^~D</string> <key>name</key> <string>Diff</string> <key>patterns</key> <array> <dict> <key>captures</key> <dict> <key>1</key> <dict> <key>name</key> <string>punctuation.definition.separator.diff</string> </dict> </dict> <key>match</key> <string>^((\*{15})|(={67})|(-{3}))$\n?</string> <key>name</key> <string>meta.separator.diff</string> </dict> <dict> <key>match</key> <string>^\d+(,\d+)*(a|d|c)\d+(,\d+)*$\n?</string> <key>name</key> <string>meta.diff.range.normal</string> </dict> <dict> <key>captures</key> <dict> <key>1</key> <dict> <key>name</key> <string>punctuation.definition.range.diff</string> </dict> <key>2</key> <dict> <key>name</key> <string>meta.toc-list.line-number.diff</string> </dict> <key>3</key> <dict> <key>name</key> <string>punctuation.definition.range.diff</string> </dict> </dict> <key>match</key> <string>^(@@)\s*(.+?)\s*(@@)($\n?)?</string> <key>name</key> <string>meta.diff.range.unified</string> </dict> <dict> <key>captures</key> <dict> <key>3</key> <dict> <key>name</key> <string>punctuation.definition.range.diff</string> </dict> <key>4</key> <dict> <key>name</key> <string>punctuation.definition.range.diff</string> </dict> <key>6</key> <dict> <key>name</key> <string>punctuation.definition.range.diff</string> </dict> <key>7</key> <dict> <key>name</key> <string>punctuation.definition.range.diff</string> </dict> </dict> <key>match</key> <string>^(((\-{3}) .+ (\-{4}))|((\*{3}) .+ (\*{4})))$\n?</string> <key>name</key> <string>meta.diff.range.context</string> </dict> <dict> <key>captures</key> <dict> <key>4</key> <dict> <key>name</key> <string>punctuation.definition.from-file.diff</string> </dict> <key>6</key> <dict> <key>name</key> <string>punctuation.definition.from-file.diff</string> </dict> <key>7</key> <dict> <key>name</key> <string>punctuation.definition.from-file.diff</string> </dict> </dict> <key>match</key> <string>(^(((-{3}) .+)|((\*{3}) .+))$\n?|^(={4}) .+(?= - ))</string> <key>name</key> <string>meta.diff.header.from-file</string> </dict> <dict> <key>captures</key> <dict> <key>2</key> <dict> <key>name</key> <string>punctuation.definition.to-file.diff</string> </dict> <key>3</key> <dict> <key>name</key> <string>punctuation.definition.to-file.diff</string> </dict> <key>4</key> <dict> <key>name</key> <string>punctuation.definition.to-file.diff</string> </dict> </dict> <key>match</key> <string>(^(\+{3}) .+$\n?| (-) .* (={4})$\n?)</string> <key>name</key> <string>meta.diff.header.to-file</string> </dict> <dict> <key>captures</key> <dict> <key>3</key> <dict> <key>name</key> <string>punctuation.definition.inserted.diff</string> </dict> <key>6</key> <dict> <key>name</key> <string>punctuation.definition.inserted.diff</string> </dict> </dict> <key>match</key> <string>^(((>)( .*)?)|((\+).*))$\n?</string> <key>name</key> <string>markup.inserted.diff</string> </dict> <dict> <key>captures</key> <dict> <key>1</key> <dict> <key>name</key> <string>punctuation.definition.inserted.diff</string> </dict> </dict> <key>match</key> <string>^(!).*$\n?</string> <key>name</key> <string>markup.changed.diff</string> </dict> <dict> <key>captures</key> <dict> <key>3</key> <dict> <key>name</key> <string>punctuation.definition.inserted.diff</string> </dict> <key>6</key> <dict> <key>name</key> <string>punctuation.definition.inserted.diff</string> </dict> </dict> <key>match</key> <string>^(((<)( .*)?)|((-).*))$\n?</string> <key>name</key> <string>markup.deleted.diff</string> </dict> <dict> <key>captures</key> <dict> <key>1</key> <dict> <key>name</key> <string>punctuation.separator.key-value.diff</string> </dict> <key>2</key> <dict> <key>name</key> <string>meta.toc-list.file-name.diff</string> </dict> </dict> <key>match</key> <string>^Index(:) (.+)$\n?</string> <key>name</key> <string>meta.diff.index</string> </dict> </array> <key>scopeName</key> <string>source.diff</string> <key>uuid</key> <string>7E848FF4-708E-11D9-97B4-0011242E4184</string> </dict> </plist> PK jj>̢T T Side Bar.sublime-menu[ { "caption": "Diff Files…", "command": "diff_files", "args": {"files": []} } ] PK i>gI^ ^ Context.sublime-menuPK ^?} diff.pyPK ݦ;@( Diff.tmLanguagePK jj>̢T T ` Side Bar.sublime-menuPK