Skip to content

Commit

Permalink
Use robotgo fork with linux key fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandro Heinzelmann committed Aug 22, 2021
1 parent bd6fcfa commit 8952b1a
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 147 deletions.
13 changes: 5 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BASE_VERSION=0.3.2
BASE_VERSION=0.4.0
REPO_OWNER=sandro-h
BUILD_CENTOS_IMAGE_VERSION=0.0.1
BUILD_CENTOS_IMAGE_TAG=ghcr.io/${REPO_OWNER}/snippet-centos-build:${BUILD_CENTOS_IMAGE_VERSION}
Expand All @@ -15,10 +15,6 @@ ifeq ($(PUSH_IMAGE), true)
docker push ${BUILD_CENTOS_IMAGE_TAG}
endif

.PHONY: patch-robotgo
patch-robotgo:
./patch_robotgo.sh

.PHONY: build-centos-image
build-centos-image:
docker build \
Expand All @@ -36,14 +32,14 @@ build-centos: ensure-centos-image
-e DEV_UID=$$(id -u) \
-w /src \
${BUILD_CENTOS_IMAGE_TAG} \
"export PATH=/usr/local/go/bin:\$$PATH && ./patch_robotgo.sh && go build -o snippet-centos ${EXTRA_BUILD_ARGS} && chown \$$DEV_UID snippet-centos"
"export PATH=/usr/local/go/bin:\$$PATH && go build -o snippet-centos ${EXTRA_BUILD_ARGS} && chown \$$DEV_UID snippet-centos"

.PHONY: build-windows
build-windows: patch-robotgo
build-windows:
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ go build -ldflags "-H=windowsgui ${EXTRA_WIN_LDFLAGS}" ${EXTRA_WIN_BUILD_ARGS}

.PHONY: build-linux
build-linux: patch-robotgo
build-linux:
go build ${EXTRA_BUILD_ARGS}

.PHONY: test
Expand All @@ -56,6 +52,7 @@ lint:

.PHONY: install-sys-packages
install-sys-packages:
sudo apt update && \
sudo apt install gcc libc6-dev \
libx11-dev xorg-dev libxtst-dev libpng++-dev \
xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev \
Expand Down
58 changes: 8 additions & 50 deletions config_linux_de_ch.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,11 @@
---
# Note, also have to patch layout to assign some weird characters to different keys,
# because robotgo can't handle them.
# sudo vim /usr/share/X11/xkb/symbols/ch
# < key <BKSL> { [ dollar, sterling, braceright ] };
# > key <BKSL> { [ dollar, dollar, braceright ] };
# < key <AE11> { [ apostrophe, question, dead_acute ] };
# > key <AE11> { [ apostrophe, question, apostrophe ] };
# < key <AE10> { [ 0, equal ] };
# > key <AE10> { [ 0, equal, dead_circumflex ] };
# setxkbmap

special_chars:
- character: /
key: 7
command: shift
- character: "#"
key: 3
command: gralt
- character: =
key: 0
command: shift
- character: '"'
key: 2
command: shift
- character: "'"
key: "?"
command: gralt
- character: '{'
key: '{'
command: gralt
- character: '}'
key: $
command: gralt
- character: '['
key: '['
command: gralt
- character: ']'
key: ']'
command: gralt
- character: '|'
key: 7
command: gralt
- character: '^'
key: '0'
command: gralt
- character: "~"
key_sym: 0xfe53
space_after: true
- character: "^"
key_sym: 0xfe52
space_after: true
- character: "`"
key_sym: 0xfe50
space_after: true
- character: ';'
key: ','
command: shift
- character: '\'
key: '<'
command: gralt
15 changes: 6 additions & 9 deletions config_sample.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
---

# Make snippet type the following characters with a particular key combination ON LINUX ONLY.
# Override the way these characters are typed ON LINUX ONLY.
# Useful for non-english keyboard layouts where the typing automation somtimes
# produces incorrect results on Linux.
# Possible key and command values: see https://github.com/go-vgo/robotgo/blob/master/docs/keys.md
# Additionally, snippet supports "gralt" command.
special_chars:
- character: /
key: 7
command: shift
- character: "#"
key: 3
command: gralt
- character: "~"
# Can be looked up with xmodmap -pk
key_sym: 0xfe53
# Needed to type "dead" keys by themselves, because they also modify a previous letter (e.g. accents)
space_after: true

