• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sublime.get_clipboard函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sublime.get_clipboard函数的典型用法代码示例。如果您正苦于以下问题:Python get_clipboard函数的具体用法?Python get_clipboard怎么用?Python get_clipboard使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_clipboard函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: run

  def run(self, edit, **args):
    global killRing

    if len(args) == 0:
      # no arguments means the command
      # is being called directly
      valueToYank = sublime.get_clipboard()
    elif args[0] == "clipboard":
      # the user has chosen to yank windows clipboard.
      valueToYank = sublime.get_clipboard()
    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(edit, s)
      self.view.insert(edit, s.begin(), valueToYank)

    # once we've yanked, we definitely don't want to
    # reuse the old kill buffer
    killRing.LastKillPosition = -1

    # Clear mark
    marks.clearMark(self.view)
开发者ID:alvinlai,项目名称:EmacsKillRing,代码行数:26,代码来源:EmacsKillRing.py


示例2: run

 def run(self):
     # init
     self.update_latest(sublime.get_clipboard())
     # check is_enabled in loop so we can deactivate it at any time
     while self.is_valid():
         # load inverval setting here, so we can mess with the settings while it's running
         interval = ClipboardTracker.interval()
         # let's assign since this method can be time consuming
         data = sublime.get_clipboard()
         if self.has_changed(data):
             self.trigger_event("change", data)
         if ClipboardTracker.is_log_enabled():
             ClipboardTracker.log(self)
         # sleep
         time.sleep(interval)
     if self.stop:
         print(self.id, 'Stop set, ClipboardTracker stopped')
     elif len(self.get_listeners()) == 0:
         print(self.id, 'No listeners left, ClipboardTracker stopped')
     elif not self.id in ClipboardTracker.valid_id_list:
         print(self.id, 'Clipboardtracker not in valid ID list, stopped')
     else:
         print(self.id, 'ClipboardTracker stopped')
     if self.id in ClipboardTracker.valid_id_list:
         ClipboardTracker.valid_id_list.remove(self.id)
开发者ID:duydao,项目名称:Text-Pastry,代码行数:25,代码来源:text_pastry_clipboard.py


示例3: run

    def run(self):
        path = sublime.get_clipboard().strip()
        parentDirsMatch = re.search("(\\.\\.[/\\\\])*(.*)", path)
        if (parentDirsMatch):
            path = parentDirsMatch.groups()[1]
        gitPathPrefixMatch = re.search("^[ab][/\\\\](.*)", path)
        if (gitPathPrefixMatch):
            path = gitPathPrefixMatch.groups()[0]

        line = None
        colonLineMatch = re.search(r'(.*?):(\d+).*', path)
        parenthesesLineMatch = re.search(r'(.*?)\((\d+)\).*', path)
        junkMatch = re.search(r'(.*?[^\w]+.*?)[:,].*', path)

        if (colonLineMatch):
            path = colonLineMatch.groups()[0]
            line = colonLineMatch.groups()[1]
        elif (parenthesesLineMatch):
            path = parenthesesLineMatch.groups()[0]
            line = parenthesesLineMatch.groups()[1]
        elif (junkMatch):
            path = junkMatch.groups()[0]

        resolvedPath = self.resolvePath(path)
        if not resolvedPath:
            sublime.status_message("Couldn't find a file matching [%s]" % sublime.get_clipboard().strip())
            return

        if line:
            self.window.open_file(resolvedPath + ':' + line, sublime.ENCODED_POSITION)
        else:
            self.window.open_file(resolvedPath)
开发者ID:jturcotte,项目名称:SublimeClipboardPath,代码行数:32,代码来源:clipboard_path.py


示例4: get

    def get(self, name=REG_UNNAMED):
        # We accept integers or strings a register names.
        name = str(name)
        assert len(str(name)) == 1, "Register names must be 1 char long."

        # Did we request a special register?
        if name == REG_BLACK_HOLE:
            return
        elif name == REG_FILE_NAME:
            try:
                return os.path.basename(self.view.file_name())
            except AttributeError:
                return ''
        elif name in REG_SYS_CLIPBOARD_ALL:
            return [sublime.get_clipboard()]
        elif name != REG_UNNAMED and name in REG_ALL:
            return
        # Special case lumped among these --user always wants the sys
        # clipboard.
        elif name == REG_UNNAMED and self.settings.view['vintageous_use_sys_clipboard'] == True:
            return sublime.get_clipboard()

        # We requested an [a-z0-9"] register.
        try:
            # In Vim, "A and "a seem to be synonyms, so accept either.
            return _REGISTER_DATA[name.lower()]
        except KeyError:
            # sublime.status_message("Vintage.Next: E353 Nothing in register %s", name)
            pass
