Reformat whole source
Reformat whole source
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.
Saves a bit of selecting, CTRL+I, etcetera.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: Reformat whole source
Ctrl+A followed by Ctrl+I ? 

I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
- Crusiatus Black
- Enthusiast
- Posts: 389
- Joined: Mon May 12, 2008 1:25 pm
- Location: The Netherlands
- Contact:
Re: Reformat whole source
ikrPB wrote:Ctrl+A followed by Ctrl+I ?

Re: Reformat whole source
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.
I know it's a matter of taste and workflow

( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: Reformat whole source
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.
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.
DE AA EB
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Reformat whole source
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.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Reformat whole source
That's close to what I want, now we only have to convince the developers to give us a one key reformatdavido 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.

( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: Reformat whole source
Would it, perhaps, be possible to make a built-in tool to do that?
That is, unfortunately, way, way beyond my capability.
That is, unfortunately, way, way beyond my capability.

DE AA EB
-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Reformat whole source
A least on Windows, it's not hard to do so.davido wrote:Would it, perhaps, be possible to make a built-in tool to do that?
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))
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
Thank you, Little John. You make it look so simple!
I'll have a good look at that.

I'll have a good look at that.
DE AA EB
Re: Reformat whole source
> 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.
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.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Re: Reformat whole source
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:
will generate this code block at a single touch of the F12 key:
Every keystroke counts. 
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
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

Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 

-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Reformat whole source
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.
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.