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

Python sublime.set_clipboard函数代码示例

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

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



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

示例1: create_gist

def create_gist(description, public):
    data = json.dumps({ 'description': description, 'public': public, 'files': { _fileName: {'content': _selectedText} }})
    result = api_request(url, data)
    sublime.set_clipboard(result['html_url'])
    if settings.get("open_in_browser"):
        webbrowser.open(result['html_url'])
    sublime.status_message("Gist: " + result['html_url'])
开发者ID:yarmand,项目名称:my_sublime_text_2,代码行数:7,代码来源:gist.py


示例2: set_register

def set_register(view, register, forward):
    delta = 1
    if not forward:
        delta = -1

    text = []
    regions = []
    for s in view.sel():
        if s.empty():
            s = sublime.Region(s.a, s.a + delta)
        text.append(view.substr(s))
        regions.append(s)

    text = '\n'.join(text)

    use_sys_clipboard = view.settings().get('vintage_use_clipboard', False) == True

    if (use_sys_clipboard and register == '"') or (register in ('*', '+')):
        sublime.set_clipboard(text)
        # If the system's clipboard is used, Vim always propagates the data to
        # the unnamed register too.
        register = '"'

    if register == '%':
        pass
    else:
        reg = register.lower()
        append = (reg != register)

        if append and reg in g_registers:
            g_registers[reg] += text
        else:
            g_registers[reg] = text
开发者ID:twolfson,项目名称:sublime-files,代码行数:33,代码来源:vintage.py


示例3: on_done

 def on_done(self, idx):
     if idx == -1:
         return
     gist = self.gists[idx]
     filename = list(gist["files"].keys())[0]
     filedata = gist["files"][filename]
     content = self.gistapi.get(filedata["raw_url"])
     if self.open_in_editor:
         new_view = self.view.window().new_file()
         if expat:  # not present in Linux
             # set syntax file
             if not self.syntax_file_map:
                 self.syntax_file_map = self._generate_syntax_file_map()
             try:
                 extension = os.path.splitext(filename)[1][1:].lower()
                 syntax_file = self.syntax_file_map[extension]
                 new_view.set_syntax_file(syntax_file)
             except KeyError:
                 logger.warn("no mapping for '%s'" % extension)
                 pass
         # insert the gist
         new_view.run_command("insert_text", {'text': content})
         new_view.set_name(filename)
         new_view.settings().set('gist', gist)
     elif self.copy_gist_id:
         sublime.set_clipboard(gist["html_url"])
     else:
         sublime.set_clipboard(content)
         sublime.status_message(self.MSG_SUCCESS % filename)
开发者ID:Mikerobenics,项目名称:sublime-github,代码行数:29,代码来源:sublime_github.py


示例4: run

	def run(self, edit):
		selectedRegions = self.view.sel()
		regionsToDelete = map(lambda r: self.view.full_line(r), selectedRegions)
		copyStr = ''.join(map(lambda r: self.view.substr(r), regionsToDelete))
		for region in regionsToDelete:
			self.view.erase(edit, region)
		sublime.set_clipboard(copyStr)
开发者ID:AlecBoutin,项目名称:sublime-line-cut,代码行数:7,代码来源:LineCut.py


示例5: choose

	def choose(self, flag):
		if flag != -1:
			if flag == len(self.item) - 1:
				self.word = self.word.replace('_','-')
				open_tab('http://www.php.net/manual/%(lang)s/function.%(function)s.php' % {'lang':'zh', 'function': self.word})
			else:
				sublime.set_clipboard(self.item[flag])
开发者ID:freemantau,项目名称:SublimePHPNinJaManual,代码行数:7,代码来源:PhpNinJaManual.py


示例6: show_list

	def show_list(self):
		self.awaits_files=[]
		self.missing=[]
		for rf in self.root_files:
			files=[]
			if rf.isnumeric():
				files=self.searchFileForAwaits(rf)
				self.awaits_files+=(files)
				for f in files:
					if f not in self.input_files:
						self.missing.append("Page {pagefile}: {awaitname}.tex".format(awaitname=f, pagefile=rf))
			

		self.unimplemented=list(set(self.input_files)-set(self.awaits_files))
		# self.missing=list(set(self.awaits_files)-set(self.input_files))

		if (self.mode=="unimplemented"):
			diff=list(set(self.unimplemented))
			self.quicklist=self.unimplemented
			self.window.show_quick_panel(sorted(set(diff)), self.setChosenToClipboard)
		elif self.mode=="all":
			diff=list(set(self.unimplemented))
			awaits_code=""
			for i in sorted(set(diff)):
				awaits_code+="\\awaits{"+i+"}\n"
			sublime.set_clipboard(awaits_code)
		elif self.mode=="missing":
			self.quicklist=self.missing
			self.window.show_quick_panel(sorted(set(self.missing)), self.setChosenToClipboard)
		else:
			return