开发者ID:corelon,项目名称:Vintageous,代码行数:29,代码来源:registers.py


示例5: run

 def run(self, edit):
     the_sels = self.view.sel()
     for a_sel in the_sels:
         he_text = self.view.substr(a_sel)
         copylen = len(sublime.get_clipboard())
         self.view.insert(edit, a_sel.begin(), sublime.get_clipboard())
         self.view.replace(edit,a_sel,"")
         eraseRegion = sublime.Region(a_sel.end() + copylen, a_sel.end() + copylen*2)
         self.view.erase(edit, eraseRegion)
开发者ID:franksmule,项目名称:Sublime-PasteOverwrite,代码行数:9,代码来源:PasteOverwrite.py


示例6: parse

 def parse(self, text):
     result = None
     if not text: return None
     if text:
         m1 = re.compile('(-?\d+) (-?\d+) (\d+)$').match(text)
         m2 = re.compile('\\\\i(\d+)(,(-?\d+))?').match(text)
         m3 = re.compile('\\\\i\((\d+)(,(-?\d+))?').match(text)
         m4 = re.compile('\\\\p\((.*?)\)?').match(text)
         m5 = re.compile('^(\$\d+\s?)+$').match(text)
         if m1:
             (current, step, padding) = map(str, text.split(" "))
             History.save_history("insert_nums", text, label=text)
             sublime.status_message("Inserting Nums: " + text)
             result = dict(Command="insert_nums", args={"current" : current, "step" : step, "padding" : padding})
         elif text == "\i":
             History.save_history("insert_nums", "1 1 1", label="\i")
             sublime.status_message("Inserting #: " + text)
             result = dict(Command="insert_nums", args={"current" : "1", "step" : "1", "padding" : "1"})
         elif m2 or m3:
             m = None
             if m2: m = m2
             else: m = m3
             current = m.group(1)
             step = m.group(3)
             if not current: current = "1"
             if not step: step = "1"
             History.save_history("insert_nums", text=current + " " + step + " 1", label=text)
             sublime.status_message("Inserting #" + text)
             result = dict(Command="insert_nums", args={"current" : current, "step" : step, "padding" : "1"})
         elif text == "\\p":
             History.save_history("text_pastry_insert_text", text=sublime.get_clipboard(), label=text)
             sublime.status_message("Inserting from clipboard")
             result = dict(Command="text_pastry_insert_text", args={"text": sublime.get_clipboard(), "clipboard": True})
         elif m4:
             separator = m4.group(1)
             if not separator: separator = None
             History.save_history("text_pastry_insert_text", text=sublime.get_clipboard(), label=text, separator=separator)
             sublime.status_message("Inserting from clipboard with separator: " + str(separator))
             result = dict(Command="text_pastry_insert_text", args={"text": sublime.get_clipboard(), "separator": separator, "clipboard": True})
         elif text == "\\UUID":
             sublime.status_message("Inserting UUID")
             History.save_history("text_pastry_insert", text=text, label="Generate UUID")
             result = dict(Command="text_pastry_insert", args={"command": "uuid", "options": {"uppercase": True} })
         elif text == "\\uuid":
             sublime.status_message("Inserting UUID")
             History.save_history("text_pastry_insert", text=text, label="Generate uuid")
             result = dict(Command="text_pastry_insert", args={"command": "uuid"})
         elif m5:
             items = ','.join(filter(None, map(lambda x: x.strip(), text.split("$"))))
             result = dict(Command="text_pastry_insert", args={"command": "backreference", "text": items, "separator": ","})
         else:
             sublime.status_message("Inserting " + text)
             result = dict(Command="text_pastry_insert_text", args={"text": text})
     else:
         pass
     return result
开发者ID:adzenith,项目名称:Text-Pastry,代码行数:56,代码来源:text_pastry.py


示例7: run

	def run(self, edit):
		view = self.view
		for thisregion in view.sel():
			thisregionfullline = view.full_line(thisregion)
			thisregionfulllineBeginning = thisregionfullline.begin()
			sublimeclipboard = sublime.get_clipboard()
			if(sublimeclipboard[-1:] != chr(10)):
				sublime.status_message("PasteIntoLines: There is not newlines ending content in clipboard, adding newline after")
				view.insert(edit, thisregionfulllineBeginning, sublime.get_clipboard() + chr(10))
				view.show(thisregion.a + len(sublimeclipboard) + 1)
			else:
				view.insert(edit, thisregionfulllineBeginning, sublime.get_clipboard())
				view.show(thisregion.a + len(sublimeclipboard) + 1)
