##############################################
# Categorize calculator and keyboard keys.   #
# Author: Scott Pakin <scott+clsl@pakin.org> #
##############################################

# -------------------------- calculator keys ---------------------------

[[rewrite]]
render_regex = '\\CASIO(?:casio)?(Dot|Integral|Cube|Divide|Equal|Factorial|Inverse|Menu|Minus|Percent|Plus|Setup|Shift|Times)\b'
lowercase_item = true
item = ["calculator keys", '\1']

[[rewrite]]
render_regex = '\\CASIOcasio(Comma|Dot|Integral|Pi|Sum|X|Y)'
lowercase_item = true
item = ["calculator keys", '\1']

[[rewrite]]
render_regex = '\\CASIO(Cube|minus|Inverse|i|angle|Comma)Paren'
lowercase_item = true
item = ["calculator keys", '\1']

# Split certain calculator-key names into exactly two words.
[[rewrite]]
render_contains = [
    "BackArrow",
    "CubeRoot",
    "DownArrow",
    "LeftArrow",
    "RightArrow",
    "SquareRoot",
    "UpArrow"
]
render_regex = '\\CASIO([A-Z][a-z]+)([A-Z][a-z]+)'
lowercase_item = true
item = ["calculator keys", '\1 \2']

[[rewrite]]
render_contains = '\CASIOAbs'
item = ["calculator keys", "absolute value"]

[[rewrite]]
render_contains = '\CASIOAlpha'
item = ["calculator keys", "alphabetical mode"]

[[rewrite]]
render_contains = '\CASIOAns'
item = ["calculator keys", "answer"]

[[rewrite]]
render_contains = '\CASIOCalc'
item = ["calculator keys", "calculate"]

[[rewrite]]
render_contains = '\CASIOcasioAbs'
item = ["calculator keys", "absolute value"]

[[rewrite]]
render_contains = '\CASIOcasioAC'
item = ["calculator keys", "power"]

[[rewrite]]
render_contains = '\CASIOcasioCos'
item = ["calculator keys", "cosine"]

[[rewrite]]
render_contains = '\CASIOcasioDblParen'
item = ["calculator keys", "parenthesize"]

[[rewrite]]
render_contains = [
    '\CASIOcasioLn',
    '\CASIOcasioLog',
    '\CASIOlogParen',
    '\CASIOnLog'
]
item = ["calculator keys", "logarithm"]

[[rewrite]]
render_contains = ['\CASIOcasioLParen', '\CASIOcasioRParen']
item = ["calculator keys", "parenthesis"]

[[rewrite]]
render_contains = '\CASIOcasioObar'
item = ["calculator keys", "overline"]

[[rewrite]]
render_contains = '\CASIOcasioOdot'
item = ["calculator keys", "dot over"]

[[rewrite]]
render_contains = '\CASIOcasioProd'
item = ["calculator keys", "product"]

# I've read some mention that Sen appears instead of Sin on
# Spanish-language Casio calculators.
[[rewrite]]
render_contains = ['\CASIOcasioSin', '\CASIOSen']
item = ["calculator keys", "sine"]

[[rewrite]]
render_contains = '\CASIOcasioTan'
item = ["calculator keys", "tangent"]

[[rewrite]]
render_contains = '\CASIOCJKMenu'
item = ["calculator keys", "menu"]

[[rewrite]]
render_contains = '\CASIOCJKOn'
item = ["calculator keys", "power"]

[[rewrite]]
render_contains = '\CASIODegRadGrad'
item = ["calculator keys", "degrees/radians/gradians"]
render = 'degrees\slash radians\slash gradians (\CASIODegRadGrad)'

[[rewrite]]
render_contains = '\CASIODel'
item = ["calculator keys", "delete"]

[[rewrite]]
render_contains = '\CASIOdivR'
item = ["calculator keys", "divide"]

[[rewrite]]
render_contains = '\CASIOdydx'
item = ["calculator keys", "derivative"]

[[rewrite]]
render_contains = [
    '\CASIOeExp',
    '\CASIOnExp',
    '\CASIOnTen',
    '\CASIOxTenx'
]
item = ["calculator keys", "exponential"]

[[rewrite]]
render_contains = '\CASIOEng'
item = ["calculator keys", "engineering notation"]

[[rewrite]]
render_contains = '\CASIOExe'
item = ["calculator keys", "execute"]

# I don't actually know what "LineFrac" means.
[[rewrite]]
render_contains = [
    '\CASIOFrac',
    '\CASIOFracMult',
    '\CASIOLineFrac',
    '\CASIOMixedFrac',
    '\CASIOswitchMixedFrac'
]
item = ["calculator keys", "fraction"]

[[rewrite]]
render_contains = '\CASIOInverseCos'
item = ["calculator keys", "arccosine"]

[[rewrite]]
render_contains = '\CASIOInverseSin'
item = ["calculator keys", "arcsine"]

[[rewrite]]
render_contains = '\CASIOInverseTan'
item = ["calculator keys", "arctangent"]

[[rewrite]]
render_regex = '\\CASIOM(minus|plus)'
item = ["calculator keys", 'memory \1']

[[rewrite]]
render_contains = '\CASIOnRoot'
item = ["calculator keys", "nth root"]

[[rewrite]]
render_contains = '\CASIOOptn'
item = ["calculator keys", "option"]

# This rule must precede the CASIOSim rule.
[[rewrite]]
render_contains = '\CASIOSimp'
item = ["calculator keys", "simplify"]

[[rewrite]]
render_contains = '\CASIOSim'
item = ["calculator keys", "similar"]

[[rewrite]]
render_contains = '\CASIOSto'
item = ["calculator keys", "store"]

# --------------------------- keyboard keys ----------------------------

[[rewrite]]
matches = ["applecmd", "wasycmd"]
item = ["keyboard symbols", "command"]

[[rewrite]]
render_contains = '(\KEYSAlt)'
item = ["keyboard symbols", "alternate"]

[[rewrite]]
matches = "AltGr"
item = ["keyboard symbols", "alternate graphic"]

[[rewrite]]
matches = "BSpace"
item = ["keyboard symbols", "backspace"]

[[rewrite]]
matches = "Ctrl"
item = ["keyboard symbols", "control"]

[[rewrite]]
matches = "Del"
item = ["keyboard symbols", "delete"]

[[rewrite]]
render_contains = '(\KEYSEnd)'
item = ["keyboard symbols", "end"]

[[rewrite]]
matches = "Esc"
item = ["keyboard symbols", "escape"]

[[rewrite]]
matches = "Ins"
item = ["keyboard symbols", "insert"]

[[rewrite]]
matches = "NumLock"
item = ["keyboard symbols", "numeric lock"]

[[rewrite]]
regex = '^Pg(Down|Up)$'
lowercase_word = true
item = ["keyboard symbols", 'page \1']

[[rewrite]]
matches = "PrtSc"
item = ["keyboard symbols", "print screen"]

[[rewrite]]
matches = "keystroke"
item = ["keyboard symbols", "customizable"]

# This rule should appear last in this section.
[[rewrite]]
matches = [
    'Break',
    'Enter',
    'Home',
    'Return',
    'Scroll',
    'Shift',
    'Spacebar',
    'Tab'
]
lowercase_word = true
item = ["keyboard symbols", '\1']