开发者ID:Strauman,项目名称:latex_tools_custom,代码行数:31,代码来源:unimplemented.py


示例7: run

    def run(self, view, paste_name=None):
        if paste_name is None:
            paste_name = self.view.file_name()
        if paste_name is not None:
            paste_name = os.path.basename(paste_name)   # Extract base name
        else:
            paste_name = "Untitled"

        text = ""
        for region in self.view.sel():

            syntax = SYNTAXES.get(self.view.settings().get('syntax').split('/')[-1], 'text')
            if text:
                text = text + '\n' + self.view.substr(region).encode('utf8')
            else:
                text = self.view.substr(region).encode('utf8')

        if not text:
            sublime.status_message('Error sending to %s: Nothing selected' % FRIENDPASTE_URL)
        else:
            self._data = json.dumps({
                'title': paste_name,
                'snippet': text,
                'language': syntax
            })

            paste = self.send_paste()

            sublime.set_clipboard(paste['url'])
            sublime.status_message('PasteBin URL copied to clipboard: ' + paste['url'])
开发者ID:martinsam,项目名称:sublime-friendpaste,代码行数:30,代码来源:pastetofriendpaste.py


示例8: run

    def run(self, edit):

        syntax_current_file = self.view.settings().get("syntax")
        sublime.set_clipboard(syntax_current_file)

        msg = "Syntax copied to the clipboard"
        sublime.status_message(msg)
开发者ID:mattst,项目名称:sublime-single-trailing-new-line,代码行数:7,代码来源:SingleTrailingNewLine.py


示例9: convert

  def convert(self, text, edit):
      if (";" in text):
        sublime.set_clipboard(self.process())
        self.view.run_command('paste_and_indent')

      else:
        self.view.run_command('paste')
开发者ID:lnikell,项目名称:css-converter,代码行数:7,代码来源:css_to_sass.py


示例10: open_url

    def open_url(self, url):
        if self.copy_url_on_open:
            sublime.set_clipboard(url)
            sublime.status_message('URL Copied: `%s`' % url)

        if url[0:3] == 'www': url = 'http://' + url
        webbrowser.open_new_tab(url)
开发者ID:miusuncle,项目名称:HiveOpener,代码行数:7,代码来源:opener.py


示例11: run

  def run( self, view ):
    try:
      s = re.findall(r'\bphp|html|css|xml|haml|python|js|java|css|c\+\+|cs|c\b', self.view.scope_name(0))[0]
      if s == 'js':
        s = 'javascript'
      if s == 'cs':
        s = 'csharp'
      if s == 'c++':
        s = 'cpp'
    except:
      s = 'other'

    c, v, i = self.view.substr(sublime.Region(0, self.view.size())), self.view.sel()[0], 0
    if v.begin() != v.end():
      for x in self.view.lines(v):
        b = x.begin()+i
        c = c[:b] + '@@' + c[b:]
        i = i + 2
       
    r, p = httplib.HTTPConnection('www.pastebin.com'), urllib.urlencode({'paste_private': 1, 'paste_code': c, 'paste_format': s})
    h = {"Content-type": "application/x-www-form-urlencoded",
               "Accept": "text/plain"}
    r.request("POST", "/api_public.php", p, h)
    g = r.getresponse()
    if g.status == 200:
      l = g.read()
      if l[0:5] == 'ERROR':
        sublime.status_message('Something went wrong:\n' + l)
      else:
        sublime.set_clipboard(l)
        sublime.status_message('Link has been copied to your clipboard')
    else:
      sublime.status_message('Something went wrong: ' + g.status, g.reason)
    r.close()
开发者ID:dwoodard,项目名称:sublimentz,代码行数:34,代码来源:uploadToPastebin.py