开发者ID:robertcollier4,项目名称:KeyboardSelectionSublime,代码行数:13,代码来源:KeyboardNavigation.py


示例8: run

	def run(self, edit):
		
		# Copy to Clipboard and Convert Entity => Variable |OR| Variable => Entity
		#
		# @param {Regionset} self
		# @param {Edit} edit

		# Save previous clipboard value / reset clipboard
		original_clipboard = sublime.get_clipboard()
		sublime.set_clipboard('')

		selections = self.view.sel()

		for selection in selections:
			
			# Get the selection's value and length
			string_value = self.view.substr(selection)

			v2e_output = variable_to_entity(string_value, self.view)
			e2v_output = entity_to_variable(string_value)

			if (v2e_output is False) and (e2v_output is False):

				# Revert clipboard to value captured before command run
				sublime.set_clipboard(original_clipboard)
				
				# Output error message
				self.view.set_status(mvt_error_status_key, 'No valid variable or entity available for conversion')
				threading.Timer(3, self.view.erase_status, args=[mvt_error_status_key]).start()

				return False

			else:

				if v2e_output is not False:
					output = v2e_output
				elif e2v_output is not False:
					output = e2v_output

				# Copy output to clipboard
				previous_clipboard = sublime.get_clipboard()
				if previous_clipboard is '':
					sublime.set_clipboard(output)

				else:
					sublime.set_clipboard(previous_clipboard + '\n' + output)

		# Status message display
		self.view.set_status(mvt_copy_status_key, 'Converted and copied ' + str(len(sublime.get_clipboard())) + ' characters')
		threading.Timer(3, self.view.erase_status, args=[mvt_copy_status_key]).start()
开发者ID:mghweb,项目名称:Miva-Template-Language,代码行数:50,代码来源:mvt-toggle-variable.py


示例9: run

 def run(self, edit, register=None, content=None):
     if register:
         self.view.run_command('copy')
         if content is None:
             content = sublime.get_clipboard()
         HISTORY.register(register, content)
         update_output_panel(self.view.window(), True)
     else:
         self.view.run_command('copy')
         content = sublime.get_clipboard()
         chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
         lines = list(chars)
         def on_done(idx):
             self.view.window().run_command('clipboard_manager_copy_to_register', {'register': lines[idx], 'content': content})
         sublime.active_window().show_quick_panel(lines, on_done)
开发者ID:progus-florian,项目名称:SublimeClipboardManager,代码行数:15,代码来源:clipboard_manager.py


示例10: run

	def run(self, edit):

		# get selectioncontent
		selectionContent = ""
		selections = self.view.sel()
		for sel in selections:
			selectionContent += self.view.substr(sel)
			if not selectionContent.endswith("\n"):
				selectionContent += "\n"

		if(selectionContent != ""):
			viewContent = selectionContent
			# todo: fetch appropriate names
			leftName = "(Selection)"
		else:
			viewContent = self.view.substr(sublime.Region(0,self.view.size()))
			# todo: fetch appropriate names
			leftName = ""
		
		# clipboard
		clipboardContent = sublime.get_clipboard()
		if not clipboardContent.endswith("\n"):
			clipboardContent += "\n"
		rightName = "Clipboard"


		leftResult, rightResult, hunks = doDiff(viewContent, clipboardContent)
		showDiff(leftResult, rightResult, hunks)

		diffSession = DiffSession(leftName, rightName, viewContent, clipboardContent)
		diffSession.diff()
		diffSession.show()
开发者ID:guija,项目名称:sublime_vergleich,代码行数:32,代码来源:sublime_vergleich.py


示例11: set_clipboard

 def set_clipboard(cls, cmd):
     if not cls.thread:
         cls.cb = sublime.get_clipboard()
     else:
         cls.thread.cancel()
         cls.thread = None
     sublime.set_clipboard(cmd)
开发者ID:hafen,项目名称:SendTextPlus,代码行数:7,代码来源:textsender.py


示例12: run

 def run(self, edit):
     clip = sublime.get_clipboard()
     if re.search('\n$', clip):
         n = re.sub('\n$', '', clip)
         self.view.replace(edit, self.view.sel()[0], n)
     else:
         self.view.replace(edit, self.view.sel()[0], clip)
