1 from __future__ import division
10 sys.path.append("../")
15 _ICON = "computer.png"
20 "CENTER": {"action": "[//]", "type": "text", "text": "//", },
21 "showAllSlices": False,
24 "CENTER": {"action": "[dec]", "type": "text", "text": "dec", },
25 "showAllSlices": True,
28 "CENTER": {"action": "[%]", "type": "text", "text": "%", },
29 "showAllSlices": False,
32 "CENTER": {"action": "0o", "type": "text", "text": "0o", },
33 "SOUTH": {"action": "[oct]", "type": "text", "text": "oct", },
34 "showAllSlices": True,
37 "CENTER": {"action": "0x", "type": "text", "text": "0x", },
38 "SOUTH": {"action": "[hex]", "type": "text", "text": "hex", },
39 "NORTH_WEST": {"action": "a", "type": "text", "text": "A", },
40 "WEST": {"action": "b", "type": "text", "text": "B", },
41 "SOUTH_WEST": {"action": "c", "type": "text", "text": "C", },
42 "NORTH_EAST": {"action": "d", "type": "text", "text": "D", },
43 "EAST": {"action": "e", "type": "text", "text": "E", },
44 "SOUTH_EAST": {"action": "f", "type": "text", "text": "F", },
45 "showAllSlices": True,
48 "CENTER": {"action": "0b", "type": "text", "text": "0b", },
49 "NORTH": {"action": "1", "type": "text", "text": "1", },
50 "SOUTH": {"action": "0", "type": "text", "text": "0", },
51 "showAllSlices": True,
54 "CENTER": {"action": "[&]", "type": "text", "text": "and", },
55 "showAllSlices": True,
58 "CENTER": {"action": "[|]", "type": "text", "text": "or", },
59 "NORTH": {"action": "[~]", "type": "text", "text": "not", },
60 "showAllSlices": True,
63 "CENTER": {"action": "[^]", "type": "text", "text": "xor", },
64 "showAllSlices": True,
68 _ICON_PATH = [os.path.join(os.path.dirname(__file__), "images")]
69 PLUGIN = plugin_utils.PieKeyboardPluginFactory(_NAME, _ICON, _MAP, _ICON_PATH)
71 hex = operation.change_base(16, "hex")
72 oct = operation.change_base(8, "oct")
73 dec = operation.change_base(10, "dec")
74 ceil = operation.generate_function(math.ceil, "ceil", operation.Function.REP_FUNCTION, 1)
75 floor = operation.generate_function(math.floor, "floor", operation.Function.REP_FUNCTION, 1)
77 PLUGIN.register_operation("hex", hex)
78 PLUGIN.register_operation("oct", oct)
79 PLUGIN.register_operation("dec", dec)
80 PLUGIN.register_operation("ceil", ceil)
81 PLUGIN.register_operation("floor", floor)
83 floorDivision = operation.generate_function(operator.floordiv, "//", operation.Function.REP_INFIX, 2)
84 modulo = operation.generate_function(operator.mod, "%", operation.Function.REP_INFIX, 2)
86 PLUGIN.register_operation("//", floorDivision)
87 PLUGIN.register_operation("%", modulo)
89 bitAnd = operation.generate_function(operator.and_, "&", operation.Function.REP_INFIX, 2)
90 bitOr = operation.generate_function(operator.or_, "|", operation.Function.REP_INFIX, 2)
91 bitXor = operation.generate_function(operator.xor, "^", operation.Function.REP_INFIX, 2)
92 bitInvert = operation.generate_function(operator.invert, "~", operation.Function.REP_PREFIX, 1)
94 PLUGIN.register_operation("&", bitAnd)
95 PLUGIN.register_operation("|", bitOr)
96 PLUGIN.register_operation("^", bitXor)
97 PLUGIN.register_operation("~", bitInvert)