# Duration until an unlocked secret snippet is locked again.
# Duration is in Golang format: https://golang.org/pkg/time/#ParseDuration
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ require (
github.com/fsnotify/fsnotify v1.4.9
github.com/go-vgo/robotgo v0.93.1
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/robotn/gohook v0.30.5
github.com/robotn/gohook v0.30.6
github.com/sahilm/fuzzy v0.1.0
github.com/sosedoff/ansible-vault-go v0.0.0-20201201002713-782dc5c40224
github.com/stretchr/testify v1.5.1
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
golang.org/x/text v0.3.5 // indirect
gopkg.in/yaml.v2 v2.2.8
)

replace github.com/go-vgo/robotgo => github.com/sandro-h/robotgo v0.99.0-linuxfix3
47 changes: 26 additions & 21 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ fyne.io/fyne/v2 v2.0.3/go.mod h1:nNpgL7sZkDVLraGtQII2ArNRnnl6kHup/KfQRxIhbvs=
github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298/go.mod h1:D+QujdIlUNfa0igpNMk6UIvlb6C252URs4yupRUV4lQ=
github.com/BurntSushi/graphics-go v0.0.0-20160129215708-b43f31a4a966/go.mod h1:Mid70uvE93zn9wgF92A/r5ixgnvX8Lh68fxp9KQBaI0=
github.com/Kodeworks/golang-image-ico v0.0.0-20141118225523-73f0f4cfade9/go.mod h1:7uhhqiBaR4CpN0k9rMjOtjpcfGd6DG2m04zQxKnWQ0I=
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk=
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 h1:5sXbqlSomvdjlRbWyNqkPsJ3Fg+tQZCbgeX1VGljbQY=
github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand All @@ -19,10 +19,8 @@ github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 h1:SCYMcCJ89LjRGwEa0tRluN
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20210410170116-ea3d685f79fb h1:T6gaWBvRzJjuOrdCtg8fXXjKai2xSDqWTcKFUPuw8Tw=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20210410170116-ea3d685f79fb/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI=
github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM=
github.com/go-vgo/robotgo v0.93.1 h1:bSuya586zK6/NpA5+mMPenzw4KlvbWGhLBISzGlEZoM=
github.com/go-vgo/robotgo v0.93.1/go.mod h1:HUCwEV5VvBtnX3Vh0EmlAkETEdcJKeHVmAPMmHaqT+A=
github.com/go-ole/go-ole v1.2.5 h1:t4MGB5xEDZvXI+0rMjjsfBsD7yAgp/s9ZDkL1JndXwY=
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/goki/freetype v0.0.0-20181231101311-fa8a33aabaff h1:W71vTCKoxtdXgnm1ECDFkfQnpdqAO00zzGXLA5yaEX8=
Expand All @@ -35,8 +33,8 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/lucor/goinfo v0.0.0-20200401173949-526b5363a13a/go.mod h1:ORP3/rB5IsulLEBwQZCJyyV6niqmI7P4EWSmkug+1Ng=
github.com/lxn/win v0.0.0-20201111105847-2a20daff6a55 h1:4BxFx5XCtXc+nFtXDGDW+Uu5sPtsAbvPh6RObj3fG9o=
github.com/lxn/win v0.0.0-20201111105847-2a20daff6a55/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk=
github.com/lxn/win v0.0.0-20210218163916-a377121e959e h1:H+t6A/QJMbhCSEH5rAuRxh+CtW96g0Or0Fxa9IKr4uc=
github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
Expand All @@ -50,18 +48,18 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/robotn/gohook v0.30.5 h1:yECDQXcKUcMxYLzPWBEKaHNiNss6lLq15RrgouDCKw4=
github.com/robotn/gohook v0.30.5/go.mod h1:FXryR68cDIho8rjE7MKxt4n4aK2FBqp+d/0HK4oiGP8=
github.com/robotn/gohook v0.30.6 h1:hH2KzyRsThtOqQ4M2ZPiOaib4vx70pz1DqgrBm26vPk=
github.com/robotn/gohook v0.30.6/go.mod h1:FXryR68cDIho8rjE7MKxt4n4aK2FBqp+d/0HK4oiGP8=
github.com/robotn/xgb v0.0.0-20190912153532-2cb92d044934 h1:2lhSR8N3T6I30q096DT7/5AKEIcf1vvnnWAmS0wfnNY=
github.com/robotn/xgb v0.0.0-20190912153532-2cb92d044934/go.mod h1:SxQhJskUJ4rleVU44YvnrdvxQr0tKy5SRSigBrCgyyQ=
github.com/robotn/xgbutil v0.0.0-20190912154524-c861d6f87770 h1:2uX8QRLkkxn2EpAQ6I3KhA79BkdRZfvugJUzJadiJwk=
github.com/robotn/xgbutil v0.0.0-20190912154524-c861d6f87770/go.mod h1:svkDXUDQjUiWzLrA0OZgHc4lbOts3C+uRfP6/yjwYnU=
github.com/sahilm/fuzzy v0.1.0 h1:FzWGaw2Opqyu+794ZQ9SYifWv2EIXpwP4q8dY1kDAwI=
github.com/sahilm/fuzzy v0.1.0/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
github.com/shirou/gopsutil v2.19.11+incompatible h1:lJHR0foqAjI4exXqWsU3DbH7bX1xvdhGdnXTIARA9W4=
github.com/shirou/gopsutil v2.19.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 h1:udFKJ0aHUL60LboW/A+DfgoHVedieIzIXE8uylPue0U=
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc=
github.com/sandro-h/robotgo v0.99.0-linuxfix3 h1:byt4mpdZEp4/2f3Kpiw4IZv5pGVSru9CASzl3tzrHoc=
github.com/sandro-h/robotgo v0.99.0-linuxfix3/go.mod h1:0+i2QWRmZtbIF02RwmiGfFj33Judprukd8ls5J6Eajg=
github.com/shirou/gopsutil v3.21.5+incompatible h1:OloQyEerMi7JUrXiNzy8wQ5XN+baemxSl12QgIzt0jc=
github.com/shirou/gopsutil v3.21.5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/sosedoff/ansible-vault-go v0.0.0-20201201002713-782dc5c40224 h1:J64keahjF4bF8wMIqTtH9ARkj9c2mRryYtd3XcObfC8=
github.com/sosedoff/ansible-vault-go v0.0.0-20201201002713-782dc5c40224/go.mod h1:u74h49t5XRrBQpubnCr8PXRABdzTEuM+nHUn1mGYgtI=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
Expand All @@ -75,8 +73,12 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/vcaesar/gops v0.10.2 h1:agDWYawurQVqyV0bcGf/6xgM5VFq0/pmlLTgAhC2yD0=
github.com/vcaesar/gops v0.10.2/go.mod h1:C5OfFWnxVszWFHpqE63qRc9mqmEPcFtQKKOpw0h22G0=
github.com/tklauser/go-sysconf v0.3.6 h1:oc1sJWvKkmvIxhDHeKWvZS4f6AW+YcoguSfRF2/Hmo4=
github.com/tklauser/go-sysconf v0.3.6/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI=
github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefldA=
github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM=
github.com/vcaesar/gops v0.20.0 h1:SqP/rzDJh7Dy4/Obrjqv+ZftUig+b46BECj9cQ1mCTw=
github.com/vcaesar/gops v0.20.0/go.mod h1:EvpOHW7re4rBSzI1B/Rly0CxfT7C9lLo7Rpgs6IVpF0=
github.com/vcaesar/imgo v0.12.1 h1:/mmZPL0CQwXtdr73ouoCu8Z9gmfmdgaFYoG0YSZ1gdU=
github.com/vcaesar/imgo v0.12.1/go.mod h1:MwS4X0FXkLxshu8jMrHCLEM0S6JOQ6lU3drq5nO9AdE=
github.com/vcaesar/tt v0.11.0 h1:obQecjgbnAxxC6OYGY6yDvhGRW2PR5wD8Ma2uJH3WGA=
Expand All @@ -89,8 +91,9 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnk
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20201208152932-35266b937fa6 h1:nfeHNc1nAqecKCy2FCy4HY+soOOe5sDLJ/gZLbx6GYI=
golang.org/x/image v0.0.0-20201208152932-35266b937fa6/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20210607152325-775e3b0c77b9 h1:D0iM1dTCbD5Dg1CbuvLC/v/agLc79efSj/L35Q3Vqhs=
golang.org/x/image v0.0.0-20210607152325-775e3b0c77b9/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
Expand All @@ -102,18 +105,20 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200720211630-cb9d2d5c5666/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210104204734-6f8348627aad h1:MCsdmFSdEd4UEa5TKS5JztCRHK/WtvNei1edOj5RSRo=
golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210608053332-aa57babbf139 h1:C+AwYEtBp/VQwoLntUmQ/yx3MS9vmZaKNdw5eOpoQe8=
golang.org/x/sys v0.0.0-20210608053332-aa57babbf139/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190808195139-e713427fea3f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
Expand Down
38 changes: 0 additions & 38 deletions patch_robotgo.sh

