Skip to content

Commit

Permalink
[Fixed] DavidGerva#1
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristinita authored and Kristinita committed Mar 26, 2017
1 parent 952f7c2 commit 900678f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 34 deletions.
70 changes: 36 additions & 34 deletions SendToSandbox.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,48 @@
import sublime, sublime_plugin
import os
import sublime
import sublime_plugin

# Command "Send To SandBox"
class SendSelection( sublime_plugin.WindowCommand ):

def run(self):
sSettings = sublime.load_settings('SendToSandbox.sublime-settings')

sSel = self.window.active_view().sel()
for region in sSel:
firstLine = self.window.active_view().rowcol(region.a)
lastLine = self.window.active_view().rowcol(region.b)
class SendSelection(sublime_plugin.WindowCommand):

if (lastLine[0] < firstLine[0] ):
firstLine = lastLine
lastLine = self.window.active_view().rowcol(region.a)
def run(self):
sSettings = sublime.load_settings('SendToSandbox.sublime-settings')

sSel = self.window.active_view().sel()
for region in sSel:
firstLine = self.window.active_view().rowcol(region.a)
lastLine = self.window.active_view().rowcol(region.b)

szText = self.window.active_view().substr(region)

fSandBox = sSettings.get("file")
if (lastLine[0] < firstLine[0]):
firstLine = lastLine
lastLine = self.window.active_view().rowcol(region.a)

if not fSandBox:
return False
szText = self.window.active_view().substr(region)

filePath = self.window.active_view().file_name();
fSandBox = sSettings.get("file")

with open(fSandBox, "a") as myfile:
myfile.write("\n")
filePath = ("## %s - [%i-%i]\n" % (filePath, firstLine[0]+1, lastLine[0]+1) )
myfile.write( filePath)
myfile.write( szText )
myfile.write("\n")

def is_enabled(self):
# Mostro solo se la selezione non è vuota
sSel = self.window.active_view().sel()
for region in sSel:
szText = self.window.active_view().substr(region)
szText = szText.strip()
if szText:
return True
if not fSandBox:
return False

return False
filePath = self.window.active_view().file_name()

with open(fSandBox, "a", encoding='utf-8') as myfile:
myfile.write("\n")
filePath = (
"## %s - [%i-%i]\n" %
(filePath, firstLine[0] + 1, lastLine[0] + 1))
myfile.write(filePath)
myfile.write(szText)
myfile.write("\n")

def is_enabled(self):
# Mostro solo se la selezione non è vuota
sSel = self.window.active_view().sel()
for region in sSel:
szText = self.window.active_view().substr(region)
szText = szText.strip()
if szText:
return True

return False
5 changes: 5 additions & 0 deletions SendToSandbox.sublime-settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
// File, that you want use as sandbox, example for Windows:
// "file": "D:\\Kristinita\\Happiness.md"
"file": ""
}

0 comments on commit 900678f

Please sign in to comment.