Inline Ctrl - 1 and Ctrl -2.

Forums for specific tips, techniques and example code
User avatar
Dr Danyo
Posts: 56
Joined: Fri Aug 21, 2009 8:59 am

Inline Ctrl - 1 and Ctrl -2.

Postby Dr Danyo » Wed Feb 09, 2011 6:34 am

Something I've just started using is;

Rather than switching to Ctrl 1 and Ctrl 2 when typing to pull up the properties / methods list, if you are an autohotkeys user http://www.autohotkey.com/ the following script will allow you to pull up the list by using a double "," character for properties or a double "." for methods.

Take a look and let me know what you think (or if you have any improvements.

Code: Select all

#ifWinActive JADE ,:: if (A_PriorHotkey = "," and A_TimeSincePriorHotkey < 400) { Send, {Left} Send, {Delete} Send, ^1 return } else { Send, {,} return } .:: if (A_PriorHotkey = "." and A_TimeSincePriorHotkey < 400) { Send, {Left} Send, {Delete} Send, ^2 return } else { Send, {.} return }
Dr Danyo.

User avatar
andy-b
Posts: 24
Joined: Mon Jul 05, 2010 2:00 pm
Location: Dunedin, NZ

Re: Inline Ctrl - 1 and Ctrl -2.

Postby andy-b » Thu Mar 03, 2011 8:08 am

Nice one. I have downloaded autohotkeys and am using this now. Since I have moved from Visual Studio to Jade I do miss the automatic intelisense and have only recently gotten used to pressing ctrl-1, ctrl-2 etc.
This will go some way to make my life easier :D

I have also added a section to your script to show the constants list if you perform a double "?" (I initially set this up to be a double "/" but of course this interferes with adding comments :oops: )

Code: Select all

?:: if (A_PriorHotkey = "?" and A_TimeSincePriorHotkey < 400) { Send, {Left} Send, {Delete} Send, ^3 return } else { Send, {?} return }

User avatar
Dr Danyo
Posts: 56
Joined: Fri Aug 21, 2009 8:59 am

Re: Inline Ctrl - 1 and Ctrl -2.

Postby Dr Danyo » Thu Mar 03, 2011 10:05 pm

Thanks Andy, that is a good addition (I've just added it to my script file).

I've recently also been working on a couple of refactors you might be interested in.

Ctrl # will take the selected text and create a variable for you

^#::
Variable =
clipboard =
NewClipBoard =
Send, ^c
ClipWait, 1
Variable = vars`r`n%A_Tab%%clipboard%
Send, ^a
Send, ^c
ClipWait, 1
InputBox, Type, Add Variable, Enter the JADE primivite type to use, 0, 250
If ErrorLevel
{
Send, {Right}
Return
}
StringUpper, Type, Type, T
StringReplace, NewClipboard, clipboard, vars, %Variable%%A_Tab%: %Type%;
clipboard = %NewClipboard%
Send, ^v
return

and Ctrl ; will try to extract the selected text into a new method on the same class.

^;::
; HotKey to extract method from selected text
NewMethodName =
Clipboard =
Send, ^x
ClipWait, 1
InputBox, NewMethodName, Extract Method, Enter the new method name, 0, 250
If ErrorLevel
{
Send, ^v
Return
}
Send self.%NewMethodName%();
Send {F2}
Send {Alt}M
Send J
Send %NewMethodName%
Send {Enter}
Send ^{End}
Send {Up 2}
Send {Tab}
Send ^v
Send {F8}
return

User avatar
andy-b
Posts: 24
Joined: Mon Jul 05, 2010 2:00 pm
Location: Dunedin, NZ

Re: Inline Ctrl - 1 and Ctrl -2.

Postby andy-b » Fri Mar 04, 2011 7:57 am

Ohh yes I like the create variable one :)

I am playing around with another hotkey, I am not sure if it will be more of a help or a hindrance but will trial it and see how it goes.

Pressing "(" will bring up the method signature tooltip.

Code: Select all

(:: Send, {(} Send, ^5 return
I thought this could get annoying with having to press escape to remove the tooltip, especially for methods with no parameters.
So also when pressing ")" will automatically close the tooltip for you.

Code: Select all

):: Send, {)} Send, {Esc} return
Of course this way also tries to perform a ctrl-5 wherever you type a "(", in comments etc.
I was thinking another option would be that a double "(" could trigger the tooltip if this way was a bit of overkill, but I prefer to type naturally and have the hotkeys support as much as possible.

User avatar
Dr Danyo
Posts: 56
Joined: Fri Aug 21, 2009 8:59 am

Re: Inline Ctrl - 1 and Ctrl -2.

Postby Dr Danyo » Fri Mar 04, 2011 8:29 pm

Cool, here is what I use for (

Basically it auto completed the ); displays the signature and returns you to within the first ( character.

~Shift & 9::
{
Send, {(}
Send, {)}
Send, {;}
Send, {LEFT 2}
Send, ^5
return
}

User avatar
BeeJay
Posts: 312
Joined: Tue Jun 30, 2009 2:42 pm
Location: Christchurch, NZ

Re: Inline Ctrl - 1 and Ctrl -2.

Postby BeeJay » Fri Mar 09, 2012 8:19 pm

Is this now somewhat obsolete with the new & improved AutoComplete feature in Jade 7? ;)

Cheers,
BeeJay.


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 1 guest

cron