I'm converting over from SynEdit to AtSynEdit
Question:
- What is the best way to sort "selected lines" of text.
Thank You Sincerely..
AtSynEdit - Sort Lines of Text
-
- Posts: 2245
- Joined: 25.08.2021 18:15
ATSynEdit already has the command for sorting,
call Ed.DoCommand(XXXX) with these codes:
call Ed.DoCommand(XXXX) with these codes:
Code: Select all
uses ATSynEdit_Commands;
cCommand_Sort_Asc = 330;
cCommand_Sort_AscNoCase = 331;
cCommand_Sort_Desc = 332;
cCommand_Sort_DescNoCase = 333;
I'm still new at all this..
I tried:
Ed.DoCommand(cCommand_Sort_Asc,cInvokeInternal,'');
I'm not fully understanding 2nd Parameter..
This TATEditorCommandInvoke cInvokeInternal, cInvokeHotkey, etc.. is probably? Use Hotkey method if one is available, or Invoke an internal method.. ?
3rd Parameter is a String, not sure is this string is used or altered..
If I run this DoCommand on the Ed:
- Then every line is sorted, blank lines are removed.
If I Select/Block a couple lines:
- Then it sorts all lines from beginning of file, up to my selected lines, but no lines after, and blank lines are removed.
I also noticed that Undo doesn't seem to be available after the sort (again I'm new to all this)
My Goal is (with option to Keep or Not Keep blank lines):
- If "couple lines blocked", then sort only those lines
- If "nothing blocked" then sort all lines in whole file
Maybe (only guessing) there is an "Ed.DoCommand(.." and an Ed.Selected.DoCommand(..",, not sure..
Thank You Sincerely..
I tried:
Ed.DoCommand(cCommand_Sort_Asc,cInvokeInternal,'');
I'm not fully understanding 2nd Parameter..
This TATEditorCommandInvoke cInvokeInternal, cInvokeHotkey, etc.. is probably? Use Hotkey method if one is available, or Invoke an internal method.. ?
3rd Parameter is a String, not sure is this string is used or altered..
If I run this DoCommand on the Ed:
- Then every line is sorted, blank lines are removed.
If I Select/Block a couple lines:
- Then it sorts all lines from beginning of file, up to my selected lines, but no lines after, and blank lines are removed.
I also noticed that Undo doesn't seem to be available after the sort (again I'm new to all this)
My Goal is (with option to Keep or Not Keep blank lines):
- If "couple lines blocked", then sort only those lines
- If "nothing blocked" then sort all lines in whole file
Maybe (only guessing) there is an "Ed.DoCommand(.." and an Ed.Selected.DoCommand(..",, not sure..
Thank You Sincerely..
-
- Posts: 2245
- Joined: 25.08.2021 18:15
That parameter was needed for CudaText plugin;>I'm not fully understanding 2nd Parameter..
so you can use any value.
just pass the empty string.>3rd Parameter is a String, not sure is this string is used or altered..
these commands do not keep Undo!>Then it sorts all lines from beginning of file, up to my selected lines, but no lines after, and blank lines are removed.
I also noticed that Undo doesn't seem to be available after the sort (again I'm new to all this)
that is limitation of them.
no, they must work for only selected block, not for lines above the block.
i tested it in CudaText.
CudaText Command Palette has these commands, and i tested them.
from file text
I selected middle part: f z az
e
d
f
z
a
a
c
and called in CudaText "sort asc, without undo".
it has some issues which I must fix: it removed empty lines above the block, which is bad.
all in all, you should make custom sorting. my current sorting has issues.
-
- Posts: 2245
- Joined: 25.08.2021 18:15
-
- Posts: 2245
- Joined: 25.08.2021 18:15