Improved tab support in dingus
- changed tab size to 4
- support for typing tab key + block indent/unindent.
This is a fairly complex change. (Certainly the 4-space tab indent is a good idea.)
Can you explain what the "block indent/unindent" code does, exactly?
Hi @jgm ,
I made these changes because I was playing with the demo, trying to understand how tabs work but couldn't actually type a tab key and had to copy/paste one.
In addition to letting you type a tab character it also supports:
- block indentation by selecting a range of lines and pressing tab
- block un-indentation by selecting a range of lines and pressing shift+tab
- auto indenting the new line when pressing enter (duplicates leading whitespace from the previous line)
- escape key, followed by tab key does default tab key behaviour (ie: moves focus out of text area)
You can try it here if you like.
The code is an almost exact copy from here. I wrote this in 2017, it's been pretty well received on stackoverflow with no issues reported. I've recently tested it on Chrome (Windows, Ubuntu, macOS), Edge (Windows), Firefox (Windows+macOS+Ubuntu), Opera (macOS+Ubuntu), Safari (macOS and iOS with physical keyboard). Not sure about Android or other browsers.
fwiw: if you'd prefer something simpler, see the other answers on the same stackoverflow post but they only support inserting a tab character.
Brad