Page 1 of 2

online converter: converts your autohotkey code into pretty indented source code.

Posted: 11 Jul 2015, 07:40
by SL5
:wave: online converter for converting your autohotkey code into pretty indented source code.
free no registration needed.

do you like it? please leave feedback :think:

http://sl5.it/SL5_preg_contentFinder/ex ... e_code.php

Re: online converter: converts your autohotkey code into pretty indented source code.

Posted: 11 Jul 2015, 10:35
by joedf
Very nice, AutoHotkey prettify :)

Re: online converter: converts your autohotkey code into pretty indented source code.

Posted: 14 Jul 2015, 13:57
by SL5
joedf wrote:Very nice, AutoHotkey prettify :)
Thanks makes me happy :P

BTW its Lite (online) Version of (offline) https://github.com/sl5net/SL5_AHK_Refac ... ce.php#L60
So if you want try this by yourself :shh: no prob

Re: online converter: converts your autohotkey code into pretty indented source code.

Posted: 14 Jul 2015, 15:08
by joedf
Oh cool haha, I'll try out this real soon :)

Re: online converter: converts your autohotkey code into pretty indented source code.

Posted: 15 Jul 2015, 00:57
by jNizM
Cool cool...

My suggestions:

- Add braces option (braces with control statement / braces on own line)

Code: Select all

while (x = y) {
    something()
    somethingelse()
}

Code: Select all

while (x = y)
{
    something()
    somethingelse()
}
- Space / Tab intent (2, 3, 4 spaces or 1 tab)
- Space before conditional: if(x) / if (x)

Like the JavaScript beautifier I use

Re: online converter: converts your autohotkey code into pretty indented source code.

Posted: 15 Jul 2015, 15:01
by SL5
.

Re: online converter: converts your autohotkey code into pretty indented source code.

Posted: 16 Jul 2015, 16:47
by SL5
have added two new Style. Two of the three seem to work pretty stablil. I have switched the style SL5net_small_v0.1 as standard for the offline version. next days i need care of another programming language. See you soon!

results:
http://sl5.it/SL5_preg_contentFinder/ex ... e_code.php

Code: Select all

; thats SL5net_small Version 0.1 Indent-Style
if(doIt)
{
    if(doIt)
    {
        if ( next )
            Check
        else
            Check = 5
        if ( next )
        {
            Send,5b{Right 5}
        }}}

Code: Select all

; thats SL5net_small+ NotRecommended Indent-Style
if(doIt){
    if(doIt){
        if ( next )Check
        else
            Check = 5
        if ( next ){
            Send,5b{Right 5}
        }}}
(hopefully also soon visible inside wikipedia: https://de.wikipedia.org/w/index.php?ti ... small-Stil )

Code: Select all

; thats free Indent-Style - like SL5net_small it dosent change the signature or body begin. your free to do it manually ;)
if(doIt)
{
    if(doIt)
    {
        if ( next )
            Check
        else
            Check = 5
        if ( next )
        {
            Send,5b{Right 5}
        }
    }
}
In addition, you can now adjust indentation and switch between space and tab. In addition, your form data is stored on your computer with garlic.js, so you do not need make every new settings.

Re: online converter: converts your autohotkey code into pretty indented source code.

Posted: 13 Nov 2016, 16:11
by samzz
Hello,
Very nice tool SL5. I used it to indent the source code of my old script.exe. I extracted the flat/raw code source (not comment, no indentation) with Resource Hacker http://www.angusj.com/resourcehacker/. Just a comment about the result of this tool:
The line command (just) after this IF test is indented, so it's fine.

Code: Select all

If (0<Ct)
But the line (just) after this IF test is not indented, and it should be indented. I guess because the test contains parenthesis and/or quotes.

Code: Select all

If (0<InStr(LisO,Labl . "/"))
Is it possible to download this tool to use it offline? How?
Maybe you can fix this "bug". Thanks in advance and regards.
sam

Re: online converter: converts your autohotkey code into pretty indented source code.

Posted: 13 Nov 2016, 17:00
by SL5
samzz wrote: ...
Is it possible to download this tool to use it offline? How?
Maybe you can fix this "bug". Thanks in advance and regards.
sam
download it here: https://github.com/sl5net/SL5_preg_cont ... Source.php

of use eventually (slightly different) for e.g. use STRG + SHIFT + L
with https://github.com/sl5net/SL5_AHK_Refactor_engine

Re: online converter: converts your autohotkey code into pretty indented source code.

