Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add foldable region comments #5

Closed
fade2gray opened this issue Nov 12, 2020 · 10 comments
Closed

Add foldable region comments #5

fade2gray opened this issue Nov 12, 2020 · 10 comments
Assignees
Labels
enhancement new feature or request

Comments

@fade2gray
Copy link

Hello,

I posted a similar [url=https://stackoverflow.com/q/64791832/14619965]question[/url] on Stack Overflow but it hasn't garnered much interest.

Essentially, I'm trying to determine what the start position is, when the copy command is used, for a selected block of text, preferably using windows cmd/Powershell to be used as a script variable.

BlockSelect

I found this API Reference and wondered if it could be used in some fashion.

Thanks for any help.

@mark-wiemer
Copy link
Owner

Hi, sorry for the late reply. Are you able to provide some sort of pseudocode JSON output of what you're expecting? Do you want me to expose something like { row: 2, col: 4 } when you press Ctrl + C?

Looking at your SO question, it looks like you want to copy both the index of the starting position and the selected text in one "Copy" command, is that right? If so, this sounds like a very niche use case, and I can't say I'd spend much time working on it. The purpose of this tool is to help developers write AHK code, and I don't see how that would help. You're more than welcome to help me understand how this is useful!

@mark-wiemer mark-wiemer self-assigned this Dec 11, 2020
@fade2gray
Copy link
Author

fade2gray commented Dec 11, 2020

Hi, my use case was to produce an AHK script that could simplify the creation of folding block comments.

As it is, VSC requires lines of text within the block comment to be indented for it to fold. The need for indentation can be eliminated with the combined use of the folding region tags ;region ;endregion ; the tag combination can be achieved by removing the circumflex anchors from lines 34 & 35 of the ahk.configuration.json file.

For the script to function correctly, it would need to ensure the selected block of text starts at column 0 and finishes at the end of a line and would otherwise issue an alert when launched.

Perhaps this concept could be encoded within the extension, possibly being called from the editor's context menu?

FoldingBlockComment

@mark-wiemer
Copy link
Owner

I saw your commit to cweijan's repo, and I appreciate the contribution! I plan to review the changes he's made and merge them into mine, including the removal of the anchors that you mentioned. Folding block comments are definitely important to me, and I think I can do even better than the implementation you've shown in your screenshot. Instead of:

/* ;region
line one
line two
*/ ;endregion

How about:

/*
line one
line two
*/

And the above comment is foldable?

@FuPeiJiang
Copy link

what extension are you using to make block comments foldable ?
currently I'm using this (toggle line comments):
https://stackoverflow.com/questions/60334430/shortcut-to-toggle-commented-and-uncommented-code-at-the-same-time#60366506

@mark-wiemer mark-wiemer added this to the December 2020 milestone Dec 14, 2020
@fade2gray
Copy link
Author

@mark-wiemer

I saw your commit to cweijan's repo, and I appreciate the contribution!

I made a further commit here. I edited the RegEx's like so...

"start": "^(\\/\\*)?\\s*\\;\\s*region\\b",
"end": "^(\\*\\/)?\\s*\\;\\s*endregion\\b"

How about:

/*
line one
line two
*/

And the above comment is foldable?

Yes, just like in Notepad++ and similar editors.

This is a folding 'helper' script I devised.

@FuPeiJiang
Copy link

@fade2gray
Copy link
Author

@FuPeiJiang Yes, thanks for that. I didn't reply there because it says not to leave comments just to say "thanks". Now, with my extremely limited experience with creating extensions, I need to try and implement your code suggestion.

Thanks again. 👍

@FuPeiJiang
Copy link

I think you already solved it using ahk ? did you ?

https://code.visualstudio.com/api/get-started/your-first-extension
yo code
I choose javascript extension because it is faster than typescript to test
on the left, in debug, click the green button
image

image
and then
ctrl+shift+p to run a command, the command name defaults to "Hello World"

idk yet how to edit file using vscode, how to copy to clipboard

@FuPeiJiang
Copy link

using ahk, if you want to block comment lines without selecting the full line, (without selecting start of line, without selecting end of line)

f1::
sleep, 50
mass:=getClip()
send, +{home}
left:=getClip()
send, +{end}
right:=getClip()
finalstr:=";region `r`n" left mass right "`r`n;endregion"
clipboard:=finalstr

send, ^v

arr:=StrSplit(finalstr,"`n", "`r")
loop % arr.Length() - 1 {
    send, {up}
}
send, {home}
loop 8
send,{right}
return
; Reload

getClip()
{
    clipboard:=""
    Send, {ctrl down}x{ctrl up}
    sleep, 50
return clipboard
}

@mark-wiemer
Copy link
Owner

Closed by #27

@mark-wiemer mark-wiemer added the enhancement new feature or request label Feb 25, 2021
@mark-wiemer mark-wiemer changed the title Question: Can AHK++ be made to determine the editors cursor postion? Add foldable region comments Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new feature or request
Projects
No open projects
Development

No branches or pull requests

3 participants