How to add a new line when double clicked at end-of-line?

English main discussion
Post Reply
  • Author
  • Message
Offline
Posts: 9
Joined: Sat Oct 14, 2017 5:58 am

How to add a new line when double clicked at end-of-line?

Post by TiderV »

I am using akelpad ver 4.9.8(X64), sometimes I pick some text and paste to akelpad for later reference, during this process no keyboard manipulation should be required, but it's an annoyance that I have to manually press enter for each line I pasted, so I hope to find a way to automatically add a new line when I double click the mouse at end of line. I think the function should work in this way:

1. Triggered by double click at the end of line or at the end of file
2. If double clicked at the end of one line ,automatically add a new line under that line,and If there is a blank line available under the line triggered double click , no action should be performed.
3. Automatically add gieven number of new lines when mouse double clicked at end of file, and If there are a preset number of blank lines available at end of file ,no action should be performed.
4. After these processes,the caret keeps stay at the position where it clicked.

I have no idea on how to make this script,can anyone give me some help?

Offline
Posts: 874
Joined: Sat Jan 16, 2010 2:03 pm

Re: How to add a new line when double clicked at end-of-line

Post by opk44 »

TiderV wrote:I have no idea on how to make this script,can anyone give me some help?
Why not simplify the problem?
Instead, you can use a script that simulates pressing the {ENTER} and {LEFT}

Code: Select all

var WshShell=new ActiveXObject("WScript.shell");

WshShell.SendKeys("{ENTER}{LEFT}");
Add this script on ToolBar:

Code: Select all

-"Add one New Line"  Call("Scripts::Main", 1, "YourScriptName.js") Icon(14)
Or/And in ContextMenu:

Code: Select all

-"Add one New Line"  Call("Scripts::Main", 1, "YourScriptName.js") Icon(4)

Offline
Posts: 9
Joined: Sat Oct 14, 2017 5:58 am

Post by TiderV »

Thanks a lot for your detailed explanation opk44 , this is a solution ,but it does'n simplify my workflow. I'd rather to use ahk if I need to simulate a key press , I have an ahk based mouse gesture working in background .
What I need is a line-adding in certain condition,for I know little about the akelped script architecture,I need to know more about the following problem:
1. How to catch an event of double click in akelpad?
2. How to detect that the caret position be double clicked is at end of line(file)?
3. How to write a function in responding the event?
4. How to silently add new line and instantly refresh the view without alerting caret position?
5. how to know the number of blank line under the current caret position?
...
currently ,I have no information about these problems, can you(or anyone else) give some more explanation?
thanks a million!
Post Reply