示例12: run

    def run(self, edit):
        t = time.strftime('%Y-%m-%d',time.localtime(time.time()));
        sublime.status_message(t)                                       # 将时间显示在状态栏,显示一段时间后自动消失
        sublime.set_clipboard(t)                                        # 将当前时间放入剪贴板,可用于粘贴(ctrl+v)
        date_str = "yyyy-mm-dd"
        # 第一种方法
        # reg = sublime.Region(0, self.view.size())                       # 获取当前文件全部区域
        # text = self.view.substr(reg)                                    # 获取指定区域的文本
        # text = text.replace(date_str,t)                                 # 把text中yyyy-mm-dd替换为当前时间t
        # self.view.erase(edit,reg)                                       # 清除指定区域的文本
        # self.view.insert(edit,0,text)                                   # 将text插入本文档

        # 另一种方法,更简便
        reg = self.view.find(date_str,0,sublime.IGNORECASE)
        if reg != None:                                                 # 不加这个条件也不会出错,最好加上
            self.view.replace(edit,reg,t)

        # 以下为将“module 模块名.v”替换为“module 模块名”,如果存在;用于配合verilog的module snippet
        file_full_name = self.view.file_name()                          # 这个文件名包括路径
        last_index = file_full_name.rfind('\\')                         # 得到最后一个\的位置
        file_name = file_full_name[last_index+1:]                       # 取得最后的文件名,不包括路径
        module_str = 'module '+ file_name
        reg = self.view.find(module_str,0,sublime.IGNORECASE)
        if reg != None:                                                 # 如果存在这个字符串
            self.view.replace(edit,reg,module_str[:-2])                 # 去掉后缀.v并插入
开发者ID:hsp86,项目名称:sublime_text3_configure,代码行数:25,代码来源:getdate.py


示例13: run

	def run(self):
		self.view = self.window.active_view()

		tmp_gist = tempfile.TemporaryFile()
		tmp_gist.write(self.view.substr(sublime.Region(0, self.view.size())))
		tmp_gist.seek(0)

		self.showMsg("Creating gist...")

		p = subprocess.Popen([ "gist", "--no-open" ],
							bufsize = 4096,
							stdin = tmp_gist,
							stdout = subprocess.PIPE,
							stderr = subprocess.PIPE)
		stdout, stderr = p.communicate()

		output = stdout
		if stderr != "":
			output = stderr

		output = output.splitlines()

		sublime.set_clipboard(output[0])

		print "URL", output[0]

		tmp_gist.close()

		self.clearTemporaryMsg()
		self.window.show_input_panel("Gist:", output[0], None, None, None)
开发者ID:dresende,项目名称:st2,代码行数:30,代码来源:gist.py


示例14: run

 def run(self):
   """
   This command copies the current scope to the clipboard
   """
   current_scope = self.window.active_view().get_status(status_key)
   if type(current_scope) is str:
     sublime.set_clipboard(current_scope.rstrip())
开发者ID:yaworsw,项目名称:Sublime-ScopeAlways,代码行数:7,代码来源:ScopeAlways.py


示例15: setUp

 def setUp(self):
     sublime.set_clipboard('')
     registers._REGISTER_DATA = {}
     TestsState.view.settings().erase('vintage')
     TestsState.view.settings().erase('vintageous_use_sys_clipboard')
     self.regs = VintageState(TestsState.view).registers
     self.regs.view = mock.Mock()
开发者ID:KevinSjoberg,项目名称:Vintageous,代码行数:7,代码来源:test_registers.py


示例16: run

 def run(self, edit):
     self.deactivate_mark()
     self.view.run_command(
         "run_macro_file",
         {"file": "Packages/Default/Delete to Hard EOL.sublime-macro"}
     )
     set_clipboard(kill_ring.kill_ring.top())
开发者ID:dreid,项目名称:E-Max,代码行数:7,代码来源:emax_commands.py


示例17: status

 def status(self):
     copy = self.current()
     copy = copy.replace("\t", "\\t")
     copy = copy.replace("\n", "\\n")
     copy = copy.replace("\r", "\\r")
     sublime.status_message(u'Set Clipboard to "{copy}"'.format(copy=copy))
     sublime.set_clipboard(self.current())
开发者ID:progus-florian,项目名称:SublimeClipboardManager,代码行数:7,代码来源:clipboard_manager.py


示例18: on_idle

 def on_idle(self, view):
     string = ""
     for region in view.sel():
         if not region.empty():
             string += view.substr(region)
     if string != "":
         sublime.set_clipboard(string)
开发者ID:chrifpa,项目名称:CopyOnSelect,代码行数:7,代码来源:copy-on-select.py


示例19: setUp

 def setUp(self):
     sublime.set_clipboard('')
     registers._REGISTER_DATA = {}
     TestsState.view.settings().erase('vintage')
     TestsState.view.settings().erase('vintageous_use_sys_clipboard')
     self.regs = Registers(view=TestsState.view,
                           settings=SettingsManager(view=TestsState.view))
开发者ID:Web5design,项目名称:Vintageous,代码行数:7,代码来源:test_registers.py


示例20: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python sublime.set_timeout函数代码示例发布时间:2022-05-27
下一篇:
Python sublime.save_settings函数代码示例发布时间: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