Posted: 21 Apr 2018, 21:37
by SL5
if you want to simulate this similar or slightly different. This is the abridged version of the core PHP source code. the main responsible part (from https://github.com/sl5net/SL5_preg_cont ... Source.php ).

Code: Select all

<?php
include_once("SL5_preg_contentFinder.php");
.....
$cf = new SL5_preg_contentFinder($file_content);
$cf->setBeginEnd_RegEx($old_open, $old_close);
$cf->setSearchMode('dontTouchThis');

$actual = $cf->getContent_user_func_recursive(

    function ($cut, $deepCount, $callsCount, $posList0, $source1) use ($conf, $arguments, $new_open_default, $new_close_default, $charSpace, $newline, $indentSize, $getIndentStr) {
        if ($cut['middle'] === false) return $cut;
        $indentStr = $getIndentStr(1, $charSpace, $indentSize);

        if (!isset($posList0['begin_end'])) $posList0['begin_end'] = strlen($source1);

        $start = '' . substr($source1, $posList0['begin_begin'], $posList0['begin_end'] - $posList0['begin_begin']) . '';
        $end = '' . ltrim(substr($source1, $posList0['end_begin'], $posList0['end_end'] - $posList0['end_begin'])) . '';

        if ($conf['noNewlineAtEnd']) {
            $doNoNewlineAtEnd = preg_match("/\W[}\s]*\}\R*$/ms", $cut['middle'], $m);
            if ($doNoNewlineAtEnd) 
                $cut['middle'] = rtrim($cut['middle']) . '';
        }
        $cut['middle'] = implode($newline . '' . $indentStr, preg_split("/(\R)/m", $cut['middle']));

        $cut['middle'] = '' . rtrim($start) . '' . $newline . '' .
            $indentStr . '' . trim($cut['middle']) . '';
        if ($conf['noNewlineAtEnd'] && $doNoNewlineAtEnd) {
            $cut['middle'] .= $end . '' . $cut['behind'] . '';
        } else {
            $cut['middle'] .= $newline . '' . $end . '' . $cut['behind'] . '';
        }
        return $cut;
    });

Re: online converter: converts your autohotkey code into pretty indented source code.

Posted: 04 Jan 2021, 07:26
by MarcelDeZaadcel
SL5 wrote:
11 Jul 2015, 07:40
:wave: online converter for converting your autohotkey code into pretty indented source code.
free no registration needed.

do you like it? please leave feedback :think:

http://sl5.it/SL5_preg_contentFinder/examples/AutoHotKey/converts_your_autohotkey_code_into_pretty_indented_source_code.php

Some bugs when adjusting "{"

Re: online converter: converts your autohotkey code into pretty indented source code.

Posted: 31 Mar 2021, 12:31
by Chunjee
What needs to happen to get this working inside VisualStudioCode?

I put a checkmark on "use Tab for indent?" but it still uses spaces.

Re: online converter: converts your autohotkey code into pretty indented source code.

Posted: 31 Mar 2021, 13:28
by joedf
@Chunjee
It looks like that's just the preview? :think:
The "Pretty indented code" seems to have tab characters when enabled.

Re: online converter: converts your autohotkey code into pretty indented source code.

Posted: 06 Nov 2021, 09:43
by BrockPlaysFortnite
Cool!

Re: online converter: converts your autohotkey code into pretty indented source code.

Posted: 24 Nov 2021, 05:08
by lancelot
Seems buggy to me - I use the http://hilite.me/ one because this one always messes up my code. I am guessing it's one of those tools that used to work and doesn't anymore?

Re: online converter: converts your autohotkey code into pretty indented source code.

Posted: 28 Feb 2022, 12:53
by UserNameForAH_Board
hilite.me converts code into . . HTML.

Re: online converter: converts your autohotkey code into pretty indented source code.

Posted: 28 Feb 2022, 12:59
by UserNameForAH_Board
But I find that there is this web tool, called (perhaps) 'SL5', and which uses, er, a tool that seems written for another language. Except, er: I find also that the web tool mangles my Autohotkey code!

Re: online converter: converts your autohotkey code into pretty indented source code.

Posted: 28 Feb 2022, 13:24
by lancelot
UserNameForAH_Board wrote:
28 Feb 2022, 12:53
hilite.me converts code into . . HTML.
sort of - you're missing the point - if you look at the preview instead of the code it's formatted your line breaks and indentations

Re: online converter: converts your autohotkey code into pretty indented source code.

Posted: 10 Sep 2022, 01:07
by jmuhammad
Greetings SL5,
First, thanks for writing AHK Prettyfy;
Second, how can I set the ELSE statements to be followed by curly brackets on their own line (Allman Indentation style)?

Like from:

Code: Select all

If (...)
{
  ;Statement
}else  {
  ;Statement
}
to this:

Code: Select all

If (...)
{
  ;Statement
}
else
{
  ;Statement
}

Re: online converter: converts your autohotkey code into pretty indented source code.

Posted: 13 Sep 2022, 01:57
by thqby
image.png
image.png (80.02 KiB) Viewed 5321 times
For AHK2, you can do this by using VSCode Web and setting the formatter option one_true_brace to false.