Permalink
Browse files

Output edit info option

  • Loading branch information...
agibsonsw committed Oct 26, 2012
1 parent 13a1fb4 commit fd37eb1a0cce81086b7b11d5fcb9e8a0a126deb3
Showing with 25 additions and 1 deletion.
  1. +25 −1 AndyEdits.py
View
@@ -1,5 +1,6 @@
import sublime, sublime_plugin
from os import path
+import datetime
PACKAGE_SETTINGS = "AndyEdits.sublime-settings"
if sublime.platform() == "linux":
@@ -23,6 +24,7 @@
ICONCURRENT = sublime.load_settings(PACKAGE_SETTINGS).get("icon_current", "comment")
# affects the colour of the gutter icon for the current edit-region
+OUTPUT_EDITS = sublime.load_settings(PACKAGE_SETTINGS).get("output_edits", False)
JUSTDELETED = {}
# Uses view.id() as key and a single boolean True/False value.
# (Prevents a deleted region from being immediately re-created.)
@@ -359,4 +361,26 @@ def on_selection_modified(self, view):
def on_close(self, view):
vid = view.id()
if CaptureEditing.edit_info.has_key(vid):
- del CaptureEditing.edit_info[vid]
+ del CaptureEditing.edit_info[vid]
+
+ def on_post_save(self, view):
+ vid = view.id()
+ re_activate = isView(vid)
+ if not OUTPUT_EDITS: return
+ _ = adjustEdits(view)
+ saved_edits = view.get_regions("edited_rgns")
+ if not saved_edits: return
+ newview = sublime.active_window().new_file()
+ edit = newview.begin_edit()
+ newview.insert(edit, 0, view.file_name() + "\n")
+ newview.insert(edit, newview.size(),
+ datetime.datetime.now().strftime("%c") + '\n')
+
+ for i, r in enumerate(sorted(saved_edits)):
+ editline, _ = view.rowcol(r.begin())
+ newview.insert(edit, newview.size(), "\n-----\nLine: " + \
+ str(editline) + '\n')
+ newview.insert(edit, newview.size(), view.substr(r))
+ newview.end_edit(edit)
+ if re_activate:
+ sublime.active_window().focus_view(view)

0 comments on commit fd37eb1

Please sign in to comment.