File: pyedit-products/unzipped/textConfig.py
""" =================================================================================== textConfig.py: PyEdit (textEditor.py) configuration module. Edit the Python variable assignments below to customize PyEdit's appearance and behavior for your preferences. These settings are applied at startup time; some can also be modified in the GUI itself (e.g., fonts and colors). Color and font settings: For colors: Use either a color-name string that Tk understands (e.g., 'navy'), or an RGB-value hex string (e.g., '#0000FF'). You can get custom RGB strings from the tools/pickcolor.py script, and PyEdit's Info dialog also reports colors you've set in the GUI itself. Both can be used for cut-and-paste here. For fonts: Use a 3-item tuple giving font family, size, and style (for example, ('menlo', 13, 'normal')). The style part is a space-separated list that may include 'normal' or 'bold', and 'italic' or 'roman', and an omitted style defaults to 'normal'. Size may be positive for points, negative for pixels, or 0 for a default size, and omitting size is the same as 0 (the default). A string 'family size style...' also works if the family name has no spaces, but you can never omit size unless you also omit style (their order matters). See the Pick Font dialog's in-program help for more pointers. Use in standalone and embedded roles: This module is imported normally via the module search path. Although the version here is loaded and used when PyEdit is run standalone, this module can also be redefined locally per client program, by creating a file of the same name in the program's '.' home folder. PyMailGUI, for example, embeds PyEdit and provides its own version of textConfig.py that overrides this. When redefined this way, the local file fully replaces this file - its settings do not augment those here, unless that other file also imports the names here (e.g., via "from *"). If a name is not set in the sole textConfig.py imported (here or elsewhere), that name's in-program default is used. If this module is not on the search path at all, it will be skipped altogether, and all names' in-program defaults will be applied. More details: 1) As noted, all names here have presets in the program that are used if not set in the sole textConfig.py file imported. So, for example, if you don't set color and font lists either here or in a client program's local version of this file, the program code's presets will be used. 2) Exception: for ease of use (and because they're crucial), PyEdit's Unicode behavior settings always come from this file, _not_ a client program's local textConfig.py. These are complex enough that they seem best set once here, for all PyEdit roles. See later in this file for the Unicode settings. 3) Caution: PyEdit is not currently forgiving about errors here. Please edit with care, and verify your changes before relying on them (e.g., import or run this file to check for syntax; PyEdit's Run Code can be used for this). Some errors may silently fail if you have no console window, and may even hang the GUI (this is a to-be-improved but low priority). =================================================================================== """ import sys # for checking platform, version, etc. # For platform-specific choices RunningOnMacOS = sys.platform.startswith('darwin') # all macOS (f.k.a. OS X) RunningOnWindows = sys.platform.startswith('win') # all Windows RunningOnLinux = sys.platform.startswith('linux') # all Linux, incl Android # [4.0] additions RunningOnAndroid = hasattr(sys, 'getandroidapilevel') # Android only (py 3.7+) RunningOnLinuxOnly = RunningOnLinux and not RunningOnAndroid # non-Android Linux #================================================================================== # Basic Edit-Window Configurations: Initial Font, Color, Size # # Comment-out any setting in this section to accept Tk or program defaults. # All of these are used for initial configuration only: you can change font # and colors from GUI menus and resize the window interactively at any time. # # See also the font and color lists ahead for mutiple-choice options that can # be cycled through on demand (and automatically for colors); the Run-Code # font and color settings below for output-window settings; and the toolbar # font settings up next for configuring controls. # # [3.0] The insertion cursor is now also set to the same color as foreground # (fg) text, so its default black doesn't get lost in a dark background (bg). # This does not require any additional settings in this file. #================================================================================== # Initial main-text font # ('family', size, 'style...'?) font = ('courier', 12, 'bold') # default for all platforms # Customize per platform? if RunningOnMacOS: # specialize, else tiny [3.0] font = ('menlo', 13, 'normal') # also mono on Mac: monaco, courier/15 elif RunningOnWindows: # size was 9, then 12 font = ('consolas', 13, 'normal') # also mono on Windows: courier (new) elif RunningOnLinuxOnly: # if differs from default (includes Android) font = ('inconsolata', 11, 'normal') # also mono on Linux: 'courier new' elif RunningOnAndroid: # space is limited on mobiles [4.0] font = ('courier', 9, 'normal') # inconsolata=helvetic: not monospaced # Initial background/foreground colors # default=colorlist[0] (see ahead) bg = 'ivory' # colorname or #RRGGBB hexstr fg = 'black' # e.g., 'powder blue', '#690f96' # Initial text-area size: lines, chars (subject to toolbar layout) if RunningOnMacOS: height = 34 # Use the space on Macs (not 35...) width = 90 # can resize after open arbitrarily elif RunningOnWindows: height = 26 # Tk default=24 lines (if not set) width = 90 # Tk default=80 characters (if not set) elif RunningOnLinuxOnly: height = 30 # toolbar was labels, now buttons [4.0] width = 90 # no need to make wider to accomodate elif RunningOnAndroid: # mobiles: first-maximized affects size [4.0] height = 30 # width has no effect, toolbar dominates width = 40 # see also sizeWindowToScreenEnable ahead #================================================================================== # [3.0] Toolbar: Font, Layout # # Choose a font for the quick-access buttons at the bottom of edit windows. # These are redundant with menus and their accelerator-key combos, but may # be useless nonetheless, especially if your input is limited on a tablet. # # You can also now choose a fixed toolbar-layout scheme (so buttons are always # in the same position) or a variable scheme where space between button groups # grows and shrinks with the window. The latter keeps more on screen (default). #================================================================================== # Font for button row at bottom toolbarFont = None # None = system default font # or ('family', size, 'style...'?) # Customize per platform? if RunningOnMacOS: toolbarFont = ('tahoma', 12, 'normal') # or None, monaco, menlo, courier elif RunningOnWindows: toolbarFont = ('consolas', 9, 'bold') # or tahoma, 'segoe ui', arial elif RunningOnLinuxOnly: toolbarFont = ('inconsolata', 10) # was labels, now buttons [4.0] elif RunningOnAndroid: toolbarFont = ('inconsolata', 6) # space is limited on mobiles [4.0] # Spacers in toolbar do not expand? # True=buttons stay in same place toolbarFixedLayout = False # False=spacers expand with window #================================================================================== # [3.0] Run Code: Font, Color # # If not None, the following font setting is used only for output text in # the window displayed for Run-Code's Capture mode. The default font is a # reasonable fixed-width, so this is optional. See above for example fonts. # # The code's output-text color can be configured here too, but it is not by # default - its lack of color suffices to make it distinct from edit windows. # But your mileage may vary: a unique color scheme may work well here. #================================================================================== # Output font for all platforms runcodefont = None # a font, or None=system default # Customize per platform? if RunningOnMacOS: # or menlo for tighter lines? runcodefont = ('monaco', 12, 'normal') # default=monaco 11 normal elif RunningOnWindows: # or courier, other? runcodefont = ('consolas', 12, 'normal') # default=courier 10 normal elif RunningOnLinuxOnly: # or same as Windows? runcodefont = ('inconsolata', 11, 'normal') # consolas not mono on Linux elif RunningOnAndroid: # space is limited on mobiles [4.0] runcodefont = ('courier', 9, 'normal') # monospace in pydroid 3 app's tk # Color of code output: background/foreground runcodebg = None # or 'black'? # None = white/black default runcodefg = None # or 'green2'? # else color 'name' or '#RRGGBB' #================================================================================== # [3.0] Grep Search: Matches List Font and Spawn Mode # # The font here is used in the Grep-matches selection list. A None invokes # the platform default, which may be too small from some users on some Windows. # # You can also define the spawn mode for Grep; change this to an alternative # if the Grep option in Tools crashes. You'll generally want to leave this as # is. The preset attempts to workaround a thread bug in Python 3.5/Tk 8.6, # and has significant performance advantages. It's available here just in case # the preset is problematic on a given platform (or threading's story improves). #================================================================================== # Matches-list font grepMatchesFont = None # None=default, or ('family', size, 'style...'?) # Customize per platform? if RunningOnMacOS: grepMatchesFont = ('menlo', 13, 'normal') # None default _was_ nice [4.0] elif RunningOnWindows: grepMatchesFont = ('consolas', 12, 'normal') # else too small elif RunningOnLinuxOnly: grepMatchesFont = ('inconsolata', 10, 'normal') # else too small elif RunningOnAndroid: grepMatchesFont = ('courier', 8, 'normal') # space limited on mobiles [4.0] # Use process or threads? (for gurus only) grepSpawnMode = 'multiprocessing' # values: multiprocessing, _thread, or threading if RunningOnAndroid: grepSpawnMode = '_thread' # multiprocessing fails, use threads code [4.0] #================================================================================== # Find (Simple Version) is Case-Insensitive? [Legacy Switch] # # [3.0] Note: the case-insensitivity ('a'='A') setting applies to Find searches # within a single window's text, but not to Grep searches in external files. # This makes Grep more specific in order to minimize the number of matches. # # [3.0] This is now for the simple Find dialog (and its accelerators) only. # Both the Change (find/change) and Grep (external files search) dialogs # now have GUI toggles to select case, which start as case-insensitive. #================================================================================== # Find is case insensitive? caseinsens = True # default=1/True (on) if not set #================================================================================== # [3.0] Color and Font Cycling Lists # # Set the following two names to the types of values shown to override preset # color and font lists that are cycled through when the GUI's menu options # "Tools->Font List" (F1) and "Tools->Color List" (F3) are selected - the next # item in the list is always applied. The toolbar's "Color" and "Font" buttons # cycle through these choices too, and the colorlist setting here will also be # used automatically by the color-cycling feature described in the next section. # # You can list any number of items in each of the lists below, per syntax shown. # For colors, fg=foreground and bg=background, and settings may be Tk color # names or '#RRGGBB' hex-value strings (see tools/pickcolor.py for the latter). # # If you also set the basic "bg" and "fg" above, they will be used for the # first window in each PyEdit instance (process), and added to the end of # the color list (here or default) so that they come up during color cycling. # # These settings are mostly a convenience. While you can always select fonts # and colors in the GUI's Tools menu at the start of each session, the lists # here are a more permanent way to access your favorite font and color choices. # If they are not set here (or in a client program's local textConfig.py file), # both lists default to their in-program presets in code (in textEditor.py). #================================================================================== # _Not_ setting these means you'll use the presets assigned in the program. # Remove the """ quotes above and below and edit to enable these overrides. """ colorlist = [dict(fg='black', bg='beige'), # or {'fg': xxx, 'bg': yyy} dict(fg='green2', bg='black'), # color name or #RRGGBB hex dict(fg='white', bg='#173166'), # as many as you wish dict(fg='#00ffff', bg='#3b3b3b') # picks next each time ] fontlist = [('courier', 11, 'normal'), # ('family', size, 'style...') ('arial', 12, 'bold italic'), # as many as you wish ('times', 18, 'bold'), # picks next each time ('consolas', 13, 'normal'), # Win (inconsolata on Linux) ('monaco', 14, 'normal') # Mac (also fixed: 'menlo') ] """ #================================================================================== # [3.0] Automatic Color Cycling for New Windows # # If the following variable is True, PyEdit automatically sets the foreground # and background color of each new edit window after the first to the next # color in the color list. # # The color list is the "colorlist" setting (or its preset default) described # in the preceding section. Its colors can be applied manually by the Tools # Menu's Color List (F3) menu option. The setting here, if True, applies the # list's colors to windows automatically when they are opened, to make each # distinct in a session. For example, each new Popup window opened and Grep # match clicked will display a different color scheme from the list. On macOS, # each click to the app or its Dock entry when already open does likewise. # # Note that this setting applies both to top-level (popup) windows that are # opened by Popup (Cmd/Ctrl-p), Clone, and other programs, and to embedded # component windows of the sort used in PyMailGUI View/Write windows; disable # it in a client program's textConfig.py if this proves too distracting. In # PyMailGUI, for example, fixed per-account color schemes may be preferred. #================================================================================== colorCycling = True # True=next color for each window, False=disabled #================================================================================== # [3.0] Auto-Save Folder and Timing Control # # If autoSaveToFolder in the following is set to None (or not assigned) in this # imported textConfig module, no auto-save is performed. # # Otherwise, every 3 minutes (as preset), PyEdit auto-saves the text content # of each changed and unsaved main, popup, or embedded-component window to a # file in the folder whose full pathname is assigned to autoSaveToFolder here. # These saved files serve as emergency recovery copies, and are automatically # deleted by PyEdit after 7 days (as preset) to minimize clutter and space. # # Important: auto-save DOES NOT overwrite the actual file(s) being edited # in-place, but merely saves copies of changed and unsaved edit windows' # content to a separate folder. This feature is intended as a last resort # for recovery from outright program crashes or unintended operator mistakes. # # Auto-save applies to all top-level windows in PyEdit, and to both top-level # popups and embedded components of View/Write windows in PyMailGUI. In all # roles, only changed windows' content is auto-saved (not text only viewed). # # FOLDER SETTING: # # The preset value below auto-saves files to a specially named (but not hidden) # folder in the running program's current working directory ('.'). This is # normally PyEdit's install directory but not when PyEdit is being used as a # tool by another program (e.g., changes in PyMailGUI appear in PyMailGUI's own # install folder). For standalone PyEdit, the default auto-save folder is # in the Pyedit unzip folder for both the source-code and Windows executable # packages, and usually in /Applications/Contents/Resources for the macOS app. # Users may change this setting to auto-save to any folder on their computer. # Use a folder name with a leading "." if you prefer that this folder be hidden # (e.g., so it is not copied by data archive/mirror programs such as Mergeall). # The auto-save folder is created automatically if it does not yet exist. # # TIMING SETTINGS: # # The preset values below run auto-save every 3 minutes, and prune saved files # that have not been rewritten in one week's time. You can change these values # (e.g., to auto-save more or less often), but these defaults generally suffice: # 3 minutes is frequent (and roughly the time it takes to compose no more than # one decently-sized paragraph), and catastrophic data loss (e.g., due to a # crash) will usually be known immediately. If you prefer to auto-save but not # auto-prune saved files, set the retention value to a very high number. As a # rule, the auto-save folder stores temporary copies, and is self-cleaning to # minimize its clutter and size; save files in the GUI for long-term storage. # # FILENAMES: # # Auto-saves use either a known filename, or a generated name for nameless # windows (i.e., text not opened from a file and not yet saved to one). # Both adopt naming patterns to make files unique in the auto-save folder. # # For known filenames, the auto-save's name is "fff--AT--ddd--BY-ppp.txt", # where "fff" is the base filename, "ddd" is the directory where "fff" is # located with slashes changed to underscores, and "ppp" is the process ID of # the PyEdit instance. The directory part (or as much of it as will fit in a # filename) is added to make same-named files unique, and the pid part is used # to make saves unique if the same file is edited in different PyEdit instances. # Rename to "AT" and "BY" parts if you are restoring from the save. # # For nameless windows (new text that has not yet been saved), the auto-save's # name is of the form "_nameless-nnn--BY--ppp.txt", where nnn is a nameless-edits # sequence number that is unique within a session (it's incremented for each # new edit window and New GUI action), and ppp is a process iID that is unique # across multiple PyEdit sessions running on your computer. If you need to # recover nameless text, it may help to also sort the auto-save folder by # modtime, so you can focus on recent saves. # # UNICODE ENCODING: # # In all cases, auto-saves always encode all saved files per the general # UTF-8 Unicode encoding scheme. This handles all text, but convert saved # files to different encodings if required for your use cases (e.g., by # Open as UTF-8 and Save As other within PyEdit itself). # # [4.0] Auto-save filenames were altered as described above (known names add # process ID and ".txt", and nameless names add "BY" for symmetry), and the # preset for autoSaveMinsTillRun was changed from 5 to 3 (an eternity on comps). #================================================================================== # Main setting: where to save files # relative to '.' if no folder path autoSaveToFolder = '__pyedit-autosaves__' # or pathame, or None=no auto-saves # Timing settings autoSaveMinsTillRun = 3 # number minutes between auto-saves (3 == 1 para) autoSaveDaysRetained = 7 # number days until auto-saved files are deleted #================================================================================== # [3.0] Run Code: Python Interpreter and Import Paths # # Out of the box, PyEdit's Run Code is very limited and will run only very # simple Python programs that do not import many standard library modules. # Read on if you need Run Code access to your locally installed Python's full # standard library and/or locally installed Python extensions. # # When launching Python code with the Tools=>Run Code option (toolbar Run), the # default Python used for your code is that used to run PyEdit. This is either: # # 1) The locally installed Python used to run PyEdit. This is always the case # for source-code distributions of PyEdit, as well as Run Code's Click modes. # Source-code PyEdit must be run with an installed Python, and Click modes run # code with a Python you've associated with files or types on your computer. # This Python launches quickly, because it runs source-code files. # # 2) A minimal version, with a limited number of Python standard libraries "baked # in" and no builtin access to any extension libraries installed locally. This is # the case for frozen app and executable distributions, which require no Python # install: your libraries aren't in the freeze, and a local Python can't be assumed. # This Python lauches slowly, because it's an executable that must be loaded. # # To access more modules and tools in the code you write and run in PyEdit, and # as a bonus reduce Run Code startup time in general, you can verride these # defaults by setting variables below: # # RunCode_PYTHONEXECUTABLE: # # To force PyEdit's Run Code to run your code in Console and Capture modes with # a Python interpreter that you've installed locally, set the first variable # below to the full pathname of the installed Python executable you wish to use. # In most contexts this also adds the chosen Python's standard library folders # to the sys.path import path automatically, so these do not require setup. # # The executable setting works for any Python -- including a Python 2.X, even # though PyEdit itself runs on 3.X. Python 2.X code generally runs in Pyedit, # including any "from __future__ import X" statements. This means your code # can choose to use either Python 3.X or 2.X prints as usual. # # Note that this setting is not required if you wish to experiment with basic # code in frozen PyEdits (which include a Python standard library subset), or # use modules saved in the same directory as the script being run (which is # always on sys.path). Edit this setting to use a specific Python, or enable # any locally-installed packages (path settings below can also do the latter). # # Hint: to locate your local Python's path for pasting here, start your local # Python's REPL (interactive session), run "import sys" and then "sys.executable" # at the ">>>" prompt, and paste the result here. A "which python3" command line # may also suffice on Unix, as may "where python" on Windows if your PATH is set. # # RunCode_PYTHONPATH_APPENDS/PREPENDS: # # To force PyEdit to extend the module import path to include your local # development folders or extension installs in Capture mode, add your local # folders to the append and/or prepend lists of pathnames assigned to the # variables below. Appends are added to the end of the import path, prepends # are added to the front, and in both cases multiple items are added in the # same left-to-right order as that in your lists here. Prepends may work # better in some cases (e.g., for same-named modules in multiple folders). # # Note that these settings are not required for your main script's folder, # which is always on the path. They are also not normally not required to use # standard library modules if you set a Python executable's path; sys.path is # then configured to see standard folders automatically by the Python run. # # Also note that your normal PYTHONPATH environment variable may work for # setting import paths in Console and Capture modes too, but on some platforms # may require that PyEdit itself be launched from a console command line # instead of by clicks (e.g., for some macOS X apps). Use the import-path # settings here if needed to configure your path to import from local folders. # # In all cases, PyEdit ignores pathnames set here that do not exist or refer to # invalid types, and falls back on its defaults. # # WHEN THESE SETTINGS ARE NEEDED: # # 1) You generally do _not_ need to set any of this section's three names # when running PyEdit's source-code version, as you will control the version # of Python (and its libs) used to start PyEdit, and hence run your own code. # You may still want to set your Python, though, to test edited code with a # different version than that required to run PyEdit itself. # # 2) You probably _do_ need to set Python executable and/or module-import paths # if you wish to access any locally-installed third-party libraries in code run # by a frozen PyEdit app or executable. Your local Python's site-packages # folder is unknown to the frozen PyEdit's bundled Python. Setting a Python # executable also makes its site-packages folder automatically importable, # and gives you acces to your Python's complete standard library of modules. # # 3) The only _required_ setting here is Python executable for Console mode, # when using frozen PyEdits on Windows or Linux (no stand-alone Python ships). # # 4) Frozen Pyedits _may_ require a locally-installed Python executable's # path in order access the full standard library, as well as to run some # programs that start other Python programs in Capture mode; see README.txt # and docetc/examples/RunCode-examples/spawner.py. Settings are optional in # other cases, and depend on your goals. # # CAVEAT: # # These settings work, but running alternative Pythons is a complex business. # Some third-party packages may manipulate import paths in unusual ways that # may throw off Run Code imports on some platforms, even with the settings here. # As a worst-case fallback, use the source-code version of PyEdit if frozen # PyEdits refuse to use your local Python or allow imports of your local libs. # # See the Run Code dialog's in-program Help for more Run Code usage details. # See the examples followng the presets below for more ideas and inspiration. # # [4.0] As noted in the User Guide, PyEdit 4.0 no longer includes a full # Python standard library because doing so makes code startup times slow # in standalone apps and executables. For best Run Code results, please # install a Python locally and set the variables in this section to gain # access to modules and extensions. Doing so also reduces code startup # time further in standalone PyEdit packages. Not doing so makes PyEdit's # Run Code not much more useful than a demo as few modules are accessible. #================================================================================== # Use this Python (and its libs) instead of default RunCode_PYTHONEXECUTABLE = None # None=use default, else 'pathname' # Append all these to sys.path's tail for imports RunCode_PYTHONPATH_APPENDS = [] # list of pathname strings to add # Prepend all these to sys.path's front for imports RunCode_PYTHONPATH_PREPENDS = [] # list of pathname strings to add #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # EXAMPLES: remove r""" and """ lines above and below, and edit, replacing *YOU* # with your user name. Always start with r""" to disable, else embedded \ fail. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #---------------------------------------------------------------------------------- # EXAMPLE: using a specific local Python 3.X for frozen app/exe or source packages #---------------------------------------------------------------------------------- r""" if RunningOnMacOS: # python.org's 3.X (or Homebrew, /usr/local/bin/python3) RunCode_PYTHONEXECUTABLE = \ '/Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12' elif RunningOnWindows: # varies per install options (default install shown) RunCode_PYTHONEXECUTABLE = \ r'C:\Users\*YOU*\AppData\Local\Programs\Python\Python312\python.exe' elif RunningOnLinuxOnly: # not including Android: auto uses Pydroid 3 app's python RunCode_PYTHONEXECUTABLE = \ '/usr/bin/python3' """ #---------------------------------------------------------------------------------- # EXAMPLE: run Python 2.X code in PyEdit, with 2.X or 3.X prints (yes, it works!) #---------------------------------------------------------------------------------- r""" if RunningOnMacOS: # Python 2.X (older Macs' default) RunCode_PYTHONEXECUTABLE = \ '/usr/bin/python' #or: '/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7' elif RunningOnWindows: # ditto on Windows RunCode_PYTHONEXECUTABLE = \ r'C:\Python27\python.exe' elif RunningOnLinuxOnly: # likewise on Linux, not incuding Android RunCode_PYTHONEXECUTABLE = \ '/usr/bin/python' """ #---------------------------------------------------------------------------------- # EXAMPLE: add a specific local Python's install folders # Usually optional: sys.path is normally setup auto by/for the Python executable #---------------------------------------------------------------------------------- r""" if RunningOnMacOS: # python.org's 3.X RunCode_PYTHONPATH_APPENDS = [ '/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12' '/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages' ] elif RunningOnWindows: # default Windows install path RunCode_PYTHONPATH_APPENDS = [ r'C:\Users\*YOU*\AppData\Local\Programs\Python\Python312\Lib' r'C:\Users\*YOU*\AppData\Local\Programs\Python\Python312\Lib\site-packages' ] elif RunningOnLinuxOnly: pass # edit me, not including Android """ #---------------------------------------------------------------------------------- # EXAMPLE: Adding your local dev or lib folders for imports # This works in contexts where the usual PYTHONPATH setting is not supported #---------------------------------------------------------------------------------- r""" if RunningOnMacOS: RunCode_PYTHONPATH_APPENDS = ['/Users/*YOU*/MY-STUFF/Code'] # tail, this order RunCode_PYTHONPATH_PREPENDS = ['/Users/*YOU*/Downloads/ziptools'] # front, this order elif RunningOnWindows: RunCode_PYTHONPATH_APPENDS = [r'C:\Users\*YOU*\MY-STUFF\Code'] RunCode_PYTHONPATH_PREPENDS = [r'C:\Users\*YOU*\Downloads\ziptools'] elif RunningOnLinuxOnly: pass # edit me, not including Android elif RunningOnAndroid: pass # edit me, not including other Linux """ #================================================================================== # 2.1: Unicode Encoding Selection for File Opens and Saves # # --These are complex and installation-wide: change with care-- # # PyEdit attempts the cases listed below in the order shown, until the first # one that works. Set variables below to modify its encoding-choice behavior. # # These settings are always imported from *this file*, not a client program's # local textConfig.py in '.'. They are located here via sys.path if PyEdit # is __main__, else by package relative imports (see textEditor.py). # # UNICODE POLICY NOTES: # # [3.0] As shipped, both Ask settings below are True, which triggers popup dialogs # on both opens and new saves to ask for encodings. This is best from a correctness # perspective, but some PyEdit users might not know or care about Unicode. # # If you are in this general group, either accept the popups' prefilled defaults, # or set the Ask settings below to False to skip the popups completely. In most # cases, the prefilled default is UTF-8, which also handles simple ASCII text. # # However, users who may be editing mixed Unicode file types (e.g., both UTF-8 # and UTF-16) should generally leave these settings as is, and enter an encoding # name when asked. Providing the correct encoding name avoids translation errors, # some of which could pass silently if text is decodable by an incorrect scheme. # # USING PLATFORM DEFAULTS: # # Setting all variables to false (False, '', or 0) uses your platform's default # encoding - which is usually the universal UTF-8 on macOS, Linux, and Android, # but may be cp1252 or other on Windows - unless Python's UTF-8 mode is manually # enabled or your Python is 3.15+. # # For more info on encoding defaults, run code locale.getpreferredencoding(False) # and see the book LP6E (Python's docs are wrong about this today). Most users # should use UTF-8 instead of relying on platform defaults that may not be the # same when files are used on other hosts. # # OTHER IDEAS: # # [3.0] In retrospect, this might have tried a single setting and asked otherwise, # or tried each of a set of common encodings until one worked or all failed, but # these are error-prone models: some text may decode per a set or tried encoding, # but only accidentally! Guessing from content (as web browsers may) could be # tried too (e.g., see chardet), but it's impossible to guess correctly in all # cases; making encodings explicit and trying reasonable sources seems a more # deterministic and safer policy in the end. # # MISC NOTES: # # savesUseKnownEncoding values: # 0=No, 1=Yes for Save only, 2=Yes for Save and SaveAs # # For Opens, the Ask popup's prefilled value is the leftmost non-empty among: # opensEncoding -or- platform default # # For Saves, the Ask popup's prefilled value is the leftmost non-empty among: # known encoding -or- savesEncoding -or- platform default # # If set, this section's opensEncoding is also used to prefill the encoding # name in the Grep external-file-search dialog. This dialog must apply an # encoding to all files in a folder tree, which is much more error prone. # # The "Cancel" button in the encoding-ask dialog of opens and saves does _not_ # abort the operation, but simply skips the ask and moves on to try other encoding # options. It's really a "Skip this step" among the encoding tries listed below. #================================================================================== # FOR OPENS # 1) try internally-known type first (e.g., email charset) opensAskUser = True # 2) <=if True, try user input next (prefilled per above) opensEncoding = '' # 3) <=if nonempty, try this encoding next: 'latin-1', etc. # 4) try platform default for content from locale module next # 5) use binary mode bytes and Tk policy as the last resort # FOR SAVES savesUseKnownEncoding = 1 # 1) <=if > 0, try known encoding from last open or save savesAskUser = True # 2) <=if True, try user input next (prefilled per above) savesEncoding = '' # 3) <=if nonempty, try this encoding next: 'utf-8', etc. # 4) try platform default from locale as a last resort # [4.0] Strongly suggest utf-8 on Windows, even where platform default is # still cp1252. Required because default is now correct, not always utf-8. if RunningOnWindows: opensEncoding = savesEncoding = 'UTF-8' # as on Unix (macOS, Linux, Android) #================================================================================== # [4.0] Oldest Tk version that supports non-BMP Unicode, including emojis # # This is an advanced setting that should not be changed unless you're using # a Python whose Tk library supports emojis and is older than version 8.6.13. # This setting pertains only to users of the source-code package, because # the version of the Tk embedded in the app and executable never varies. # # Before the Tk version given here, PyEdit replaces non-BMP Unicode text, # including emojis, with the Unicode replacement character. This is a config # because it's impossible to test every Tk version for emoji support. # # The preset Tk 8.6.13 supports emojis and is used by Python 3.12 on PCs (and # is embedded in standalone apps and executables), but Tk on the Android # Pydroid 3 app varies. As of 10/2024, Pydroid 3 7.4's Python 3.11 uses # Tk 8.6.10 which lacks emojis, though this may change, and 8.6.11 and 8.6.12 # are unknowns; change this to see if those Tks do emojis in a future Pydroid 3. # # To check Tk version in Pydroid 3's Interpreter (and others) run this Python: # >>> from tkinter import * # >>> Tcl().call('info', 'patchlevel') # # UPDATE: the Tk 8.6.12 used by Python 3.12 on Linux _does_ fully support # non-BMP characters (including emojis), but does not color them (just as on # Windows). The preset below was updated, but may need mods on some hosts. # Tk 8.6.15 used by Python 3.13 still does not colorize emojis outside macOS. # # TIP: setting this to a high value like [9, 9, 9] will also _disable_ support # for emojis and other non-BMP text, and revert to replacing this text with # Unicode replacement characters. This may help if Python or Tk ever fail. #================================================================================== minimumTkForEmojis = [8, 6, 12] # Preset means Tk 8.6.12 or later required for emojis #================================================================================== # [4.0] Use custom file open and/or save dialogs, for crashes or functionality # # On macOS, the system file dialogs called by Tk/tkinter and used for Open and # Save (e.g., NSSavePanel) have a history of crashing. Most notably, the Save # dialog was seen to crash intermittently on macOS Catalina (10.15) when using # Tk 8.6.13, and apparently due to a bug in macOS system code related to that # platform's ever-evolving sandboxing security model. # # This happens only on macOS; occurs many levels below PyEdit's code; may be # dependent on macOS and Tk version; and is unavoidable: there's nothing an app # can do when its GUI library properly runs a system call that crashes. # # If you see such a crash, the only known workaround is to substitute a custom # replacement for macOS file dialogs, by setting the switch below to True. It's # not pretty, but it doesn't crash. And it's unfortunate that macOS ships with # such bugs, but weakest-link fails are sadly a universal in software stacks today. # # Updates: # - Granting macOS's Full Disk Access in Settings/Provacy may work around dialog # crashes too and might make sense to try first, but this is unproven as a fix. # # - The tkinter custom dialog is also arguably better than the Linux system/native # file dialog on Android: enabled as a preset here but mod as desired. # # - You may now configure the custom dialog for opens and saves individually: # in the case of macOS save crashes only, opens can still use native dialogs. #================================================================================== # Defaults: native dialogs opensUseCustomFileDialog = False # False means system/native dialog for opens savesUseCustomFileDialog = False # False means system/native dialog for saves # Android: custom enabled for opens and saves - change to use native Linux dialogs if RunningOnAndroid: opensUseCustomFileDialog = True # Go custom for functionality, not crashes savesUseCustomFileDialog = True # For both Open and Save # macOS: remove quotes above and below to enable for saves only """ if RunningOnMacOS: savesUseCustomFileDialogs = True # Go custom if Save dialog crashes for you """ #================================================================================== # [4.0] Initial folder to display in Open and Save dialogs # # Set a folder path below to use for the first display of Open and Save file dialogs. # Later displays may use the last path used, possibly per dialog. This setting is # useful on Android because navigation, like much else, is tedious on a mobile. # # Android's preset is the root of shared storage, and is the same as '/sdcard' on # most devices but easier to navigate to drives (if ever available in Pydroid 3). # See also impermanent App and Home storage paths in the app's Open menu dialog. #================================================================================== fileDialogsStartFolder = None # Use default: your home (account) root folder # Preset to shared-storage root on Android: see above if RunningOnAndroid: fileDialogsStartFolder = '/storage/emulated/0' # Disabled example settings for others: replace "me" with your user name r""" if RunningOnMacOS: fileDialogsStartFolder = '/Users/me/Documents' if RunningOnWindows: fileDialogsStartFolder = r'C:\Users\me\Documents' if RunningOnLinux: fileDialogsStartFolder = '/home/me/Documents' """ #================================================================================== # [4.0] Size windows to the display (e.g., to avoid off-screen content on Android) # # When enabled below, new windows are initially sized to be as large as the # physical display, less an optional margin size. # # This is primarily intended for use on Android to avoid too-large windows with # content off screen, but this may also be used on other platforms to force an # initial window size (including ~fullscreen for margin=0), and you may wish to # disable this for larger Android tablets with ample displays. # # In all cases the default size is based on window content, and windows can be # resized in the GUI later. This setting applies to first opens of main windows # only, and the margin X and Y settings are deducted from window width and height # leaving empty space on the right and bottom, respectively - adjust as desired. # Popup dialogs are automatically limited to not exceed the size of your display. #================================================================================== sizeWindowToScreenEnable = False # False = accept default initial sizes sizeWindowToScreenMarginX = 0 # 0 = no space around window sizeWindowToScreenMarginY = 0 # X is space on right, Y is space on bottom if RunningOnAndroid: sizeWindowToScreenEnable = True # Size window to display on mobiles sizeWindowToScreenMarginX = 120 # Allow some space for window border/margin sizeWindowToScreenMarginY = 180 # Adjust for your device and orientation #================================================================================== # [4.0] Call out Find/Change matches by underline, bold, and background color # # This setting generally applies only to macOS but can be enabled on other # platforms as an accessibility aid. # # On macOS, the highlighting of selected text may be hard to notice, especially # on dark backgrounds with light text, and particularly when stepping through # matches in the Find/Change dialog. On Windows, Linux, and Android, this is # not usually an issue because highlighting of matched text works well, but # some users may still find matches visually obscure in some color schemes. # # To make Find/Change matches more apparent, a True setting below changes selected # text to use underlining; a bold font; and, on macOS only, the background color # of active widgets. When enabled here, these formats are turned on whenever any # Find/Change dialog is open, and cancelled when the last such dialog is closed. # # This is preset to True for macOS only, but can be enabled elsewhere. If # it's overkill for your colors on macOS, set to False to disable in full. # Tip: to maximize selection visibility on all hosts, use dark text on light # backgrounds; the underlying GUI library now changes selected text to white. #================================================================================== if RunningOnMacOS: emphasizeFindChangeMatches = True # True=call out Find/Change matches via formats else: emphasizeFindChangeMatches = False # False=rely on host's selection highlighting # [END USER SETTINGS]