tb = TEXT_BINDINGS.copy()
tb.update({
'<F3>': lambda tv: tv.copy_selection_to_stack,
- '<F4>': lambda tv: tv.cut,
- # '<F-->': lambda tv: tv.pastecut,
- # '<F6>': lambda tv: tv.copyto,
+ '<Shift-F3>': lambda tv: tv.cut,
+ '<F4>': lambda tv: tv.copyto,
+ '<Shift-F4>': lambda tv: tv.pastecut,
})
defaults = dict(text_bindings=tb, width=80, height=25)
GLOBAL_COMMANDS = {
'<F5>': 'swap',
'<F6>': 'dup',
-
'<Shift-F5>': 'roll<',
'<Shift-F6>': 'roll>',
-
'<F7>': 'over',
'<Shift-F7>': 'tuck',
-
- '<Shift-F3>': 'parse',
-
+ '<F8>': 'parse',
'<F12>': 'words',
'<F1>': 'reset_log show_log',
'<Escape>': 'clear reset_log show_log',
'<Control-Delete>': 'pop',
- '<Control-Shift-Delete>': 'popd',
}
def key_bindings(*args):
- print dedent('''
- Ctrl-Enter - Run the selection as Joy code.
-
- F1 - Reset and show (if hidden) the log.
- Esc - Like F1 but also clears the stack.
- ...
- F12 - print a list of all command words, or right-click "words".
- ''')
+ commands = [
+ 'Control-Enter - Run the selection as Joy code.',
+ '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.iteritems():
+ commands.append('%s - %s' % (key.strip('<>'), command))
+ print '\n'.join([''] + sorted(commands))
return args
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():
- t.bind_all(event, lambda _, _command=command: world.interpret(_command))
+ t.bind(event, lambda _, _command=command: world.interpret(_command))
+ log.bind(event, lambda _, _command=command: world.interpret(_command))
def main():
self.delete('0.0', tk.END)
self.insert(tk.END, data)
-
def popupTB(self, tb):
top = tk.Toplevel()
T = TextViewerWidget(
('pred', ['--']),
('rolldown', ['roll<']),
('rollup', ['roll>']),
+ ('eh', ['?']),
('id', [u'•']),
)
FUNCTIONS = {
name: SymbolJoyType(name, [DEFS[name]], i)
- for i, name in enumerate('''
- ccons cons divmod dup dupd dupdd first first_two fourth over pop
- popd popdd popop popopd popopdd rest rrest rolldown rollup second
- stack swaack swap swons third tuck uncons unswons stuncons
- stununcons unit eq ge gt le lt ne and bool not
- _Tree_add_Ee _Tree_delete_R0 _Tree_delete_clear_stuff _Tree_get_E
- add mul sub floordiv modulus div truediv pow
- neg pred succ
- '''.strip().split())
+ for i, name in enumerate(sorted(DEFS))
}
'''Docstring for functions in Sphinx?'''
Return a dict of FunctionJoyType instances to be used with ``infer()``.
'''
- sum_ = product = [(((Ns[1], s1), s0), (n0, s0))]
+ average = sum_ = product = min_ = max_ = [(((Ns[1], s1), s0), (n0, s0))]
clear = [(s0, s1)]
joy.library.i,
joy.library.infra,
joy.library._dictionary['nullary'],
+ joy.library._dictionary['unary'],
+ joy.library._dictionary['binary'],
+ joy.library._dictionary['ternary'],
joy.library.x,
))
})
branch.expect = s7, (s6, (b1, s5))
loop.expect = s6, (b1, s5)
i.expect = nullary.expect = x.expect = s7, s6
+ unary.expect = (s1, (a1, s2))
+ binary.expect = (s1, (a1, (a2, s2)))
+ ternary.expect = (s1, (a1, (a2, (a3, s2))))
dip.expect = dupdip.expect = s8, (a8, s7)
dipd.expect = s8, (a8, (a7, s7))
dipdd.expect = s8, (a8, (a7, (a6, s7)))
and_ = __(b1, b2), __(b3)
bool_ = not_ = __(a1), __(b1)
+ eh = compose(dup, bool_)
- add = div = floordiv = modulus = mul = pow_ = sub = truediv = \
+ add = div = floordiv = mod = mul = pow_ = sub = truediv = \
lshift = rshift = __(n1, n2), __(n3,)
- sqrt = compose(dup, mul)
- succ = pred = neg = __(n1,), __(n2,)
+ sqr = compose(dup, mul)
+ abs_ = floor = succ = pred = neg = __(n1,), __(n2,)
divmod_ = pm = __(n2, n1), __(n4, n3)
first_two = compose(uncons, uncons, pop)