1 from __future__ import division
7 from ejpi import operation
8 from ejpi import plugin_utils
12 _ICON = "computer.png"
17 "CENTER": {"action": "7", "type": "text", "text": "7", },
18 "SOUTH": {"action": "d", "type": "text", "text": "D", },
19 "showAllSlices": False,
22 "CENTER": {"action": "8", "type": "text", "text": "8", },
23 "SOUTH": {"action": "e", "type": "text", "text": "E", },
24 "showAllSlices": False,
27 "CENTER": {"action": "9", "type": "text", "text": "9", },
28 "SOUTH": {"action": "f", "type": "text", "text": "F", },
29 "showAllSlices": False,
32 "CENTER": {"action": "4", "type": "text", "text": "4", },
33 "NORTH_EAST": {"action": "0o", "type": "text", "text": "0o", },
34 "EAST": {"action": "0x", "type": "text", "text": "0x", },
35 "SOUTH_EAST": {"action": "0b", "type": "text", "text": "0b", },
36 "showAllSlices": True,
39 "CENTER": {"action": "5", "type": "text", "text": "5", },
40 "NORTH": {"action": "[&]", "type": "text", "text": "and", },
41 "WEST": {"action": "[|]", "type": "text", "text": "or", },
42 "SOUTH": {"action": "[~]", "type": "text", "text": "not", },
43 "EAST": {"action": "[^]", "type": "text", "text": "xor", },
44 "showAllSlices": True,
47 "CENTER": {"action": "6", "type": "text", "text": "6", },
48 "NORTH_WEST": {"action": "[oct]", "type": "text", "text": "-> oct", },
49 "WEST": {"action": "[dec]", "type": "text", "text": "-> dec", },
50 "SOUTH_WEST": {"action": "[hex]", "type": "text", "text": "-> hex", },
51 "showAllSlices": True,
54 "CENTER": {"action": "1", "type": "text", "text": "1", },
55 "NORTH": {"action": "a", "type": "text", "text": "A", },
56 "EAST": {"action": "0", "type": "text", "text": "0", },
57 "showAllSlices": False,
60 "CENTER": {"action": "2", "type": "text", "text": "2", },
61 "NORTH": {"action": "b", "type": "text", "text": "B", },
62 "EAST": {"action": "[//]", "type": "text", "text": "x // y", },
63 "WEST": {"action": "[%]", "type": "text", "text": "x % y", },
64 "showAllSlices": False,
67 "CENTER": {"action": "3", "type": "text", "text": "3", },
68 "NORTH": {"action": "c", "type": "text", "text": "C", },
69 "showAllSlices": False,
73 _ICON_PATH = [os.path.join(os.path.dirname(__file__), "images")]
74 PLUGIN = plugin_utils.PieKeyboardPluginFactory(_NAME, _ICON, _MAP, _ICON_PATH)
76 hex = operation.change_base(16, "hex")
77 oct = operation.change_base(8, "oct")
78 dec = operation.change_base(10, "dec")
79 ceil = operation.generate_function(math.ceil, "ceil", operation.Function.REP_FUNCTION, 1)
80 floor = operation.generate_function(math.floor, "floor", operation.Function.REP_FUNCTION, 1)
82 PLUGIN.register_operation("hex", hex)
83 PLUGIN.register_operation("oct", oct)
84 PLUGIN.register_operation("dec", dec)
85 PLUGIN.register_operation("ceil", ceil)
86 PLUGIN.register_operation("floor", floor)
88 floorDivision = operation.generate_function(operator.floordiv, "//", operation.Function.REP_INFIX, 2)
89 modulo = operation.generate_function(operator.mod, "%", operation.Function.REP_INFIX, 2)
91 PLUGIN.register_operation("//", floorDivision)
92 PLUGIN.register_operation("%", modulo)
94 bitAnd = operation.generate_function(operator.and_, "&", operation.Function.REP_INFIX, 2)
95 bitOr = operation.generate_function(operator.or_, "|", operation.Function.REP_INFIX, 2)
96 bitXor = operation.generate_function(operator.xor, "^", operation.Function.REP_INFIX, 2)
97 bitInvert = operation.generate_function(operator.invert, "~", operation.Function.REP_PREFIX, 1)
99 PLUGIN.register_operation("&", bitAnd)
100 PLUGIN.register_operation("|", bitOr)
101 PLUGIN.register_operation("^", bitXor)
102 PLUGIN.register_operation("~", bitInvert)