플러그인 나는 다른 사용하여 세 개의 클래스로 현재 파일에서 모든 텍스트를 복사 지금까지 약간의 스크립트가 있습니다3 내가 숭고한 텍스트 3 플러그인 작업입니다
import sublime, sublime_plugin
# string and new file created
s = 0
newFile = 0
class CreateNewWindowCommand(sublime_plugin.WindowCommand):
def run(self):
global s, newFile
s = self.window.active_view().substr(sublime.Region(0, self.window.active_view().size()))
newFile = self.window.new_file()
class CopyTextCommand(sublime_plugin.TextCommand):
def printAChar(self,char,edit):
self.view.insert(edit, 0, char)
def run(self, edit):
global s
st = list(s)
for i in st[::-1]:
self.printAChar(i, edit)
class PrintCodeCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.run_command("create_new_window")
newFile.run_command("copy_text")
을 스크립트는 먼저 PrintCodeCommand를 통해 실행됩니다.
나는이 코드에 대한 여러 질문이 있습니다
- 이 할 수있는 '권리'방법을? 전역 변수를 전달하는 것은 약간 더러운 것처럼 보입니다.
- WindowCommand와 TextCommand를 동시에 사용할 수있는 클래스를 만드는 방법이 있습니까?
- 삽입 명령 (CopyTextCommand에서) 삽입, 처음에는 파일 끝에 추가 할 수있는 방법이 있습니까?
또 하나 : 어떻게 sublime.set_timeout()을 사용할 수 있습니까? 이 때문에 같은 :
# ...
class CopyTextCommand(sublime_plugin.TextCommand):
def printAChar(self,char,edit):
sublime.set_timeout(self.view.insert(edit, 0, char) , 1000)
# I want to print a char one per second
또는 time.sleep()를 사용하여 명령하지만이 작동하지 않는 것 ... 미리
감사합니다!
질문 당 여러 질문을하지 마십시오. – MattDMo