开发者ID:shikajiro,项目名称:GaryutenPaste,代码行数:7,代码来源:GaryutenPaste.py


示例13: run

	def run(self, edit, **kw):
		if not eutils.is_css_view(self.view, True):
			return sublime.error_message('You should run this action on CSS file')

		# build sources list
		sources = [view for view in eutils.all_views() if re.search(r'[\/\\]lspatch-[\w\-]+\.json$', view.file_name() or '')]

		# gather all available items
		display_items = []
		patches = []

		def add_item(patch, name):
			for p in patch:
				display_items.append([p['file'], 'Updated selectors: %s' % ', '.join(p['selectors']), name])
				patches.append(json.dumps(p['data']))

		for view in sources:
			add_item(lsutils.diff.parse_patch(eutils.content(view)), view.file_name())

		# check if buffer contains valid patch
		pb =  sublime.get_clipboard()
		if lsutils.diff.is_valid_patch(pb):
			add_item(lsutils.diff.parse_patch(pb), 'Clipboard')

		def on_done(ix):
			if ix == -1: return
			apply_patch_on_view(self.view, patches[ix])

		if len(display_items) == 1:
			on_done(0)
		elif display_items:
			self.view.window().show_quick_panel(display_items, on_done)
		else:
			sublime.error_message('No patches found. You have to open patch files in Sublime Text or copy patch file contents into clipboard and run this action again.')
开发者ID:archerchiu,项目名称:livestyle-sublime,代码行数:34,代码来源:livestyle.py


示例14: on_modified

 def on_modified(self, view):
     # print(view.command_history(0, False))
     # print(view.command_history(-1, False))
     session = registry.getSessionByView(view)
     if session:
         if (session.state == pi.STATE_CONNECTED) and (session.role == pi.HOST_ROLE):
             command = view.command_history(0, False)
             lastCommand = session.lastViewCommand
             session.lastViewCommand = command
             payload = ''
             # handle history-capturable edit commands on this view
             if command[0] == 'insert':
                 # because of the way the insert commands are captured in the command_history
                 # this seems to be the most sensible way to handle this... grab latest character
                 # inserted and send it... not most efficient but it is a start
                 if command[0] == lastCommand[0]:
                     chars = command[1]['characters']
                     lastChars = lastCommand[1]['characters']
                     if chars.startswith(lastChars):
                         payload = chars.replace(lastChars, '', 1)
                     else:
                         payload = chars
                 else:
                     payload = command[1]['characters']
                 session.sendEdit(pi.EDIT_TYPE_INSERT, payload)
             elif command[0] ==  'insert_snippet':
                 payload = command[1]['contents']
                 session.sendEdit(pi.EDIT_TYPE_INSERT_SNIPPET, payload)
             elif command[0] == 'left_delete':
                 session.sendEdit(pi.EDIT_TYPE_LEFT_DELETE, payload)
             elif command[0] == 'right_delete':
                 session.sendEdit(pi.EDIT_TYPE_RIGHT_DELETE, payload)
             elif command[0] == 'paste':
                 payload = sublime.get_clipboard()
                 session.sendEdit(pi.EDIT_TYPE_PASTE, payload)
开发者ID:hitchh1k3r,项目名称:SubliminalCollaborator,代码行数:35,代码来源:commands.py


示例15: run

 def run(self, edit):
     try:
         text = sublime.get_clipboard()
         if text is not None and len(text) > 0:
             regions = []
             sel = self.view.sel()
             items = text.split("\n")
             if len(items) == 1: items = [text];
             strip = True
             settings = sublime.load_settings("TextPastry.sublime-settings")
             for idx, region in enumerate(sel):
                 if idx < len(items):
                     row = items[idx].strip()
                     if region.empty():
                         sublime.status_message("empty")
                         row = self.view.substr(self.view.line(self.view.line(region).begin()-1)) + "\n"
                         i = 0
                         if len(row.strip()): i = self.view.insert(edit, region.end(), row)
                         regions.append( sublime.Region(region.end() + i, region.end() + i) )
                     else:
                         sublime.status_message("selection")
                         self.view.replace(edit, region, row)
                         i = len(row)
                         regions.append( sublime.Region(region.begin() + i, region.begin() + i) )
             sel.clear()
             for region in regions:
                 sel.add(region)
                 pass
         else:
             sublime.status_message("No text found for Insert Text, canceled")
     except ValueError:
         sublime.status_message("Error while executing Insert Text, canceled")
         pass
