PK! ` texteditor.py#!/usr/bin/env python """ """ import io import os import re import sys import subprocess import tempfile from distutils.spawn import find_executable __version__ = '1.0.3' EDITOR = 'EDITOR' MACOS_EDITORS = [ # The -t flag make MacOS open the default *editor* for the file 'open -t', ] # I'm NOT including vim or emacs in this list because: # # 1. If you are using it, you know what the EDITOR variable is, and you # probably has set it already. # # 2. If you aren't using it, finding yourself in their UI for the first time # is going to be super confusing, in fact "How to exit vim" is a common # Stack Overflow question. Having to google how to set an EDITOR variable is a # less scary alternative. COMMON_EDITORS = [ 'subl', 'vscode', 'atom', ] # In some linuxes `vim` and/or `emacs` come preinstalled, but we don't want # to throw you to their unfamiliar UI unless there are other options. # If you are using them you probably have set your $EDITOR variable anyway. LINUX_EDITORS = COMMON_EDITORS + [ 'kate', 'geany', 'gedit', 'nano', ] WINDOWS_EDITORS = COMMON_EDITORS + [ 'notepad++.exe', 'notepad.exe', ] EDITORS = { 'darwin': MACOS_EDITORS, 'linux': LINUX_EDITORS, 'win': WINDOWS_EDITORS, } def get_possible_editors(): sys_platform = sys.platform for platform in EDITORS: if sys_platform.startswith(platform): return EDITORS[platform] return COMMON_EDITORS def split_editor_cmd(cmd): r"""Split by spaces unless escaped. >>> split_editor_cmd(r'my\ editor --wait') ['my\\ editor', '--wait'] """ return re.split(r'(?[s#3B 7R+t6AϢtهK4B=9qjOȭ败g–Fv7{iH\v?tqظJU{$Ki!+]ڼdsmSTmB ӭ}^9i@Mw30 ֏ءlatݛ]p͓(J"Nv'>QN!kiX?e(1a& ^YL,BwF{Os¸7* +k:QV6ڊ`%)ޞ]m\Ѷoؿ,ײiǭT+^؞Pń=/ݳ+؂,;g\)(8#*+΍ѦHi|rp)A+oH|\t+(ͷ;_ j^;Z]h|㐲Sc+niiH}*,Pےy4=ÓZ_Zэvr!T+ߏǙ*F703H)a*}C1S:K?1e#bm<bT&!V)bJ#6xGNP#n/.uK6V;5"#o;bŠE.J*~UmES3vY946m+9H_qAvw<d3/6?5ąѼ`,MFg;QȶHAv>DᎫNf6+D icvam+iipckz5!dvś l&->գoXMk.s^>X dw]>^7YA+)k|0_t%0/DB@ m8A98Uܽc27͂Rnix!n+Ɲ*nt *1 Awȋ E[س ¢*n*h!rCS.2,5F gKK==N0-6$4e|4x:SiwbS$Fo;" 6<22-9u=1Sb5_ySgZ6rz