Format plugin

Discuss and announce AkelPad plugins
  • Author
  • Message
Offline
Posts: 1862
Joined: Mon Aug 06, 2007 1:07 pm
Contact:

Post by Infocatcher »

KDJ
I think, for remove/extracts lines and reverse order should used buttons.

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

Infocatcher wrote:I think, for remove/extracts lines and reverse order should used buttons.
I did LinesSort.js, but buttons instead of boxes were not good.

Offline
Site Admin
Posts: 6311
Joined: Thu Jul 06, 2006 7:20 am

Post by Instructor »

KDJ wrote:Well, actually in Format plugin is not option "case sensitive".
May partially solve the problem ColumnsSort.js script.
It is possible via external call with code 1.

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

Instructor wrote:It is possible via external call with code 1.
Indeed. Sorry, I had not noticed this before.

Offline
Posts: 119
Joined: Sat Jan 12, 2008 10:16 am
Location: Shantou, China

Seperator by any character(s) instead of "\r" only

Post by cnnnc »

How about make Seperator by any character(s) instead of "\r" only?
Example - Seperator ";" for following:

Code: Select all

*.rar;*.zip;*.ace;*.arc;*.arj;*.jar;*.cab;*.7z;*.lzh;*.tar;*.bz2;*.gz;*.uha;*.sqx;*.kgb;*.dir;*.uue;*.xxe;*.deb;*.gzip;*.uc2;*.sbc;*.pak;*.tgz;*.bgz
Sort by StringAscending, and then I get:

Code: Select all

*.7z;*.ace;*.arc;*.arj;*.bgz;*.bz2;*.cab;*.deb;*.dir;*.gz;*.gzip;*.jar;*.kgb;*.lzh;*.pak;*.rar;*.sbc;*.sqx;*.tar;*.tgz;*.uc2;*.uha;*.uue;*.xxe;*.zip

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Re: Seperator by any character(s) instead of "\r"

Post by KDJ »

cnnnc wrote:How about make Seperator by any character(s) instead of "\r" only?
I think you should use Replace.
Main menu -> Edit -> Replace...
What: \n
With: ;
Select Esc-sequences, and then press Replace all.
All line-end characters will be replaced by a semicolon.

Offline
Posts: 119
Joined: Sat Jan 12, 2008 10:16 am
Location: Shantou, China

Re: Seperator by any character(s) instead of "\r"

Post by cnnnc »

KDJ wrote:I think you should use Replace.
...
You get me wrong.
As you mean if I want to sort my string, I have to replace ";" with "\r", and then sort it, finally replace "\r" back to ";".
But my string only in one line, and I just want to get a "aTxt" like this:

Code: Select all

    var pSeperator = ";";
    // ...
    aTxt  = AkelPad.GetSelText(1 /*\r*/).split(pSeperator);
and then sort "aTxt", in this way I can do it easily, not:

Code: Select all

    aTxt  = AkelPad.GetSelText(1 /*\r*/).split("\r");
Your LinesSort.js is Great, but it's only used to deal with the situation of seperator is "\r".

Offline
Posts: 876
Joined: Tue Jul 24, 2007 8:54 am

Post by Fr0sT »

Quite useful suggestion IMHO

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Re: Seperator by any character(s) instead of "\r"

Post by KDJ »

cnnnc wrote:You get me wrong...
LinesSort.js script is designed to sort lines, and not to sort the words contained between any separators.
Therefore, as separator of strings used newline character (\r or \n).
Maybe, on the basis of LinesSort.js, I'll write a script to sort words (eg. WordsSort.js).
Meanwhile, you can deal with, replacing semicolons with end-line characters and vice versa.
Original string:

Code: Select all

*.zip;*.arj;*.7z;*.rar
Replace ";" with "\n":

Code: Select all

*.zip
*.arj
*.7z
*.rar
Sort lines using Format plugin or LinesSort.js script:

Code: Select all

*.7z
*.arj
*.rar
*.zip
Replace "\n" with ";":

Code: Select all

*.7z;*.arj;*.rar;*.zip

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Re: Seperator by any character(s) instead of "\r"

Post by KDJ »

Well, the script is almost ready.
Sorting strings contained between the semicolons:

Code: Select all

AkelPad.ReplaceSel(AkelPad.GetSelText().replace(/;/g, "\r"), 1);
AkelPad.Call("Format::LineSortStrAsc");
AkelPad.ReplaceSel(AkelPad.GetSelText().replace(/\r/g, ";"), 1);

Offline
Posts: 876
Joined: Tue Jul 24, 2007 8:54 am

Post by Fr0sT »

cnnnc
you can easily modify the script yourself, just add separator as parameter or do the query for it in the beginning of the script

Offline
Posts: 119
Joined: Sat Jan 12, 2008 10:16 am
Location: Shantou, China

Post by cnnnc »

KDJ
It's work. Thank you.

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

cnnnc
I wrote ListSort.js script that sorts lists separated with any separator, in each line, by using Format plugin.

Offline
Posts: 119
Joined: Sat Jan 12, 2008 10:16 am
Location: Shantou, China

Post by cnnnc »

KDJ
I test it. It works very well if I needn't to undo/redo. Its undo/redo is not convenient, because they are a new operation, not just like Akelpad as.
After all it has been quite good. Thank you.

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

cnnnc
In ListSort.js I changed the action of Undo/Redo. Now it is compatible with AkelPad.
Post Reply