Page 1 of 2

text navigation by paragraph using ctrl+down

Posted: Wed Oct 07, 2015 11:04 am
by woreda
Hi Akelpadderrs,
I was trying to navigate by paragraph using ctrl+down, but it moves down line by line. so, is therre any scrript, plugin or setting to enable this kind of cursor movement in the text?

Woreda

Posted: Wed Oct 07, 2015 7:32 pm
by KDJ
woreda
From AkelPad documentation:
AkelHelp-Eng.htm wrote:Ctrl+Up - go to start of previous line
Ctrl+Down - go to start of next line
From Wikipedia:
Paragraph
...
In computing
...
In plaintext files, there are two common formats. Pre-formatted text will have a newline at the end of every physical line, and two newlines at the end of a paragraph, creating a blank line. An alternative is to only put newlines at the end of each paragraph, and leave word wrapping up to the application that displays or processes the text.
What do you understand by the term "paragraph" in plain text file?

Posted: Fri Oct 09, 2015 8:11 am
by woreda
KDJ:
thank you for yourr prrompt response.
what I mean is [quote=In plaintext files, there are two common formats. Pre-formatted text will have a newline at the end of every physical line, and two newlines at the end of a paragraph, creating a blank line.]

Posted: Fri Oct 09, 2015 8:48 am
by DV
Looks like this is the script to be assigned to Ctrl+Down:

Code: Select all

AkelPad.TextFind(0, "(?<=\\n\\n)", 0x00000001|0x00040000|0x00080000);
and to Ctrl+Up:

Code: Select all

AkelPad.TextFind(0, "(?<=\\n\\n)", 0x00100000|0x00040000|0x00080000);
The hotkeys can be assigned either from the Scripts plugin's window or from the Hotkeys plugin.
See AkelFiles\Docs\Scripts-Eng.txt and AkelFiles\Docs\Hotkeys-Eng.txt for more details.

Posted: Fri Oct 09, 2015 9:04 am
by woreda
thanks! it works very well.
I assigned ctrl+down and ctrl+up, will it be a problem?

Posted: Fri Oct 09, 2015 9:54 am
by DV
woreda wrote:I assigned ctrl+down and ctrl+up, will it be a problem?
Nope, these assigned hotkeys override the default behaviour which in case of Ctrl+Down and Ctrl+Up seems to be duplicate of Down and Up.
There is, however, a thing that could be improved in the code mentioned above. Let's imagine that some of your paragraphs are separated by a line of spaces instead of an empty line. Visually the line of spaces looks similar to an empty line (unless you make the space characters visible via SpecialChar plugin), but the RegEx "(?<=\\n\\n)" does not handle spaces. You could say the RegEx could be changed to "(?<=\\n(\\s*)\\n)" to handle that - but, unluckily, (?<=pattern) supports only fixed length pattern, whereas (\\s*) is obviously non-fixed.

Posted: Fri Oct 09, 2015 5:04 pm
by Instructor
Single Scripts plugin method call can be done without script (more fast variant):

Code: Select all

"Find next paragraph" Call("Scripts::Main", 7, `AkelPad.TextFind(0, "(?<=\n\n)(?!\n)", 0x80001 /*FRF_DOWN|FRF_REGEXP*/)`)

Posted: Sat Oct 10, 2015 1:25 pm
by woreda
Instructor wrote:Single Scripts plugin method call can be done without script (more fast variant):

Code: Select all

"Find next paragraph" Call("Scripts::Main", 7, `AkelPad.TextFind(0, "(?<=\n\n)(?!\n)", 0x80001 /*FRF_DOWN|FRF_REGEXP*/)`)
I tried to save it as a js file and when I try to use it says:
"Scripts plugin
Script:
E:\Users\SkyDrive\PortableApps\AkelPadPortable\App\AkelPadx64\Ake
lFiles\Plugs\Scripts\next_paragraph.js
Line: 2
Symbol: 26
Error: Invalid character
Code: 800A03F6
Source: Microsoft JScript compilation error"

@DV thank You again.
DV wrote:There is, however, a thing that could be improved in the code mentioned above. Let's imagine that some of your paragraphs are separated by a line of spaces instead of an empty line. Visually the line of spaces looks similar to an empty line (unless you make the space characters visible via SpecialChar plugin), but the RegEx "(?<=\\n\\n)" does not handle spaces. You could say the RegEx could be changed to "(?<=\\n(\\s*)\\n)" to handle that - but, unluckily, (?<=pattern) supports only fixed length pattern, whereas (\\s*) is obviously non-fixed.
I'd like that, is there a way to implement it?

Posted: Sat Oct 10, 2015 3:45 pm
by KDJ
woreda wrote:
Instructor wrote:Single Scripts plugin method call can be done without script (more fast variant):

Code: Select all

"Find next paragraph" Call("Scripts::Main", 7, `AkelPad.TextFind(0, "(?<=\n\n)(?!\n)", 0x80001 /*FRF_DOWN|FRF_REGEXP*/)`)
I tried to save it as a js file and when I try to use it says:
...
This code must not be saved in a file.
It is for immediate use on toolbar, menu or hotkey.

Posted: Sat Oct 10, 2015 4:51 pm
by woreda
ok. How can i assign a hot key to the code without saving it as a script first?

Posted: Sat Oct 10, 2015 5:16 pm
by KDJ
woreda
By using Hotkeys plugin.
Name: Find next paragraph
Command: Call("Scripts::Main", 7, `AkelPad.TextFind(0, "(?<=\n\n)(?!\n)", 0x80001)`)
Hotkey: Ctrl + Down

Posted: Sat Oct 10, 2015 5:48 pm
by woreda
KDJ
thank you!
Sorry, for bothering you. I should have checked in the hot key pluggin first.
Now it works well. But, how do i assign previous paragraph? I tried changing the text down to up in the code, but it does the same thing, finding the next paragraph.

Posted: Sat Oct 10, 2015 6:12 pm
by KDJ
woreda
Name: Find previous paragraph
Command: Call("Scripts::Main", 7, `AkelPad.TextFind(0, "(?<=\n\n)(?!\n)", 0x00180000)`)
Hotkey: Ctrl + Up

About AkelPad.TextFind method read in documentation (Scripts-Eng.txt). For convenience, you can use AkelPadMethodsView.js script.

Posted: Sun Oct 11, 2015 11:38 am
by woreda
KDJ
thank you again! it works flawlessly.
btw, is it possible
DV wrote:find next paragraph, even if there are spaces in the empty lines?
I emphasized it a little bit.

Posted: Sun Oct 11, 2015 2:13 pm
by KDJ
woreda
Try this:

Code: Select all

"Find prev paragraph" Call("Scripts::Main", 7, `AkelPad.TextFind(0, "(?<=\n)[ \t]*\n\K(?=[ \t]*\S)|\A[ \t]*\n\K(?=[ \t]*\S)|\A(?=[ \t]*\S)", 0x00180000 /*FRF_UP|FRF_REGEXP*/)`)
"Find next paragraph" Call("Scripts::Main", 7, `AkelPad.TextFind(0, "\A[ \t]*\n\K(?=[ \t]*\S)|(?<=\n)[ \t]*\n\K(?=[ \t]*\S)", 0x00080001 /*FRF_DOWN|FRF_REGEXP*/)`)