Align Text command please.

Ideas for new features

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
Nial
Posts: 29
Joined: Fri May 09, 2003 12:04 pm

Align Text command please.

Post by Nial »

20 years after posting here....

https://forums.textpad.com/viewtopic.ph ... highlight=

I'm still hoping for a fast alignment command. (Note the tool Prism I talk about in that post doesn't exist any more).

Select a block of text, hit the command, enter the string to align to then the command right justifies any instances of the string in the selected text block.

This is really simple and would massively speed up tidying up code, especially signal declarations and component instances in VHDL.

81% marked this as important in the post above, come on Helios, I'll buy another license if you implement this.
User avatar
AmigoJack
Posts: 532
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Post by AmigoJack »

I'm sure almost 20 years ago you were already able to use BBCode which could have formatted your code examples much better, especially preserving whitespaces. Why you chose to not do so is beyond my understanding, because it should be trivial enough for anybody dealing with code.

Also it's common usage to just use tabular characters (the tab key on your keyboard) for what you want to achieve: just start with 2-3 on the first line and in most cases it should be enough for all the following (see how I now use the CODE BBCode):

Code: Select all

 port map(
          wraddress => ram_wr_address,
          data=> ram_din,       
          wren=> ram_1_wren,    
          wrclock=> clk,           
          wrclken=> enabled,      
          rdaddress => ram_rd_address,
          rdclock=> clk,           
          rden=> enabled,       
          rdclken=> enabled,       
          q=> ram_1_dout     
          );
This is for whatever reason what you don't want (I would even put the commas to the front, so there's never a surprise at the end for too many or too few commas). This also can't be a generated text, because the first and sixth parameters have a trailing white space in front of the operator, unlike all others.

If you would have used tab characters right away when typing it would have become:

Code: Select all

 port map(
          wraddress{TAB}=> ram_wr_address,
          data{TAB}{TAB}=> ram_din,       
          wren{TAB}{TAB}=> ram_1_wren,    
          wrclock{TAB}=> clk,           
          wrclken{TAB}=> enabled,      
          rdaddress{TAB}=> ram_rd_address,
          rdclock{TAB}=> clk,           
          rden{TAB}{TAB}=> enabled,       
          rdclken{TAB}=> enabled,       
          q{TAB}{TAB}=> ram_1_dout     
          );
...which then looks as per editor (in this case {TAB} equals 8 characters in width) like:

Code: Select all

 port map(
          wraddress     => ram_wr_address,
          data          => ram_din,       
          wren          => ram_1_wren,    
          wrclock       => clk,           
          wrclken       => enabled,      
          rdaddress     => ram_rd_address,
          rdclock       => clk,           
          rden          => enabled,       
          rdclken       => enabled,       
          q             => ram_1_dout     
          );
Microsoft Word also needs the tab character (yes, it's that, not the tab key on your keyboard activating some magic feature) to achieve this.


This is how I'd write it, putting the commas in front and avoiding needless indention, and using 1-3 tab characters in front of the operator right away when typing:

Code: Select all

port map
( wraddress     => ram_wr_address
, data          => ram_din
, wren          => ram_1_wren
, wrclock       => clk
, wrclken       => enabled
, rdaddress     => ram_rd_address
, rdclock       => clk
, rden          => enabled
, rdclken       => enabled
, q             => ram_1_dout
);
Nial
Posts: 29
Joined: Fri May 09, 2003 12:04 pm

Post by Nial »

You're a right sarcastic bugger and have also missed the point.

"Why you chose to not do so is beyond my understanding"

Because I'd never heard of it, hopefully you can get your head round that.

There can be cuts and pastes of code from other designs, block replacements of signals, the introduction of longer signal names then previously, multiple other reasons why code ends up mis-aligned.

Thanks for demonstrating what it would do though, it would be very useful for tidying things up.
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

AmigoJack wrote: This is how I'd write it, putting the commas in front and avoiding needless indention, and using 1-3 tab characters in front of the operator right away when typing:
and then someone views it with a different tab width ...

Apart from other reasons why it were nice to have an alignment tool that uses spaces (codes from other sources than your own writing, increased lengths of new entries, ...)
User avatar
AmigoJack
Posts: 532
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Post by AmigoJack »

Yes, I've seen both code and BBS posts being treated like smelly socks instead of putting a bit of effort into it before: not wondering why there is a "Code" button, and not being consistent on putting a space in front of an operator or not. Apparently my 25+ years are not enough to encounter projects where single lines of code are changed so often and so drastically that it ruins the formatting so quickly. I've also seen code being center aligned, such as:

Code: Select all

      data => ram_din,
      wren => ram_1_wren,
   wrclock => clk,
   wrclken => enabled,
 rdaddress => ram_rd_address,
(And while in programming languages it is an odd encounter, the most prominent example would be SQL where it's regularily used:)

Code: Select all

SELECT t.column
  FROM table t
  JOIN other o ON o.id= t.id
 WHERE filter
   AND NOT something
Do you see where this leads to? "Align text" as a feature could be more complex than you think.

A different tab width happens, sure. Want me to pull out code from others from 25+ years ago that already had a comment which stated how to treat tabs?

But I'm more with you than not for wanting this indention/fillup feature. Why? Because the Edit > Reformat works surprisingly intelligent up to today: it also discovers when one line begins with a hyphen and a space (to simulate a list's point) and the following lines also have the indention of two spaces (to continue that point of the list) - the reformatting maintains that indention. I wonder if I'm the only one using it with joy. In Notepad++ I don't find such a feature.
Post Reply