Page 1 of 1
Reformat whole source
Posted: Fri Jul 26, 2013 1:52 pm
by blueznl
Silly question, I know there's CTRL+I, but is there also a shortcut that will reformat the whole source at once?
Saves a bit of selecting, CTRL+I, etcetera.
Re: Reformat whole source
Posted: Fri Jul 26, 2013 1:55 pm
by PB
Ctrl+A followed by Ctrl+I ?

Re: Reformat whole source
Posted: Fri Jul 26, 2013 2:40 pm
by Crusiatus Black
PB wrote:Ctrl+A followed by Ctrl+I ?

ikr

Re: Reformat whole source
Posted: Fri Jul 26, 2013 3:07 pm
by blueznl
Yeah, i know. But... that's multiple keystrokes, moves my cursor to a different line, and selects all. I often use reformat to keep track of my work (ie. I use CodeCaddy then hit Alt+r, and keep on working in the same area). By reformatting I can quickly spot if I missed a few EndIf's etcetera.
I know it's a matter of taste and workflow

I was just wondering if there was a single key without having to select anything.
Re: Reformat whole source
Posted: Fri Jul 26, 2013 3:30 pm
by davido
I, too, wouldn't mind a single key solution.
For now I use:
Hold control key and press: f2 a i
Release the control-key and press: f2
It is really very quick and I'm always less than half a screen away from where I was.
Re: Reformat whole source
Posted: Fri Jul 26, 2013 3:37 pm
by IdeasVacuum
It's a small limitation of the IDE really (as it is in many IDEs, including VS). I write my code using UltraEdit, formating on-the-fly with the wonderful column mode.
Re: Reformat whole source
Posted: Fri Jul 26, 2013 3:53 pm
by blueznl
davido wrote:I, too, wouldn't mind a single key solution.
For now I use:
Hold control key and press: f2 a i
Release the control-key and press: f2
It is really very quick and I'm always less than half a screen away from where I was.
That's close to what I want, now we only have to convince the developers to give us a one key reformat

Re: Reformat whole source
Posted: Fri Jul 26, 2013 4:23 pm
by davido
Would it, perhaps, be possible to make a built-in tool to do that?
That is, unfortunately, way, way beyond my capability.

Re: Reformat whole source
Posted: Fri Jul 26, 2013 5:44 pm
by Little John
davido wrote:Would it, perhaps, be possible to make a built-in tool to do that?
A least on Windows, it's not hard to do so.
a) Get some good code for sending keystrokes:
I recommend the
AutoWin library by ts-soft, with improvements by me.
b) Write your own versatile generic Sendkeys program in 2 lines:
Code: Select all
XIncludeFile <Path> + "AutoWin_Include.pbi"
AW_SendKeys(ProgramParameter(0))
and compile it to an EXE file.
c) PB IDE > Tools > Configue tools > New:
Commandline:
<Path>\SendKeys.exe
Arguments:
"{CONTROLDOWN}{F2}ai{CONTROLUP}{DELAY 100}{F2}"
Name:
Reformat whole source
Event to trigger the tool:
Menu Or Shortcut
Note: Some delay before sending the second {F2} seems to be crucial. 100 ms is fine on my system, on other systems other values might be appropriate.
Re: Reformat whole source
Posted: Fri Jul 26, 2013 6:10 pm
by davido
Thank you, Little John. You make it look so
simple!
I'll have a good look at that.
Re: Reformat whole source
Posted: Sat Jul 27, 2013 2:07 am
by PB
> By reformatting I can quickly spot if I missed a few EndIf's etcetera.
If that's all you're worried about, then you do know the IDE has two
features to prevent that: matching keyword colors, and the line that
gets drawn between If/EndIf so you can see if any are mismatched.
Re: Reformat whole source
Posted: Sat Jul 27, 2013 9:10 am
by TI-994A
Personally, I use
AutoHotkey. It is configured via a simple text script and can automate single commands and even paragraphs. It's become an indispensable tool for me, automatically generating standard procedures, code blocks, and event loops at the press of a single key. For example, this entry in the script:
Code: Select all
F12::
Send {Raw} Enumeration
Send {Enter}
Send {Raw} #MainWindow
Send {Enter}
Send {Raw} EndEnumeration
Send {Enter 2}
Send {Raw} wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
Send {Enter}
Send {Raw} OpenWindow(#MainWindow, #PB_Any, #PB_Any, 640, 480, "<Title>", wFlags)
Send {Enter 2}
Send {Raw} While WaitWindowEvent() ! #PB_Event_CloseWindow: CloseWindow: Wend
will generate this code block at a single touch of the
F12 key:
Code: Select all
Enumeration
#MainWindow
EndEnumeration
wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(#MainWindow, #PB_Any, #PB_Any, 640, 480, "<Title>", wFlags)
While WaitWindowEvent() ! #PB_Event_CloseWindow : CloseWindow :Wend
Every keystroke counts. 
Re: Reformat whole source
Posted: Sat Jul 27, 2013 9:23 am
by Little John
Hi TI-994A,
I just thought that it might be more fun and more self-contained to compile a
SendKeys program ourselves with PB.
However, I agree that AutoHotkey is a great tool which can be used very effectively and flexible.