handle option combos on mac

This commit is contained in:
Felix Angell 2018-04-16 00:13:06 +01:00
parent 0ac9aff112
commit 0395a358b4

View File

@ -5,6 +5,7 @@ import (
"log"
"path"
"regexp"
"runtime"
"strings"
"time"
"unicode"
@ -139,6 +140,30 @@ var shiftAlternative = map[rune]rune{
'§': '±',
}
var altAlternative = map[rune]rune{
'1': '¡',
'2': '€',
'3': '#',
'4': '¢',
'5': '∞',
'6': '§',
'7': '¶',
'8': '•',
'9': 'ª',
'0': 'º',
'-': '',
'=': '≠',
'`': '`',
'/': '÷',
'.': '≥',
',': '≤',
'[': '“',
']': '',
';': '…',
'\'': 'æ',
'\\': '«',
}
func (b *Buffer) processTextInput(r rune) bool {
if ALT_DOWN && r == '\t' {
// nop, we dont want to
@ -147,6 +172,15 @@ func (b *Buffer) processTextInput(r rune) bool {
return true
}
// only do the alt alternatives on mac osx
// todo change this so it's not checking on every
// input
if runtime.GOOS == "darwin" && ALT_DOWN {
if val, ok := altAlternative[r]; ok {
r = val
}
}
if CAPS_LOCK {
if unicode.IsLetter(r) {
r = unicode.ToUpper(r)