1 from __future__ import division
10 sys.path.append("../")
18 "CENTER": {"action": "7", "type": "text", "text": "7", },
19 "showAllSlices": True,
22 "CENTER": {"action": "8", "type": "text", "text": "8", },
23 "SOUTH": {"action": "[**]", "type": "text", "text": "**", },
24 "EAST": {"action": "[sq]", "type": "text", "text": "sq", },
25 "WEST": {"action": "[sqrt]", "type": "text", "text": "sqrt", },
26 "showAllSlices": False,
29 "CENTER": {"action": "9", "type": "text", "text": "9", },
30 "showAllSlices": True,
33 "CENTER": {"action": "4", "type": "text", "text": "4", },
34 "showAllSlices": True,
37 "CENTER": {"action": "5", "type": "text", "text": "5", },
38 "EAST": {"action": "[+]", "type": "text", "text": "+", },
39 "WEST": {"action": "[-]", "type": "text", "text": "-", },
40 "NORTH": {"action": "[*]", "type": "text", "text": "*", },
41 "SOUTH": {"action": "[/]", "type": "text", "text": "/", },
42 "showAllSlices": True,
45 "CENTER": {"action": "6", "type": "text", "text": "6", },
46 "showAllSlices": True,
49 "CENTER": {"action": "1", "type": "text", "text": "1", },
50 "EAST": {"action": "0", "type": "text", "text": "0", },
51 "showAllSlices": True,
54 "CENTER": {"action": "2", "type": "text", "text": "2", },
55 "EAST": {"action": "[abs]", "type": "text", "text": "abs", },
56 "NORTH": {"action": ".", "type": "text", "text": ".", },
57 "WEST": {"action": "[+-]", "type": "text", "text": "+/-", },
58 "showAllSlices": True,
61 "CENTER": {"action": "3", "type": "text", "text": "3", },
62 "NORTH": {"action": "[!]", "type": "text", "text": "!", },
63 "WEST": {"action": "j", "type": "text", "text": "j", },
64 "showAllSlices": True,
68 PLUGIN = plugin_utils.PieKeyboardPluginFactory(_NAME, _MAP, [])
70 addition = operation.generate_function(operator.add, "+", operation.Function.REP_INFIX, 2)
71 subtraction = operation.generate_function(operator.sub, "-", operation.Function.REP_INFIX, 2)
72 multiplication = operation.generate_function(operator.mul, "*", operation.Function.REP_INFIX, 2)
73 trueDivision = operation.generate_function(operator.truediv, "/", operation.Function.REP_INFIX, 2)
75 PLUGIN.register_operation("+", addition)
76 PLUGIN.register_operation("-", subtraction)
77 PLUGIN.register_operation("*", multiplication)
78 PLUGIN.register_operation("/", trueDivision)
80 exponentiation = operation.generate_function(operator.pow, "**", operation.Function.REP_INFIX, 2)
81 abs = operation.generate_function(operator.abs, "abs", operation.Function.REP_FUNCTION, 1)
83 fact_func = math.factorial
84 except AttributeError:
85 def fact_func(self, num):
88 return num * fact_func(self, num - 1)
89 factorial = operation.generate_function(fact_func, "!", operation.Function.REP_POSTFIX, 1)
90 negate = operation.generate_function(operator.neg, "+-", operation.Function.REP_PREFIX, 1)
91 square = operation.generate_function((lambda self, x: x ** 2), "sq", operation.Function.REP_FUNCTION, 1)
92 square_root = operation.generate_function((lambda self, x: x ** 0.5), "sqrt", operation.Function.REP_FUNCTION, 1)
94 # @todo Possibly make a graphic for this of x^y
95 PLUGIN.register_operation("**", exponentiation)
96 PLUGIN.register_operation("abs", abs)
97 PLUGIN.register_operation("!", factorial)
98 PLUGIN.register_operation("+-", negate)
99 PLUGIN.register_operation("sq", square)
100 PLUGIN.register_operation("sqrt", square_root)