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