Ctrl+C to copy line - code edit

Editor for AutoHotkey written completely in AutoHotkey.

Moderator: maestrith

Heezea
Posts: 59
Joined: 30 Sep 2013, 21:33

Ctrl+C to copy line - code edit

11 Sep 2018, 11:28

With nothing selected, I wanted Ctrl+c to copy the entire line.

This can be done by searching the AHKStudio code for 2178 and replacing with 2519. There is only one occurrence to change.

This works because In Scintilla, the code for "CopyAllowLine" is 2519. Please see http://www.scintilla.org/CommandValues.html
Heezea
Posts: 59
Joined: 30 Sep 2013, 21:33

Re: Ctrl+C to copy line - code edit

11 Sep 2018, 15:59

I wanted this to work how it works in SciTE4AHK and, I think, most other editors (tried and confirmed in atom and sublimetext). The way I'm accustomed to it working is:
1. Ctrl+c pressed on a line of text with nothing selected.
2. Ctrl+v pressed on a line of text with nothing selected. This would insert the line as a new line at the beginning of the line that the cursor is currently on. This would be similar to using "Duplicate line" but needing to press a second key where you wanted the line duplicated. Once the line is inserted, the cursor goes back to the position it was in right before the paste action.

The way it currently works in AHKStudio is that it will place the copied line at the location of the cursor. So, if your cursor is not at the very beginning of the line where you want it inserted, it will append the copied text where the cursor is.

I made an attempt to get this desired behavior. It seems to be working ok.

TOP OF FILE AT GLOBAL DECLARATIONS
Added global variable that is used in the copy/paste functions.

Code: Select all

global blnWholeLine:=false
COPY FUNCTION
Last line of function changed by adding a check to see if the whole line was selected.

Code: Select all

	}CSC().2519(),Clipboard:=RegExReplace(Clipboard,"\R","`r`n"),blnWholeLine:=(CSC().2143=CSC().2145)
PASTE FUNCTION
Adjusted function to check whether a whole line was previously selected and to check for what is selected prior to pasting.

Code: Select all

Paste(){
	ControlGetFocus,Focus,% MainWin.ID
	if(Focus="Edit1"){
		SendMessage,0x302,0,0,Edit1,% MainWin.ID
		return
	}
	
	sc:=CSC()
	blnSelectedNothing:=(CSC().2143=CSC().2145)
	if(!blnWholeLine or !blnSelectedNothing){
		Line:=sc.2166(sc.2008)+1
	}
	else {
		CarPos:=sc.2008
		Line:=sc.2166(sc.2008)
		sc.2024(Line)
	}
	sc.2078(),sc.2179(),MarginWidth(sc),Edited(),RegExReplace(Clipboard,"\n",,Count)
	Loop,% Count+1
		LineStatus.Add(Line+(A_Index-1),2)
	sc.2079
	sc.2078
	if(v.Options.Full_Auto_Indentation&&Current(3).Lang="ahk")
		FixIndentArea()
	if(CarPos){
		sc.2024(Line+1)
		sc.2025(CarPos+StrLen(Clipboard))
	}
	sc.2079
	SetTimer,Scan_Line,-1
}
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Ctrl+C to copy line - code edit

12 Sep 2018, 13:58

You could make a pull request on github.
Recommends AHK Studio

Return to “AHK Studio”

Who is online

Users browsing this forum: No registered users and 20 guests