开发者ID:adzenith,项目名称:Text-Pastry,代码行数:33,代码来源:text_pastry.py


示例16: process

  def process(self):
    text = sublime.get_clipboard()

    tree = {'children': {}}
    # Remove comments
    text = re.sub("\/\*[\s\S]*?\*\/", "", text)
    results = re.findall("([^{]+)\{([^}]+)\}", text)
    # Process each css block
    for (selector, declaration) in results:
      selectors = []
      path = tree
      selector = selector.strip()
      if re.search(",", selector):
        path = self.addRule(path, selector)
      else:
        selector = re.sub("\s*([>\+~])\s*", r' &\1' , selector)
        selector = re.sub("(\w)([:\.])", r'\1 &\2' , selector)
        selectors = re.split("[\s]+", selector)
        for item in selectors:
          #fix back special chars
          _sel = re.sub("&(.)", r'& \1 ', item)
          _sel = re.sub("& ([:\.]) ", r'&\1', _sel)

          path = self.addRule(path, _sel)
      for (_property, value) in re.findall("([^:;]+):([^;]+)", declaration):
        obj = {
          "property": _property.strip(),
          "value": value.strip()
        }

        path['declarations'].append(obj)
    if len(results) == 0: return self.clean(text)
    return self.generateOutput(tree)
开发者ID:lnikell,项目名称:css-converter,代码行数:33,代码来源:css_to_sass.py


示例17: run

    def run(self, action, title=''):
        self.action = action

        if self.action == 'mediawiker_show_page':
            if mw_get_setting('mediawiker_newtab_ongetpage'):
                self.run_in_new_window = True

            if not title:
                pagename_default = ''
                #use clipboard or selected text for page name
                if bool(mw_get_setting('mediawiker_clipboard_as_defaultpagename')):
                    pagename_default = sublime.get_clipboard().strip()
                if not pagename_default:
                    selection = self.window.active_view().sel()
                    for selreg in selection:
                        pagename_default = self.window.active_view().substr(selreg).strip()
                        break
                self.window.show_input_panel('Wiki page name:', mw_pagename_clear(pagename_default), self.on_done, self.on_change, None)
            else:
                self.on_done(title)
        elif self.action == 'mediawiker_reopen_page':
            #get page name
            if not title:
                title = mw_get_title()
            self.action = 'mediawiker_show_page'
            self.on_done(title)
        elif self.action in ('mediawiker_publish_page', 'mediawiker_add_category', 'mediawiker_category_list', 'mediawiker_search_string_list', 'mediawiker_add_image', 'mediawiker_add_template', 'mediawiker_upload'):
            self.on_done('')
开发者ID:SLboat,项目名称:Mediawiker-SLboat-Mod,代码行数:28,代码来源:mediawiker.py


示例18: OpenFile

        def OpenFile():

            output = []
            filePath = []

            def open(index):
                if index < 0:
                    return
                self.view.window().open_file(filePath[index])

            path = sublime.get_clipboard()
            if not path.strip():
                return

            if os.path.isfile(path):
                filePath.append(path)
                open(0)
            elif os.path.isdir(path):
                listDir = os.listdir(path)
                for f in listDir:
                    if os.path.isfile(path + "/" + f):
                        output.append(f)
                        filePath.append(path + "/" + f)

                self.view.window().show_quick_panel(output, open)
开发者ID:easyz,项目名称:Tools,代码行数:25,代码来源:Refactor.py


示例19: opSetBase

    def opSetBase(self):
        content = sublime.get_clipboard()
        if content is None:
            raise ValueError("failed to get content from clipboard!")

        self.snippetBase = content.rstrip("\n\r")
        sublime.status_message("snippet base is set to: {}".format(self.snippetBase))
开发者ID:iamstorm,项目名称:SublimeStorm-DPalette,代码行数:7,代码来源:cmd_snippet_base.py


示例20: get_right

    def get_right(self):
        """Get right."""

        return {
            "win_id": None, "view_id": None,
            "clip": EasyDiffView("**clipboard**", sublime.get_clipboard(), "UTF-8")
        }
开发者ID:MSublime,项目名称:EasyDiff,代码行数:7,代码来源:easy_diff_basic.py



注:本文中的sublime.get_clipboard函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sublime.installed_packages_path函数代码示例发布时间:2022-05-27
下一篇:
Python sublime.find_resources函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap