text navigation by paragraph using ctrl+down

English main discussion
  • Author
  • Message
Offline
Posts: 10
Joined: Sat Oct 03, 2015 11:13 am
Location: nearby to ethiopis

text navigation by paragraph using ctrl+down

Post 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

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

Post 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?

Offline
Posts: 10
Joined: Sat Oct 03, 2015 11:13 am
Location: nearby to ethiopis

Post 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.]

DV
Offline
Posts: 1250
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Post 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.

Offline
Posts: 10
Joined: Sat Oct 03, 2015 11:13 am
Location: nearby to ethiopis

Post by woreda »

thanks! it works very well.
I assigned ctrl+down and ctrl+up, will it be a problem?

DV
Offline
Posts: 1250
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Post 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.

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

Post 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*/)`)

Offline
Posts: 10
Joined: Sat Oct 03, 2015 11:13 am
Location: nearby to ethiopis

Post 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?

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

Post 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.

Offline
Posts: 10
Joined: Sat Oct 03, 2015 11:13 am
Location: nearby to ethiopis

Post by woreda »

ok. How can i assign a hot key to the code without saving it as a script first?

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

Post 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

Offline
Posts: 10
Joined: Sat Oct 03, 2015 11:13 am
Location: nearby to ethiopis

Post 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.

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

Post 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.

Offline
Posts: 10
Joined: Sat Oct 03, 2015 11:13 am
Location: nearby to ethiopis

Post 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.

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

Post 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*/)`)
Post Reply