def focus_st(): sublime_command = get_sublime_exe() if sublime_command is not None: platform = sublime.platform() # TODO: this does not work on OSX # and I don't know why... if platform == 'osx': return plat_settings = get_setting(platform, {}) wait_time = plat_settings.get('keep_focus_delay', 0.5) def keep_focus(): startupinfo = None shell = False if platform == 'windows': startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW shell = _ST3 subprocess.Popen( sublime_command, startupinfo=startupinfo, shell=shell, env=os.environ ) if hasattr(sublime, 'set_async_timeout'): sublime.set_async_timeout(keep_focus, int(wait_time * 1000)) else: sublime.set_timeout(keep_focus, int(wait_time * 1000))
def _get_synctex_editor(self): st_binary = get_sublime_exe() if st_binary is None: st_binary = get_setting('linux', {}).get('sublime', 'sublime_text') return '--synctex-editor-command={0} %{{input}}:%{{line}}'.format( st_binary)
def _get_synctex_editor(self): st_binary = get_sublime_exe() if st_binary is None: st_binary = get_setting('linux', {}).get('sublime', 'sublime_text') return '--synctex-editor-command={0} %{{input}}:%{{line}}'.format( st_binary )
def _run_zathura(self, pdf_file, **kwargs): st_binary = get_sublime_exe() if st_binary is None: st_binary = get_setting('linux', {}).get('sublime', 'sublime_text') return subprocess.Popen([ 'zathura', '-x', '{0} %{{input}}:%{{line}}'.format(st_binary), pdf_file ]).pid
def _launch_evince(self, pdf_file): ev_path = self._get_evince_folder() py_binary, _ = self._get_settings() st_binary = get_sublime_exe() if st_binary is None: linux_settings = get_setting('linux', {}) st_binary = linux_settings.get('sublime', 'sublime_text') subprocess.Popen([ 'sh', os.path.join(ev_path, 'evince_sync'), py_binary, st_binary, pdf_file ], cwd=ev_path)
def run(self): view = sublime.active_window().active_view() t = SystemCheckThread(sublime_exe=get_sublime_exe(), uses_miktex=using_miktex(), texpath=_get_texpath(view) or os.environ['PATH'], build_env=get_setting('builder_settings', {}).get( sublime.platform(), {}).get('env'), view=view, on_done=self.on_done) t.start() ProgressIndicator(t, 'Checking system...', 'System check complete')
def run(self): view = sublime.active_window().active_view() t = SystemCheckThread( sublime_exe=get_sublime_exe(), uses_miktex=using_miktex(), texpath=_get_texpath(view) or os.environ['PATH'], build_env=get_setting('builder_settings', {}).get( sublime.platform(), {} ).get('env'), view=view, on_done=self.on_done ) t.start() ProgressIndicator(t, 'Checking system...', 'System check complete')
def _launch_evince(self, pdf_file): ev_path = self._get_evince_folder() py_binary, _ = self._get_settings() st_binary = get_sublime_exe() if st_binary is None: linux_settings = get_setting('linux', {}) st_binary = linux_settings.get('sublime', 'sublime_text') external_command( [ 'sh', os.path.join(ev_path, 'evince_sync'), py_binary, st_binary, pdf_file ], cwd=ev_path, use_texpath=False )
def _replace_vars(self, s, pdf_file, tex_file=None, line='', col=''): ''' Function to substitute various values into a user-provided string Returns a tuple consisting of the string with any substitutions made and a boolean indicating if any substitutions were made Provided Values: --------------------|-----------------------------------------------| $pdf_file | full path of PDF file $pdf_file_name | name of the PDF file $pdf_file_ext | extension of the PDF file $pdf_file_base_name | name of the PDF file without the extension $pdf_file_path | full path to directory containing PDF file $sublime_binary | full path to the Sublime binary Forward Sync Only: --------------------|-----------------------------------------------| $src_file | full path of the tex file $src_file_name | name of the tex file $src_file_ext | extension of the tex file $src_file_base_name | name of the tex file without the extension $src_file_path | full path to directory containing tex file $line | line to sync to $col | column to sync to ''' # only do the rest if we must if not self.CONTAINS_VARIABLE.search(s): return(s, False) sublime_binary = get_sublime_exe() or '' pdf_file_path = os.path.split(pdf_file)[0] pdf_file_name = os.path.basename(pdf_file) pdf_file_base_name, pdf_file_ext = os.path.splitext(pdf_file_name) if tex_file is None: src_file = '' src_file_path = '' src_file_name = '' src_file_ext = '' src_file_base_name = '' else: if os.path.isabs(tex_file): src_file = tex_file else: src_file = os.path.normpath( os.path.join( pdf_file_path, tex_file ) ) src_file_path = os.path.split(src_file)[0] src_file_name = os.path.basename(src_file) src_file_base_name, src_file_ext = os.path.splitext(src_file_name) template = string.Template(s) return (template.safe_substitute( pdf_file=pdf_file, pdf_file_path=pdf_file_path, pdf_file_name=pdf_file_name, pdf_file_ext=pdf_file_ext, pdf_file_base_name=pdf_file_base_name, sublime_binary=sublime_binary, src_file=src_file, src_file_path=src_file_path, src_file_name=src_file_name, src_file_ext=src_file_ext, src_file_base_name=src_file_base_name, line=line, col=col ), True)
def _replace_vars(self, s, pdf_file, tex_file=None, line='', col=''): ''' Function to substitute various values into a user-provided string Returns a tuple consisting of the string with any substitutions made and a boolean indicating if any substitutions were made Provided Values: --------------------|-----------------------------------------------| $pdf_file | full path of PDF file $pdf_file_name | name of the PDF file $pdf_file_ext | extension of the PDF file $pdf_file_base_name | name of the PDF file without the extension $pdf_file_path | full path to directory containing PDF file $sublime_binary | full path to the Sublime binary Forward Sync Only: --------------------|-----------------------------------------------| $src_file | full path of the tex file $src_file_name | name of the tex file $src_file_ext | extension of the tex file $src_file_base_name | name of the tex file without the extension $src_file_path | full path to directory containing tex file $line | line to sync to $col | column to sync to ''' # only do the rest if we must if not self.CONTAINS_VARIABLE.search(s): return (s, False) sublime_binary = get_sublime_exe() or '' pdf_file_path = os.path.split(pdf_file)[0] pdf_file_name = os.path.basename(pdf_file) pdf_file_base_name, pdf_file_ext = os.path.splitext(pdf_file_name) if tex_file is None: src_file = '' src_file_path = '' src_file_name = '' src_file_ext = '' src_file_base_name = '' else: if os.path.isabs(tex_file): src_file = tex_file else: src_file = os.path.normpath( os.path.join(pdf_file_path, tex_file)) src_file_path = os.path.split(src_file)[0] src_file_name = os.path.basename(src_file) src_file_base_name, src_file_ext = os.path.splitext(src_file_name) template = string.Template(s) return (template.safe_substitute(pdf_file=pdf_file, pdf_file_path=pdf_file_path, pdf_file_name=pdf_file_name, pdf_file_ext=pdf_file_ext, pdf_file_base_name=pdf_file_base_name, sublime_binary=sublime_binary, src_file=src_file, src_file_path=src_file_path, src_file_name=src_file_name, src_file_ext=src_file_ext, src_file_base_name=src_file_base_name, line=line, col=col), True)