FXMisc / RichTextFX

Rich-text area for JavaFX
BSD 2-Clause "Simplified" License
1.19k stars 236 forks source link

RFE Elastic Tabstops #175

Open RobertBColton opened 8 years ago

RobertBColton commented 8 years ago

I am not sure if this has been considered before but I'd like to bring it up. Elastic tabstops is a new way of solving the old tabs vs. spaces dillema by treating vertical tabs as TSV to achieve block alignment. http://nickgravgaard.com/elastic-tabstops/

It has been implemented in a number of editors including Google's new Go programming language, Sublime, Visual Studio, Eclipse (halted by a bug), and there has been talks of Atom support. https://github.com/SublimeText/ElasticTabstops Elastic Tabstops

The approach has been to implement it for the vertical tab character to not break existing tab indentation and also because it solves rare edge cases such as python as in the following:

def foo( bar,
         xyzzy ):
         wibble() # Too much indentation

So that you can get the following instead:

def foo( bar,
         xyzzy ):
    wibble()

Basically normal tabs would be for indentation and vertical tab would be for columnar alignment. The reason being also that vertical tabs have really no need for anything but every editor and parser still usually treats them as whitespace.

I feel this would be a really great feature to set RTFX apart from a lot of other editors in a very good way and something I would like to see. Even if implemented as an optional feature I would like to see it enabled by default as well.

TomasMikula commented 8 years ago

It is a nice feature, but not trivial to implements. Currently, the document is a list of TextFlows. This would have to change to a list of TextFlows or tables of TextFlows, where deciding what is going to be a single TextFlow and what is going to be a table has to be detected automatically. It is an interesting challenge that I would like to take on if I had the bandwidth for it, but I don't see that happening in the near future. Of course anyone is welcome to take on the task.

nick-gravgaard commented 7 years ago

I just saw this issue and wanted to point out that that my elastic tabstops invention does not propose using the vertical tab character for anything, and never has. Elastic tabstops uses normal tab characters. It just means that the tabstops are set dynamically according to the text in the buffer. Using tabs to jump to the next fixed tabstop, and vertical tabs to jump to a different set of elastic tabstops would be very confusing and hard to use. Imagine having two different kinds of tabstop - ugh!

One of the arguments against using tab characters for indenting is that people sometimes have a hard time telling the difference between a tab and a space. Introducing a new whitespace character would make that even worse.