Пример #1
0
	def run(self, window, args):
		if(len(window.views()) == 0 and sublime.getClipboard() != ''):
			window.newFile()
			view = window.activeView()
			view.insert(view.size(), sublime.getClipboard())
		else:
			window.runCommand('paste')


# view.set_scratch(True)
    def run(self, view, args):

        clipboard = sublime.getClipboard()

        sel = view.sel()
        initial_selection = [s for s in sel]
        sel.clear()

        adjusted_selection = []
        accumulated_shift = 0

        for s in initial_selection:
            s = self.adjustPosition(s, accumulated_shift)
            adjusted_selection.append(s)
            sel.add(s)
            view.runCommand("expandSelectionTo line")
            accumulated_shift += sel[0].end() - sel[0].begin()
            view.runCommand("copy")
            begin = sel[0].begin()
            end = sel[0].end()
            view.runCommand("toggleComment")
            accumulated_shift += sel[0].end() - end
            self.gotoPosition(sel, begin)
            view.runCommand("paste")
            sel.clear()

        [sel.add(s) for s in adjusted_selection]

        sublime.setClipboard(clipboard)
 def choices(self):
   # tuples of integers with kill-ring entries. 
   # Used by the yank choice command
   choiceArr = []
   for i in range(1,len(self.killRing)):
     choiceArr.append( (i,self.killRing[i]) )
   choiceArr.append( ("clipboard", "Windows Clipboard: " + sublime.getClipboard()))
   return choiceArr
Пример #4
0
 def run(self, edit, **args):
   global killRing
   
   if len(args) == 0:
     # no arguments means the command 
     # is being called directly
     valueToYank = sublime.getClipboard()
   elif args[0] == "clipboard":
     # the user has chosen to yank windows clipboard.
     valueToYank = sublime.getClipboard()
   else:
     # an argument means it's been called from 
     # the EmacsYankChoiceCommand
     idx = int(args[0])
     valueToYank = killRing.get(idx)
   
   for s in self.view.sel():
     self.view.erase(s)
     self.view.insert(s.begin(), valueToYank)
           
   # once we've yanked, we definitely don't want to
   # reuse the old kill buffer
   killRing.LastKillPosition = -1
    def run(self, view, args):
        clipboard = sublime.getClipboard()
        sel = view.sel()
        initial_selection = [s for s in sel]
        sel.clear()

        adjusted_selection = []
        accumulated_selection_size = 0

        for s in initial_selection:
            s = self.adjustPosition(s, accumulated_selection_size)
            adjusted_selection.append(s)
            sel.add(s)
            view.runCommand("expandSelectionTo line")
            accumulated_selection_size += self.selectionSize(sel[0])
            view.runCommand("copy")
            view.runCommand("move characters 1")
            view.runCommand("paste")
            sel.clear()

        [sel.add(s) for s in adjusted_selection]

        sublime.setClipboard(clipboard)
	def run(self, view, args):
		clip = sublime.getClipboard().split(u"\n")
		for region in view.sel():
			view.replace(region, clip.pop(0))
	def isEnabled(self, view, args):
		return sublime.getClipboard() != ""