{"action":"created","issue":{"url":"https://api.github.com/repos/dictation-toolbox/aenea/issues/100","labels_url":"https://api.github.com/repos/dictation-toolbox/aenea/issues/100/labels{/name}","comments_url":"https://api.github.com/repos/dictation-toolbox/aenea/issues/100/comments","events_url":"https://api.github.com/repos/dictation-toolbox/aenea/issues/100/events","html_url":"https://github.com/dictation-toolbox/aenea/pull/100","id":109918184,"number":100,"title":"Handle basic alt-key sequences for extended ASCII chars in the aenea client.","user":{"login":"nirvdrum","id":12584,"avatar_url":"https://avatars.githubusercontent.com/u/12584?v=3","gravatar_id":"","url":"https://api.github.com/users/nirvdrum","html_url":"https://github.com/nirvdrum","followers_url":"https://api.github.com/users/nirvdrum/followers","following_url":"https://api.github.com/users/nirvdrum/following{/other_user}","gists_url":"https://api.github.com/users/nirvdrum/gists{/gist_id}","starred_url":"https://api.github.com/users/nirvdrum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nirvdrum/subscriptions","organizations_url":"https://api.github.com/users/nirvdrum/orgs","repos_url":"https://api.github.com/users/nirvdrum/repos","events_url":"https://api.github.com/users/nirvdrum/events{/privacy}","received_events_url":"https://api.github.com/users/nirvdrum/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-06T01:20:05Z","updated_at":"2015-10-09T15:48:42Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/dictation-toolbox/aenea/pulls/100","html_url":"https://github.com/dictation-toolbox/aenea/pull/100","diff_url":"https://github.com/dictation-toolbox/aenea/pull/100.diff","patch_url":"https://github.com/dictation-toolbox/aenea/pull/100.patch"},"body":"The basic problem I'm trying to fix here is Dragon 14 (maybe earlier too?) will send an en dash character when the 'dash' command is used in the middle of a dictation sequence. This character is `\\x96` in extended ASCII. Tkinter sends the key press the way one would typically enter extended ASCII characters on Windows: by sending an Alt_L press followed by the numeric sequence (0, 1, 5, 0, in this case).\r\n\r\nI've been unable to train myself to replace 'dash' with 'hyphen' thus far and what happens is the aenea client sends over a \"0150\" instead. It's been frustrating me, so I wanted to fix it.\r\n\r\nThe approach taken here is to look at both the char and keysym attributes of the event. The char will contain the en dash character as a Unicode code point at the end of the sequence, when the keysym would be '??'. To track through this, I implemented a small state machine that is activated when the 'Alt_L' keysym is encountered.\r\n\r\nThere is a hole in the state machine: if someone presses 'Alt_L' followed by the '0' key by typing in the aenea client, all characters will be discarded until the '??' keysym is encountered, marking the end of the sequence. It seems extremely unlikely this would ever happen in the real world and I don't think it can happen at all via dictation. Should it happen, simply pressing 'Alt_L' again would reset the state.\r\n\r\nI'm sure there's more clean up that could be done here. Before investing too much more into it, I want to get buy-in first. I'm already finding it helpful."},"comment":{"url":"https://api.github.com/repos/dictation-toolbox/aenea/issues/comments/146908385","html_url":"https://github.com/dictation-toolbox/aenea/pull/100#issuecomment-146908385","issue_url":"https://api.github.com/repos/dictation-toolbox/aenea/issues/100","id":146908385,"user":{"login":"nirvdrum","id":12584,"avatar_url":"https://avatars.githubusercontent.com/u/12584?v=3","gravatar_id":"","url":"https://api.github.com/users/nirvdrum","html_url":"https://github.com/nirvdrum","followers_url":"https://api.github.com/users/nirvdrum/followers","following_url":"https://api.github.com/users/nirvdrum/following{/other_user}","gists_url":"https://api.github.com/users/nirvdrum/gists{/gist_id}","starred_url":"https://api.github.com/users/nirvdrum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nirvdrum/subscriptions","organizations_url":"https://api.github.com/users/nirvdrum/orgs","repos_url":"https://api.github.com/users/nirvdrum/repos","events_url":"https://api.github.com/users/nirvdrum/events{/privacy}","received_events_url":"https://api.github.com/users/nirvdrum/received_events","type":"User","site_admin":false},"created_at":"2015-10-09T15:48:42Z","updated_at":"2015-10-09T15:48:42Z","body":"As for moving the state machine logic into `AltKeySequenceState`, that's certainly doable. I wrote the class as a poor man's enum because Python 2.7 doesn't have enum without requiring an external package. As such, it's very bare bones.\r\n\r\nI don't care much one way or the other. I can move the state into there -- it'll just make the control flow a bit odder since there are fail-fast paths."}}