This file was deleted.

13 changes: 4 additions & 9 deletions typing/typing.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import (
// SpecialChar defines a character that has to be typed in a non-standard way.
type SpecialChar struct {
Character string `yaml:"character"`
Key string `yaml:"key"`
CommandKey string `yaml:"command"`
SpaceAfter bool `yaml:"space_after"`
KeySym int `yaml:"key_sym"`
}

// Config specifies the behavior when typing.
Expand Down Expand Up @@ -53,6 +52,7 @@ func typeStr(str string, cfg *Config) {
// robotgo's linux implementation for typing cannot deal with special keys on non-standard keyboard layouts (e.g. Swiss German),
// so handle such special keys explicitly.
if runtime.GOOS == "linux" {
robotgo.StartMultiToggleKey()
parts := util.SplitSpecials(str, cfg.SpecialCharList)
for _, p := range parts {
if len(p) == 1 && strings.Contains(cfg.SpecialCharList, p) {
Expand All @@ -61,19 +61,14 @@ func typeStr(str string, cfg *Config) {
robotgo.TypeStr(p)
}
}
robotgo.EndMultiToggleKey()
} else {
robotgo.TypeStr(str)
}
}

func typeSpecialKey(key SpecialChar) {
if key.CommandKey == "gralt" {
robotgo.KeyToggle("gralt", "down")
robotgo.KeyTap(key.Key)
robotgo.KeyToggle("gralt", "up")
} else {
robotgo.KeyTap(key.Key, key.CommandKey)
}
robotgo.KeysymType(uint32(key.KeySym))

if key.SpaceAfter {
robotgo.KeyTap("space")
Expand Down
21 changes: 12 additions & 9 deletions util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,26 @@ import (
// in the specials parameter. The found special characters are also included in the result.
func SplitSpecials(str string, specials string) []string {
var parts []string
// Reminder: s and i are indexes in bytes. Means if we iterate over a unicode point (e.g. 2 bytes wide),
// i jumps by 2.
s := 0
e := 0
for i, c := range str {
if s < 0 {
s = i
}

if strings.ContainsRune(specials, c) {
if e > s {
parts = append(parts, str[s:e])
if i > s {
parts = append(parts, str[s:i])
}
parts = append(parts, string(c))
s = i + 1
e = s
} else {
e++
// Don't set to i+1 because current char could be more than 2 bytes.
s = -1
}
}

if e > s {
parts = append(parts, str[s:e])
if s > -1 && s < len(str) {
parts = append(parts, str[s:])
}

return parts
Expand Down
9 changes: 8 additions & 1 deletion util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ func TestSplitSpecial(t *testing.T) {
{"hello/world", []string{"hello", "/", "world"}},
{"/hello/", []string{"/", "hello", "/"}},
{"hello", []string{"hello"}},
{"hel/l", []string{"hel", "/", "l"}},
{"/", []string{"/"}},
{\\", []string{\\"}},
{"ä/\\", []string{"ä", "/", "\\"}},
{"helloüworld", []string{"hello", "ü", "world"}},
{"äääüööö", []string{"äää", "ü", "ööö"}},
{"ü", []string{"ü"}},
{"ühello", []string{"ü", "hello"}},
{"", nil},
{"#!/usr/bin/env bash", []string{"#", "!", "/", "usr", "/", "bin", "/", "env bash"}},
}

specials := "/#"
specials := "/#ü"

for _, c := range cases {
actual := SplitSpecials(c.in, specials)
Expand Down

0 comments on commit 8952b1a

Please sign in to comment.