Switch to tabs for indentation.

Instead of a mix of 2- and 4-space tabs just use actual tabs.  ;-P
This commit is contained in:
Simon Forman
2020-04-24 12:48:15 -07:00
parent 2fb610e733
commit 078f29830d
26 changed files with 4080 additions and 4080 deletions
+60 -60
View File
@@ -23,10 +23,10 @@ repo = init_home(JOY_HOME)
_log = logging.getLogger(__name__)
logging.basicConfig(
format='%(asctime)-15s %(levelname)s %(name)s %(message)s',
filename=os.path.join(JOY_HOME, 'thun.log'),
level=logging.INFO,
)
format='%(asctime)-15s %(levelname)s %(name)s %(message)s',
filename=os.path.join(JOY_HOME, 'thun.log'),
level=logging.INFO,
)
_log.info('Starting with JOY_HOME=%s', JOY_HOME)
@@ -39,73 +39,73 @@ from joy.utils.stack import stack_to_string
cp = RawConfigParser()
cp.optionxform = str # Don't mess with uppercase.
with open(os.path.join(args.joy_home, 'thun.config')) as f:
cp.readfp(f)
cp.readfp(f)
GLOBAL_COMMANDS = dict(cp.items('key bindings'))
def repo_relative_path(path):
return os.path.relpath(
path,
os.path.commonprefix((repo.controldir(), path))
)
return os.path.relpath(
path,
os.path.commonprefix((repo.controldir(), path))
)
def commands():
# pylint: disable=unused-variable
# pylint: disable=unused-variable
def key_bindings(*args):
commands = [ # These are bound in the TextViewerWidget.
'Control-Enter - Run the selection as Joy code, or if there\'s no selection the line containing the cursor.',
'F3 - Copy selection to stack.',
'Shift-F3 - Cut selection to stack.',
'F4 - Paste item on top of stack to insertion cursor.',
'Shift-F4 - Pop and paste top of stack to insertion cursor.',
]
for key, command in GLOBAL_COMMANDS.items():
commands.append('%s - %s' % (key.lstrip('<').rstrip('>'), command))
print('\n'.join([''] + sorted(commands)))
return args
def key_bindings(*args):
commands = [ # These are bound in the TextViewerWidget.
'Control-Enter - Run the selection as Joy code, or if there\'s no selection the line containing the cursor.',
'F3 - Copy selection to stack.',
'Shift-F3 - Cut selection to stack.',
'F4 - Paste item on top of stack to insertion cursor.',
'Shift-F4 - Pop and paste top of stack to insertion cursor.',
]
for key, command in GLOBAL_COMMANDS.items():
commands.append('%s - %s' % (key.lstrip('<').rstrip('>'), command))
print('\n'.join([''] + sorted(commands)))
return args
def mouse_bindings(*args):
print(dedent('''
Mouse button chords (to cancel a chord, click the third mouse button.)
def mouse_bindings(*args):
print(dedent('''
Mouse button chords (to cancel a chord, click the third mouse button.)
Left - Point, sweep selection
Left-Middle - Copy the selection, place text on stack
Left-Right - Run the selection as Joy code
Left - Point, sweep selection
Left-Middle - Copy the selection, place text on stack
Left-Right - Run the selection as Joy code
Middle - Paste selection (bypass stack); click and drag to scroll.
Middle-Left - Paste from top of stack, preserve
Middle-Right - Paste from top of stack, pop
Middle - Paste selection (bypass stack); click and drag to scroll.
Middle-Left - Paste from top of stack, preserve
Middle-Right - Paste from top of stack, pop
Right - Execute command word under mouse cursor
Right-Left - Print docs of command word under mouse cursor
Right-Middle - Lookup word (kinda useless now)
'''))
return args
Right - Execute command word under mouse cursor
Right-Left - Print docs of command word under mouse cursor
Right-Middle - Lookup word (kinda useless now)
'''))
return args
def reset_log(*args):
log.delete('0.0', tk.END)
print(__doc__)
return args
def reset_log(*args):
log.delete('0.0', tk.END)
print(__doc__)
return args
def show_log(*args):
log_window.wm_deiconify()
log_window.update()
return args
def show_log(*args):
log_window.wm_deiconify()
log_window.update()
return args
def grand_reset(s, e, d):
stack = world.load_stack() or ()
log.reset()
t.reset()
return stack, e, d
def grand_reset(s, e, d):
stack = world.load_stack() or ()
log.reset()
t.reset()
return stack, e, d
return locals()
return locals()
STACK_FN = os.path.join(JOY_HOME, 'stack.pickle')
@@ -125,19 +125,19 @@ FONT = get_font('Iosevka', size=14) # Requires Tk root already set up.
log.init('Log', LOG_FN, repo_relative_path(LOG_FN), repo, FONT)
t.init('Joy - ' + JOY_HOME, JOY_FN, repo_relative_path(JOY_FN), repo, FONT)
for event, command in GLOBAL_COMMANDS.items():
callback = lambda _, _command=command: world.interpret(_command)
t.bind(event, callback)
log.bind(event, callback)
callback = lambda _, _command=command: world.interpret(_command)
t.bind(event, callback)
log.bind(event, callback)
def main():
sys.stdout, old_stdout = FileFaker(log), sys.stdout
try:
t.mainloop()
finally:
sys.stdout = old_stdout
return 0
sys.stdout, old_stdout = FileFaker(log), sys.stdout
try:
t.mainloop()
finally:
sys.stdout = old_stdout
return 0
if __name__ == '__main__':
main()
main()