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": "[&]", "type": "text", "text": "and", },
33 "showAllSlices": True,
36 "CENTER": {"action": "[|]", "type": "text", "text": "or", },
37 "NORTH": {"action": "[~]", "type": "text", "text": "not", },
38 "showAllSlices": True,
41 "CENTER": {"action": "[^]", "type": "text", "text": "xor", },
42 "showAllSlices": True,
45 "CENTER": {"action": "0x", "type": "text", "text": "0x", },
46 "SOUTH": {"action": "[hex]", "type": "text", "text": "hex", },
47 "NORTH_WEST": {"action": "a", "type": "text", "text": "A", },
48 "WEST": {"action": "b", "type": "text", "text": "B", },
49 "SOUTH_WEST": {"action": "c", "type": "text", "text": "C", },
50 "NORTH_EAST": {"action": "d", "type": "text", "text": "D", },
51 "EAST": {"action": "e", "type": "text", "text": "E", },
52 "SOUTH_EAST": {"action": "f", "type": "text", "text": "F", },
53 "showAllSlices": True,
56 "CENTER": {"action": "0o", "type": "text", "text": "0o", },
57 "SOUTH": {"action": "[oct]", "type": "text", "text": "oct", },
58 "showAllSlices": True,
61 "CENTER": {"action": "0b", "type": "text", "text": "0b", },
62 "showAllSlices": True,
66 _ICON_PATH = [os.path.join(os.path.dirname(__file__), "images")]
67 PLUGIN = plugin_utils.PieKeyboardPluginFactory(_NAME, _ICON, _MAP, _ICON_PATH)
69 hex = operation.change_base(16, "hex")
70 oct = operation.change_base(8, "oct")
71 dec = operation.change_base(10, "dec")
72 ceil = operation.generate_function(math.ceil, "ceil", operation.Function.REP_FUNCTION, 1)
73 floor = operation.generate_function(math.floor, "floor", operation.Function.REP_FUNCTION, 1)
75 PLUGIN.register_operation("hex", hex)
76 PLUGIN.register_operation("oct", oct)
77 PLUGIN.register_operation("dec", dec)
78 PLUGIN.register_operation("ceil", ceil)
79 PLUGIN.register_operation("floor", floor)
81 floorDivision = operation.generate_function(operator.floordiv, "//", operation.Function.REP_INFIX, 2)
82 modulo = operation.generate_function(operator.mod, "%", operation.Function.REP_INFIX, 2)
84 PLUGIN.register_operation("//", floorDivision)
85 PLUGIN.register_operation("%", modulo)
87 bitAnd = operation.generate_function(operator.and_, "&", operation.Function.REP_INFIX, 2)
88 bitOr = operation.generate_function(operator.or_, "|", operation.Function.REP_INFIX, 2)
89 bitXor = operation.generate_function(operator.xor, "^", operation.Function.REP_INFIX, 2)
90 bitInvert = operation.generate_function(operator.invert, "~", operation.Function.REP_PREFIX, 1)
92 PLUGIN.register_operation("&", bitAnd)
93 PLUGIN.register_operation("|", bitOr)
94 PLUGIN.register_operation("^", bitXor)
95 PLUGIN.register_operation("~", bitInvert)