Skip to content

Commit

Permalink
ptig - editor support in config file
Browse files Browse the repository at this point in the history
  • Loading branch information
clach04 committed Sep 2, 2023
1 parent 56bdba4 commit 92e6c9e
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions puren_tonbo/tools/ptig.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,21 +309,38 @@ def do_results(self, line=None):
do_r = do_results

def do_edit(self, line=None):
"""Edit using external $PT_VISUAL, $VISUAL or $EDITOR, with fall backs if unset.
"""Edit using external $PT_VISUAL, $VISUAL or $EDITOR, ptig.editor in config file with fall backs if unset.
Microsoft Windows will use file associations.
If not set:
Linux/Unix will use editor, which under Debian derivatives like
Ubuntu can be configured via:
1. Microsoft Windows will use file associations.
sudo update-alternatives --config editor
update-alternatives --list editor
2. Linux/Unix will use editor, which under Debian derivatives like
Ubuntu can be configured via:
sudo update-alternatives --config editor
update-alternatives --list editor
To set in config file:
{
....
"ptig": {
"editor": "start scite", # Windows
"editor": "start gvim", # Windows
"editor": "gvim", # Linux, etc.
....
}
}
For Windows use "start" so that ptig does NOT wait for editor to exit.
Use ptconfig commandline tool to generate skeleton config.
"""
line = self.validate_result_id(line)
if line is None:
return
filename = line
editor = os.environ.get('PT_VISUAL') or os.environ.get('VISUAL') or os.environ.get('EDITOR')
editor = os.environ.get('PT_VISUAL') or os.environ.get('VISUAL') or os.environ.get('EDITOR') or self.pt_config['ptig'].get('editor')
if puren_tonbo.is_encrypted(filename):
# Prompt for password for editors that won't prompt
# TODO how to indicate whether ptig should prompt (and set environment variable)?
Expand Down

0 comments on commit 92e6c9e

Please sign in to comment.