Hi all,
I code using python and java quite often nowadays and I use visual studio code for that. The thing is these programming languages have indentations and I don't know if it is possible to find and navigate quickly between them. In nvda for windows you can set it so if there is an indentation nvda will tell about it and you won't have to scan manually by pressing left or right arrows and cycling between spaces,what if we have 16 spaces before the code in the line? So, is there the way to quickly navigate and find indentations with VoiceOver on mac? How can I do that? Thank you in advance!
Comments
Don't know
I'm not aware of any way to do this. As far as I know, Python is the only language of those two where indentation is actually important. I deal with the indentation issue by using tabs rather than spaces, since it's possible to get VO to announce them, without making VO overly verbose in the process.
I assume you're reasonably familiar with Python, so assuming you can't find a suitable tool, it would be easy enough to write a script to convert between tabs and spaces, and vice versa, if you absolutely need to use spaces for indentation.
A cave man's workaround
I don't know any automatic way of solving the problem.
My workaround, and it is a very manual one, was to add pronunciations in Voiceover for sets of spaces, 4, 8, 12... I think I went to 10 indentation levels, and make VoiceOver read them as indentations, firstly 1 tab, 2 tabs, but recently I changed it to 1 tic, 2 tics for speed reasons.
It works great on text mate 2, however VScode has a problem and when you open the app it says Code only, so you can't configure Voiceover to only adopt that pronunciation only in VSCode, and it bothers me if indentation is spoken in Eclipse or Xcode.
An AppleScript to check the indentation of the last spoken text
Hello,
The indentation level for code is not only for Python. Other languages use it to show better for non blind developers. If you need to share your code or you have to become a member of a developer team the indentation level is important.
I developed an appleScript for this. You only have to call this AppleScript with a VoiceOver command using a shortcut.
The AppleScript is in my GitHub account. Here is the link to the repository https://github.com/TyflosAccessibleSoftware/IndentationLineForVoiceOver
Auto indent
I agree that indentation is important in other languages to work in a team.
However in those cases I usually ignore it and let the IDE auto indent my code.
I mentioned Python because indentation is crucial to make the code work, that's why I like to have indentation report in every Python line and in other languages I ignore it while coding and let the IDE format it when I save the files.
And thanks for the script!
Indent Report in Visual Studio Code
There’s an extension called indent report in the visual studio code marketplace that announces the indentation level using sounds. It works very well.
Does this solution require…
Does this solution require you to use tabs rather than spaces? I had a quick try but got "space space space space...." read out to me when I selected a load of spaces.
Regarding your comment re VS Code - can you use Activities in VoiceOver to work around this? It would allow you to have different settings for VS Code specifically if that helps.
I'm currently battling with the same problem. I'm hoping to get up and running in PyCharm (the latest IntelliJ EAP fixes a lot of VoiceOver problems, so hopefully those changes will appear in PyCharm's next EAP). But indentation looks like a big problem.
I will try out the AppleScript when I have a few mins. (Just need to brush up on my Spanish :) )
IntelliJ IDEA and it's accessibility
Woaw!
I didn't know they are improving accessibility!
Last year I tried to use pyCharm it wasn't really accessible.
It seems like I will need to use IntelliJ IDEA often now because I am learning java and I am curious how it works with maven and how accessibility works there nowadays.
Where can I read about using it with screen readers including VoiceOver?
Thank you!
Script and VSCode extension
Hi all again,
Thank you for the script and information about extension.
Maybe I will try that, but with this current situation it is better for me to switch to linux or maybe windows in turms of coding because VoiceOver doesn't have such simple things.
Also imho nuance voices are hardly usable for coding purposes.
Activities!!!
Thanks, I forgot about activities! Probably it will work as it allows to select opened activities, whereas punctuation only lists the ones in the applications folder (I think).
Yes, my current indentation punctuation workaround works with spaces, but you have to be precise with the amount of spaces, I don't know if it is configurable but my python indents 4 spaces per indentation level.
I opened Intellij accidentally the other day and I was surprised by it reading a Java file, I am very curious to try pycharm when my current project finishes!
I've not seen anything…
I've not seen anything official about it, other than something vague like "macos accessibility improvements" in their EAP announcements and some activity on their issue tracker, and a few mostly unofficial comments on their forum (https://intellij-support.jetbrains.com/hc/en-us/community/posts/360009718839-Using-IntelliJ-with-a-screen-reader?page=1).
I'm guessing the PyCharm EAP is lagging behind IntelliJ a little, so hopefully the next one will have the improvements, but also I'm hoping that they've not stopped yet.
Personally, I'd urge anyone who wants this sort of thing to make their voices heard. Maybe upvote the features etc as the more support it has, the better it's likely to get.
Ah OK - it didn't work for…
Ah OK - it didn't work for me with spaces, but it's quite likely I was doing it wrong. I will have a mess about with it some more when I have some free time. It's not an elegant solution, sure, but it sounds perfectly good to me if it can be made to work. I slightly prefer it to an AppleScript solution because it's not adding anything new to the mix, but I'm really grateful for the script as well and will check it out if I can't get your idea to work.
I tried the pronunciation…
I tried the pronunciation method (i.e. having 4 spaces with "four spaces" as the text) and it actually seems to work pretty well, although not flawlessly.
I tried in TextEdit and typed 4 spaces, then shift+cmd+left to select them, and it read "space space space space". But doing the same in the opposite direction did read "four spaces".
I then used a Python script in intellij EAP and was surprised that it was actually reading the indentation level out as I moved up and down lines in the code. It actually seemed pretty damn good.
Noticed that there is a new…
Noticed that there is a new EAP of PyCharm which does seem to include the IntelliJ VoiceOver fixes.
As far as I can tell, the toolbox app doesn't work at all with VoiceOver yet.
Let's write to apple accessibility!
Hi all!
I have a suggestion!
I believe we all should write to apple accessibility about the indentations reading feature should be included.
It is extremely important for coding!
Here how I suggest implementing it:
It could be the VoiceOver setting that would allow to choose the method how indentations would be read, the similar that is already present with text attributes.
1. With the signal. If the indentation changes, the signal should be higher/lower depending on the count of spaces.
For example:
If there are 4 spaces there can be the low sound.
When there are 8 spaces it should be slightly higher.
And ETC.
When there are less spaces, from 8 to 4, the sound should be getting lower and lower depending on spaces count, when we don’t have spaces we could have the lowest sound.
You can see how it works in NVDA screen reader for windows.
2. The setting to speak spaces:
4 spaces, 8 spaces, 12 spaces, no indentation.
You can also see how it works in NVDA screen reader for windows.
3. The setting to use both the sound and speaking of indentations.
We could hear the sound that the indentation is present plus the message for example 4 spaces or 8 spaces.
It can really help a lot of people who perform coding tasks on Mac.
I am sure that if a lot of people write them about that really need feature they will include it.
So let's do it! :)
Thanks
Wow! I was so convinced that typing spaces in the pronunciation dictionary wouldn't work that I didn't try it. Thank you so much for trying and then sharing the simple "cave man" solution. I added them to my coding VoiceOver activity and it works well.
I might try the Apple script solution as well. I like Apple scriptts, but it is amazing how often they don't work because of some security problem with where or how they are run.
I wish Apple would include a feature for speaking indentation, but I personally wouldn't like sounds. First, I turned off my VO sounds. They should really make it possible to turn off some and not other sounds as it is with iOS. I simply can't stand that stupid sound VO makes every time focus moves.
Second, I'm not actually tone deaf, but I often have problems identifying sounds that only differ in pitch. Seems to be my brain rather than my ears, but it sure is inconvenient and embarrassing for a blind person to have my problem.
One of many reasons to use a braille display
A braille display can show the indentation correctly. Also, some editors have block-based navigation commands that should be useful for moving quickly to the desired code.
Indentation and simple notepad?
I am using notepad on windows for coding in python.
I think you could use like notepad on your mac.
Cheers!