self._constantPlugins = plugin_utils.ConstantPluginManager()
self._constantPlugins.add_path(*self._plugin_search_paths)
- for pluginName in ["Builtin", "Trigonometry", "Computer", "Alphabet"]:
+ for pluginName in ["Builtins", "Trigonometry", "Computer", "Alphabet"]:
try:
pluginId = self._constantPlugins.lookup_plugin(pluginName)
self._constantPlugins.enable_plugin(pluginId)
self._operatorPlugins = plugin_utils.OperatorPluginManager()
self._operatorPlugins.add_path(*self._plugin_search_paths)
- for pluginName in ["Builtin", "Trigonometry", "Computer", "Alphabet"]:
+ for pluginName in ["Builtins", "Trigonometry", "Computer", "Alphabet"]:
try:
pluginId = self._operatorPlugins.lookup_plugin(pluginName)
self._operatorPlugins.enable_plugin(pluginId)
self._handler.register_command_handler("clear", self._on_entry_clear)
# Main keyboard
- builtinKeyboardId = self._keyboardPlugins.lookup_plugin("Builtin")
+ builtinKeyboardId = self._keyboardPlugins.lookup_plugin("Builtins")
self._keyboardPlugins.enable_plugin(builtinKeyboardId)
- self._builtinPlugin = self._keyboardPlugins.keyboards["Builtin"].construct_keyboard()
+ self._builtinPlugin = self._keyboardPlugins.keyboards["Builtins"].construct_keyboard()
self._builtinKeyboard = self._builtinPlugin.setup(self._history, self._handler)
entryKeyboardId = self._keyboardPlugins.lookup_plugin("Entry")
def validate_variable_name(variableName):
match = _VARIABLE_VALIDATION_RE.match(variableName)
if match is None:
- raise RuntimeError("Invalid characters")
+ raise RuntimeError("Invalid characters in '%s'" % variableName)
def parse_number(userInput):
"NORTH_EAST",
]
- def __init__(self, rows, columns):
+ def __init__(self):
self._layout = QtGui.QGridLayout()
self.__cells = {}
def setup(self, calcStack, boardHandler):
self.__handler = boardHandler
- with open(self.factory.mapFile, "r") as mapfile:
- boardTree = qtpieboard.parse_keyboard_data("\n".join(mapfile.readlines()))
+ boardTree = self.factory.map
- rows, columns = boardTree["dimensions"]
keyboardName = boardTree["name"]
keyTree = boardTree["keys"]
- keyboard = qtpieboard.PieKeyboard(rows, columns)
+ keyboard = qtpieboard.PieKeyboard()
qtpieboard.load_keyboard(keyboardName, keyTree, keyboard, self.__handler, self.factory.iconPaths)
for commandName, operator in self.factory.commands.iteritems():
class PieKeyboardPluginFactory(object):
- def __init__(self, pluginName, keyboardMapFile):
+ def __init__(self, pluginName, keyboardMap, iconPaths):
self.name = pluginName
- self.mapFile = keyboardMapFile
+ self.map = keyboardMap
self.commands = {}
- self.iconPaths = [os.path.join(os.path.dirname(keyboardMapFile), "images")]
+ self.iconPaths = iconPaths
def register_operation(self, commandName, operator):
self.commands[commandName] = operator
+++ /dev/null
-{
- "name": "Alphabet",
- "dimensions": (3, 3),
- "keys": {
- (0, 0): {
- "CENTER": {"action": "e", "type": "text", "text": "E", },
- "SOUTH": {"action": "q", "type": "text", "text": "Q", },
- "EAST": {"action": "w", "type": "text", "text": "W", },
- "showAllSlices": True,
- },
- (0, 1): {
- "CENTER": {"action": "t", "type": "text", "text": "T", },
- "WEST": {"action": "r", "type": "text", "text": "R", },
- "EAST": {"action": "y", "type": "text", "text": "Y", },
- "SOUTH": {"action": "u", "type": "text", "text": "U", },
- "showAllSlices": True,
- },
- (0, 2): {
- "CENTER": {"action": "i", "type": "text", "text": "I", },
- "WEST": {"action": "o", "type": "text", "text": "O", },
- "SOUTH": {"action": "p", "type": "text", "text": "P", },
- "showAllSlices": True,
- },
- (1, 0): {
- "CENTER": {"action": "a", "type": "text", "text": "A", },
- "EAST": {"action": "s", "type": "text", "text": "S", },
- "showAllSlices": True,
- },
- (1, 1): {
- "CENTER": {"action": "h", "type": "text", "text": "H", },
- "WEST": {"action": "d", "type": "text", "text": "D", },
- "NORTH": {"action": "f", "type": "text", "text": "F", },
- "EAST": {"action": "g", "type": "text", "text": "G", },
- "SOUTH": {"action": "j", "type": "text", "text": "J", },
- "showAllSlices": True,
- },
- (1, 2): {
- "CENTER": {"action": "l", "type": "text", "text": "L", },
- "WEST": {"action": "k", "type": "text", "text": "K", },
- "showAllSlices": True,
- },
- (2, 0): {
- "CENTER": {"action": "c", "type": "text", "text": "C", },
- "NORTH": {"action": "z", "type": "text", "text": "Z", },
- "EAST": {"action": "x", "type": "text", "text": "X", },
- "showAllSlices": True,
- },
- (2, 1): {
- "CENTER": {"action": "b", "type": "text", "text": "B", },
- "NORTH": {"action": "v", "type": "text", "text": "V", },
- "showAllSlices": True,
- },
- (2, 2): {
- "CENTER": {"action": "n", "type": "text", "text": "N", },
- "NORTH_WEST": {"action": "m", "type": "text", "text": "M", },
- "showAllSlices": True,
- },
- },
-}
from __future__ import division
import os
-import operator
-
-import operation
import sys
sys.path.append("../")
import plugin_utils
-_MAP_FILE_PATH = os.path.join(os.path.dirname(__file__), "alphabet.map")
-PLUGIN = plugin_utils.PieKeyboardPluginFactory("Alphabet", _MAP_FILE_PATH)
+_NAME = "Alphabet"
+_MAP = {
+ "name": _NAME,
+ "keys": {
+ (0, 0): {
+ "CENTER": {"action": "e", "type": "text", "text": "E", },
+ "SOUTH": {"action": "q", "type": "text", "text": "Q", },
+ "EAST": {"action": "w", "type": "text", "text": "W", },
+ "showAllSlices": True,
+ },
+ (0, 1): {
+ "CENTER": {"action": "t", "type": "text", "text": "T", },
+ "WEST": {"action": "r", "type": "text", "text": "R", },
+ "EAST": {"action": "y", "type": "text", "text": "Y", },
+ "SOUTH": {"action": "u", "type": "text", "text": "U", },
+ "showAllSlices": True,
+ },
+ (0, 2): {
+ "CENTER": {"action": "i", "type": "text", "text": "I", },
+ "WEST": {"action": "o", "type": "text", "text": "O", },
+ "SOUTH": {"action": "p", "type": "text", "text": "P", },
+ "showAllSlices": True,
+ },
+ (1, 0): {
+ "CENTER": {"action": "a", "type": "text", "text": "A", },
+ "EAST": {"action": "s", "type": "text", "text": "S", },
+ "showAllSlices": True,
+ },
+ (1, 1): {
+ "CENTER": {"action": "h", "type": "text", "text": "H", },
+ "WEST": {"action": "d", "type": "text", "text": "D", },
+ "NORTH": {"action": "f", "type": "text", "text": "F", },
+ "EAST": {"action": "g", "type": "text", "text": "G", },
+ "SOUTH": {"action": "j", "type": "text", "text": "J", },
+ "showAllSlices": True,
+ },
+ (1, 2): {
+ "CENTER": {"action": "l", "type": "text", "text": "L", },
+ "WEST": {"action": "k", "type": "text", "text": "K", },
+ "showAllSlices": True,
+ },
+ (2, 0): {
+ "CENTER": {"action": "c", "type": "text", "text": "C", },
+ "NORTH": {"action": "z", "type": "text", "text": "Z", },
+ "EAST": {"action": "x", "type": "text", "text": "X", },
+ "showAllSlices": True,
+ },
+ (2, 1): {
+ "CENTER": {"action": "b", "type": "text", "text": "B", },
+ "NORTH": {"action": "v", "type": "text", "text": "V", },
+ "showAllSlices": True,
+ },
+ (2, 2): {
+ "CENTER": {"action": "n", "type": "text", "text": "N", },
+ "NORTH_WEST": {"action": "m", "type": "text", "text": "M", },
+ "showAllSlices": True,
+ },
+ },
+}
+PLUGIN = plugin_utils.PieKeyboardPluginFactory(_NAME, _MAP, [])
+++ /dev/null
-[Operator]
-name=Entry
-version=0.1
-description=
-
-[Constants]
-name=Entry
-version=0.1
-description=
-
-[Keyboard]
-name=Entry
-version=0.1
-description=
+++ /dev/null
-{
- "name": "Entry",
- "dimensions": (1, 1),
- "keys": {
- (0, 0): {
- "CENTER": {"action": "[push]", "type": "image", "path": "newline.png", },
- "NORTH": {"action": "[unpush]", "type": "text", "text": "Undo", },
- "NORTH_WEST": {"action": "[clear]", "type": "image", "path": "clear.png", },
- "WEST": {"action": "[backspace]", "type": "image", "path": "backspace.png", },
- "showAllSlices": False,
- },
- },
-}
+++ /dev/null
-from __future__ import division
-
-import os
-
-import sys
-sys.path.append("../")
-import plugin_utils
-
-
-_NAME = "Entry"
-_MAP = {
- "name": _NAME,
- "keys": {
- (0, 0): {
- "CENTER": {"action": "[push]", "type": "image", "path": "newline.png", },
- "NORTH": {"action": "[unpush]", "type": "text", "text": "Undo", },
- "NORTH_WEST": {"action": "[clear]", "type": "image", "path": "clear.png", },
- "WEST": {"action": "[backspace]", "type": "image", "path": "backspace.png", },
- "showAllSlices": False,
- },
- },
-}
-_ICON_PATH = [os.path.join(os.path.dirname(__file__), "images")]
-PLUGIN = plugin_utils.PieKeyboardPluginFactory(_NAME, _MAP, _ICON_PATH)
[Operator]
-name=Builtin
+name=Builtins
version=0.1
description=
[Constants]
-name=Builtin
+name=Builtins
version=0.1
description=
[Keyboard]
-name=Builtin
+name=Builtins
version=0.1
description=
+++ /dev/null
-{
- "name": "Builtins",
- "dimensions": (3, 3),
- "keys": {
- (0, 0): {
- "CENTER": {"action": "7", "type": "text", "text": "7", },
- "showAllSlices": True,
- },
- (0, 1): {
- "CENTER": {"action": "8", "type": "text", "text": "8", },
- "SOUTH": {"action": "[**]", "type": "text", "text": "**", },
- "EAST": {"action": "[sq]", "type": "text", "text": "sq", },
- "WEST": {"action": "[sqrt]", "type": "text", "text": "sqrt", },
- "showAllSlices": False,
- },
- (0, 2): {
- "CENTER": {"action": "9", "type": "text", "text": "9", },
- "showAllSlices": True,
- },
- (1, 0): {
- "CENTER": {"action": "4", "type": "text", "text": "4", },
- "showAllSlices": True,
- },
- (1, 1): {
- "CENTER": {"action": "5", "type": "text", "text": "5", },
- "EAST": {"action": "[+]", "type": "text", "text": "+", },
- "WEST": {"action": "[-]", "type": "text", "text": "-", },
- "NORTH": {"action": "[*]", "type": "text", "text": "*", },
- "SOUTH": {"action": "[/]", "type": "text", "text": "/", },
- "showAllSlices": True,
- },
- (1, 2): {
- "CENTER": {"action": "6", "type": "text", "text": "6", },
- "showAllSlices": True,
- },
- (2, 0): {
- "CENTER": {"action": "1", "type": "text", "text": "1", },
- "EAST": {"action": "0", "type": "text", "text": "0", },
- "showAllSlices": True,
- },
- (2, 1): {
- "CENTER": {"action": "2", "type": "text", "text": "2", },
- "EAST": {"action": "[abs]", "type": "text", "text": "abs", },
- "NORTH": {"action": ".", "type": "text", "text": ".", },
- "WEST": {"action": "[+-]", "type": "text", "text": "+/-", },
- "showAllSlices": True,
- },
- (2, 2): {
- "CENTER": {"action": "3", "type": "text", "text": "3", },
- "NORTH": {"action": "[!]", "type": "text", "text": "!", },
- "WEST": {"action": "j", "type": "text", "text": "j", },
- "showAllSlices": True,
- },
- },
-}
sys.path.append("../")
import plugin_utils
-
-_MAP_FILE_PATH = os.path.join(os.path.dirname(__file__), "builtins.map")
-PLUGIN = plugin_utils.PieKeyboardPluginFactory("Builtin", _MAP_FILE_PATH)
+_NAME = "Builtins"
+_MAP = {
+ "name": _NAME,
+ "keys": {
+ (0, 0): {
+ "CENTER": {"action": "7", "type": "text", "text": "7", },
+ "showAllSlices": True,
+ },
+ (0, 1): {
+ "CENTER": {"action": "8", "type": "text", "text": "8", },
+ "SOUTH": {"action": "[**]", "type": "text", "text": "**", },
+ "EAST": {"action": "[sq]", "type": "text", "text": "sq", },
+ "WEST": {"action": "[sqrt]", "type": "text", "text": "sqrt", },
+ "showAllSlices": False,
+ },
+ (0, 2): {
+ "CENTER": {"action": "9", "type": "text", "text": "9", },
+ "showAllSlices": True,
+ },
+ (1, 0): {
+ "CENTER": {"action": "4", "type": "text", "text": "4", },
+ "showAllSlices": True,
+ },
+ (1, 1): {
+ "CENTER": {"action": "5", "type": "text", "text": "5", },
+ "EAST": {"action": "[+]", "type": "text", "text": "+", },
+ "WEST": {"action": "[-]", "type": "text", "text": "-", },
+ "NORTH": {"action": "[*]", "type": "text", "text": "*", },
+ "SOUTH": {"action": "[/]", "type": "text", "text": "/", },
+ "showAllSlices": True,
+ },
+ (1, 2): {
+ "CENTER": {"action": "6", "type": "text", "text": "6", },
+ "showAllSlices": True,
+ },
+ (2, 0): {
+ "CENTER": {"action": "1", "type": "text", "text": "1", },
+ "EAST": {"action": "0", "type": "text", "text": "0", },
+ "showAllSlices": True,
+ },
+ (2, 1): {
+ "CENTER": {"action": "2", "type": "text", "text": "2", },
+ "EAST": {"action": "[abs]", "type": "text", "text": "abs", },
+ "NORTH": {"action": ".", "type": "text", "text": ".", },
+ "WEST": {"action": "[+-]", "type": "text", "text": "+/-", },
+ "showAllSlices": True,
+ },
+ (2, 2): {
+ "CENTER": {"action": "3", "type": "text", "text": "3", },
+ "NORTH": {"action": "[!]", "type": "text", "text": "!", },
+ "WEST": {"action": "j", "type": "text", "text": "j", },
+ "showAllSlices": True,
+ },
+ },
+}
+PLUGIN = plugin_utils.PieKeyboardPluginFactory(_NAME, _MAP, [])
addition = operation.generate_function(operator.add, "+", operation.Function.REP_INFIX, 2)
subtraction = operation.generate_function(operator.sub, "-", operation.Function.REP_INFIX, 2)
import plugin_utils
-_MAP_FILE_PATH = os.path.join(os.path.dirname(__file__), "computer.map")
-PLUGIN = plugin_utils.PieKeyboardPluginFactory("Computer", _MAP_FILE_PATH)
+_NAME = "Computer"
+_MAP = {
+ "name": _NAME,
+ "keys": {
+ (0, 0): {
+ "CENTER": {"action": "[//]", "type": "text", "text": "//", },
+ "showAllSlices": False,
+ },
+ (0, 1): {
+ "CENTER": {"action": "[dec]", "type": "text", "text": "dec", },
+ "showAllSlices": True,
+ },
+ (0, 2): {
+ "CENTER": {"action": "[%]", "type": "text", "text": "%", },
+ "showAllSlices": False,
+ },
+ (1, 0): {
+ "CENTER": {"action": "[&]", "type": "text", "text": "and", },
+ "showAllSlices": True,
+ },
+ (1, 1): {
+ "CENTER": {"action": "[|]", "type": "text", "text": "or", },
+ "NORTH": {"action": "[~]", "type": "text", "text": "not", },
+ "showAllSlices": True,
+ },
+ (1, 2): {
+ "CENTER": {"action": "[^]", "type": "text", "text": "xor", },
+ "showAllSlices": True,
+ },
+ (2, 0): {
+ "CENTER": {"action": "0x", "type": "text", "text": "0x", },
+ "SOUTH": {"action": "[hex]", "type": "text", "text": "hex", },
+ "NORTH_WEST": {"action": "a", "type": "text", "text": "A", },
+ "WEST": {"action": "b", "type": "text", "text": "B", },
+ "SOUTH_WEST": {"action": "c", "type": "text", "text": "C", },
+ "NORTH_EAST": {"action": "d", "type": "text", "text": "D", },
+ "EAST": {"action": "e", "type": "text", "text": "E", },
+ "SOUTH_EAST": {"action": "f", "type": "text", "text": "F", },
+ "showAllSlices": True,
+ },
+ (2, 1): {
+ "CENTER": {"action": "0o", "type": "text", "text": "0o", },
+ "SOUTH": {"action": "[oct]", "type": "text", "text": "oct", },
+ "showAllSlices": True,
+ },
+ (2, 2): {
+ "CENTER": {"action": "0b", "type": "text", "text": "0b", },
+ "showAllSlices": True,
+ },
+ },
+}
+PLUGIN = plugin_utils.PieKeyboardPluginFactory(_NAME, _MAP, [])
hex = operation.change_base(16, "hex")
oct = operation.change_base(8, "oct")
--- /dev/null
+[Operator]
+name=Entry
+version=0.1
+description=
+
+[Constants]
+name=Entry
+version=0.1
+description=
+
+[Keyboard]
+name=Entry
+version=0.1
+description=
--- /dev/null
+from __future__ import division
+
+import os
+
+import sys
+sys.path.append("../")
+import plugin_utils
+
+
+_NAME = "Entry"
+_MAP = {
+ "name": _NAME,
+ "keys": {
+ (0, 0): {
+ "CENTER": {"action": "[push]", "type": "image", "path": "newline.png", },
+ "NORTH": {"action": "[unpush]", "type": "text", "text": "Undo", },
+ "NORTH_WEST": {"action": "[clear]", "type": "image", "path": "clear.png", },
+ "WEST": {"action": "[backspace]", "type": "image", "path": "backspace.png", },
+ "showAllSlices": False,
+ },
+ },
+}
+_ICON_PATH = [os.path.join(os.path.dirname(__file__), "images")]
+PLUGIN = plugin_utils.PieKeyboardPluginFactory(_NAME, _MAP, _ICON_PATH)
+++ /dev/null
-{
- "name": "Trigonometry",
- "dimensions": (3, 3),
- "keys": {
- (0, 0): {
- "CENTER": {"action": "[sinh]", "type": "text", "text": "sinh", },
- "SOUTH": {"action": "[asinh]", "type": "text", "text": "asinh", },
- "showAllSlices": False,
- },
- (0, 1): {
- "CENTER": {"action": "[cosh]", "type": "text", "text": "cosh", },
- "SOUTH": {"action": "[acosh]", "type": "text", "text": "acosh", },
- "showAllSlices": False,
- },
- (0, 2): {
- "CENTER": {"action": "[tanh]", "type": "text", "text": "tanh", },
- "SOUTH": {"action": "[atanh]", "type": "text", "text": "atanh", },
- "showAllSlices": False,
- },
- (1, 0): {
- "CENTER": {"action": "[exp]", "type": "text", "text": "exp", },
- "NORTH": {"action": "[log]", "type": "text", "text": "log", },
- "showAllSlices": True,
- },
- (1, 1): {
- "CENTER": {"action": "pi", "type": "text", "text": "pi", },
- "NORTH": {"action": "e", "type": "text", "text": "e", },
- "showAllSlices": True,
- },
- (1, 2): {
- "CENTER": {"action": "[rad]", "type": "text", "text": "rad", },
- "NORTH": {"action": "[deg]", "type": "text", "text": "deg", },
- "showAllSlices": True,
- },
- (2, 0): {
- "CENTER": {"action": "[sin]", "type": "text", "text": "sin", },
- "SOUTH": {"action": "[asin]", "type": "text", "text": "asin", },
- "showAllSlices": False,
- },
- (2, 1): {
- "CENTER": {"action": "[cos]", "type": "text", "text": "cos", },
- "SOUTH": {"action": "[acos]", "type": "text", "text": "acos", },
- "showAllSlices": False,
- },
- (2, 2): {
- "CENTER": {"action": "[tan]", "type": "text", "text": "tan", },
- "SOUTH": {"action": "[atan]", "type": "text", "text": "atan", },
- "showAllSlices": False,
- },
- },
-}
from __future__ import division
-import os
-import operator
import math
import cmath
import plugin_utils
-_MAP_FILE_PATH = os.path.join(os.path.dirname(__file__), "trig.map")
-PLUGIN = plugin_utils.PieKeyboardPluginFactory("Trigonometry", _MAP_FILE_PATH)
+_NAME = "Trigonometry"
+_MAP = {
+ "name": _NAME,
+ "keys": {
+ (0, 0): {
+ "CENTER": {"action": "[sinh]", "type": "text", "text": "sinh", },
+ "SOUTH": {"action": "[asinh]", "type": "text", "text": "asinh", },
+ "showAllSlices": False,
+ },
+ (0, 1): {
+ "CENTER": {"action": "[cosh]", "type": "text", "text": "cosh", },
+ "SOUTH": {"action": "[acosh]", "type": "text", "text": "acosh", },
+ "showAllSlices": False,
+ },
+ (0, 2): {
+ "CENTER": {"action": "[tanh]", "type": "text", "text": "tanh", },
+ "SOUTH": {"action": "[atanh]", "type": "text", "text": "atanh", },
+ "showAllSlices": False,
+ },
+ (1, 0): {
+ "CENTER": {"action": "[exp]", "type": "text", "text": "exp", },
+ "NORTH": {"action": "[log]", "type": "text", "text": "log", },
+ "showAllSlices": True,
+ },
+ (1, 1): {
+ "CENTER": {"action": "pi", "type": "text", "text": "pi", },
+ "NORTH": {"action": "e", "type": "text", "text": "e", },
+ "showAllSlices": True,
+ },
+ (1, 2): {
+ "CENTER": {"action": "[rad]", "type": "text", "text": "rad", },
+ "NORTH": {"action": "[deg]", "type": "text", "text": "deg", },
+ "showAllSlices": True,
+ },
+ (2, 0): {
+ "CENTER": {"action": "[sin]", "type": "text", "text": "sin", },
+ "SOUTH": {"action": "[asin]", "type": "text", "text": "asin", },
+ "showAllSlices": False,
+ },
+ (2, 1): {
+ "CENTER": {"action": "[cos]", "type": "text", "text": "cos", },
+ "SOUTH": {"action": "[acos]", "type": "text", "text": "acos", },
+ "showAllSlices": False,
+ },
+ (2, 2): {
+ "CENTER": {"action": "[tan]", "type": "text", "text": "tan", },
+ "SOUTH": {"action": "[atan]", "type": "text", "text": "atan", },
+ "showAllSlices": False,
+ },
+ },
+}
+PLUGIN = plugin_utils.PieKeyboardPluginFactory(_NAME, _MAP, [])
pi = operation.Constant("pi", operation.Value(math.pi, operation.render_float_eng))
e = operation.Constant("e", operation.Value(math.e, operation.render_float_eng))