forked from DavidGerva/SendToSandbox-SublimePlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kristinita
authored and
Kristinita
committed
Mar 26, 2017
1 parent
952f7c2
commit 900678f
Showing
2 changed files
with
41 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": "" | ||
} |