1 from __future__ import division
10 sys.path.append("../")
15 _ICON = "computer.png"
20 "CENTER": {"action": "7", "type": "text", "text": "7", },
21 "SOUTH": {"action": "d", "type": "text", "text": "D", },
22 "showAllSlices": False,
25 "CENTER": {"action": "8", "type": "text", "text": "8", },
26 "SOUTH": {"action": "e", "type": "text", "text": "E", },
27 "showAllSlices": False,
30 "CENTER": {"action": "9", "type": "text", "text": "9", },
31 "SOUTH": {"action": "f", "type": "text", "text": "F", },
32 "showAllSlices": False,
35 "CENTER": {"action": "4", "type": "text", "text": "4", },
36 "NORTH_EAST": {"action": "0o", "type": "text", "text": "0o", },
37 "EAST": {"action": "0x", "type": "text", "text": "0x", },
38 "SOUTH_EAST": {"action": "0b", "type": "text", "text": "0b", },
39 "showAllSlices": True,
42 "CENTER": {"action": "5", "type": "text", "text": "5", },
43 "NORTH": {"action": "[&]", "type": "text", "text": "and", },
44 "WEST": {"action": "[|]", "type": "text", "text": "or", },
45 "SOUTH": {"action": "[~]", "type": "text", "text": "not", },
46 "EAST": {"action": "[^]", "type": "text", "text": "xor", },
47 "showAllSlices": True,
50 "CENTER": {"action": "6", "type": "text", "text": "6", },
51 "NORTH_WEST": {"action": "[oct]", "type": "text", "text": "-> oct", },
52 "WEST": {"action": "[dec]", "type": "text", "text": "-> dec", },
53 "SOUTH_WEST": {"action": "[hex]", "type": "text", "text": "-> hex", },
54 "showAllSlices": True,
57 "CENTER": {"action": "1", "type": "text", "text": "1", },
58 "NORTH": {"action": "a", "type": "text", "text": "A", },
59 "EAST": {"action": "0", "type": "text", "text": "0", },
60 "showAllSlices": False,
63 "CENTER": {"action": "2", "type": "text", "text": "2", },
64 "NORTH": {"action": "b", "type": "text", "text": "B", },
65 "EAST": {"action": "[//]", "type": "text", "text": "x // y", },
66 "WEST": {"action": "[%]", "type": "text", "text": "x % y", },
67 "showAllSlices": False,
70 "CENTER": {"action": "3", "type": "text", "text": "3", },
71 "NORTH": {"action": "c", "type": "text", "text": "C", },
72 "showAllSlices": False,
76 _ICON_PATH = [os.path.join(os.path.dirname(__file__), "images")]
77 PLUGIN = plugin_utils.PieKeyboardPluginFactory(_NAME, _ICON, _MAP, _ICON_PATH)
79 hex = operation.change_base(16, "hex")
80 oct = operation.change_base(8, "oct")
81 dec = operation.change_base(10, "dec")
82 ceil = operation.generate_function(math.ceil, "ceil", operation.Function.REP_FUNCTION, 1)
83 floor = operation.generate_function(math.floor, "floor", operation.Function.REP_FUNCTION, 1)
85 PLUGIN.register_operation("hex", hex)
86 PLUGIN.register_operation("oct", oct)
87 PLUGIN.register_operation("dec", dec)
88 PLUGIN.register_operation("ceil", ceil)
89 PLUGIN.register_operation("floor", floor)
91 floorDivision = operation.generate_function(operator.floordiv, "//", operation.Function.REP_INFIX, 2)
92 modulo = operation.generate_function(operator.mod, "%", operation.Function.REP_INFIX, 2)
94 PLUGIN.register_operation("//", floorDivision)
95 PLUGIN.register_operation("%", modulo)
97 bitAnd = operation.generate_function(operator.and_, "&", operation.Function.REP_INFIX, 2)
98 bitOr = operation.generate_function(operator.or_, "|", operation.Function.REP_INFIX, 2)
99 bitXor = operation.generate_function(operator.xor, "^", operation.Function.REP_INFIX, 2)
100 bitInvert = operation.generate_function(operator.invert, "~", operation.Function.REP_PREFIX, 1)
102 PLUGIN.register_operation("&", bitAnd)
103 PLUGIN.register_operation("|", bitOr)
104 PLUGIN.register_operation("^", bitXor)
105 PLUGIN.register_operation("~", bitInvert)