4coder»Forums
Charly Mourglia
5 posts
None
Weird indentation out of 4coder (4.0.13)
Although I get a perfectly fine indentation in 4coder, I get weird stuff when opening a file outside of it.

For example, when I have

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
LRESULT CALLBACK win32_MainWindowCallback(HWND hwnd,
                                          UINT message,
                                          WPARAM wParam,
                                          LPARAM lParam)
{
    LRESULT result = 0;
    
    switch (message)
    {
        case WM_SIZE:
        {
        } break;
        
        case WM_DESTROY:
        {
            g_Running = false;
        } break;
        
        case WM_CLOSE:
        {
            g_Running = false;
        } break;
        
        case WM_ACTIVATEAPP:
        {
        } break;
        
        case WM_SYSKEYDOWN:
        case WM_SYSKEYUP:
        case WM_KEYDOWN:
        case WM_KEYUP:
        {
            uint32 vkCode = wParam;
            bool32 wasDown = ((lParam & (1 << 30)) != 0);
            bool32 isDown = ((lParam & (1 << 31)) == 0);
            
            if (isDown != wasDown)
            {
                if (vkCode == VK_ESCAPE)
                {
                    g_Running = false;
                }
            }
        } break;
        
        default:
        {
            result = DefWindowProc(hwnd, message, wParam, lParam);
        }
    }
    
    return result;
}


here is the result when opening it in visual :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
LRESULT CALLBACK win32_MainWindowCallback(HWND hwnd,
                                      UINT message,
                                      WPARAM wParam,
                                      LPARAM lParam)
{
    LRESULT result = 0;
    
    switch (message)
    {
        case WM_SIZE:
        {
        } break;
        
        case WM_DESTROY:
        {
            g_Running = false;
        } break;
        
        case WM_CLOSE:
        {
            g_Running = false;
        } break;
        
        case WM_ACTIVATEAPP:
        {
        } break;
        
        case WM_SYSKEYDOWN:
        case WM_SYSKEYUP:
        case WM_KEYDOWN:
        case WM_KEYUP:
        {
            uint32 vkCode = wParam;
            bool32 wasDown = ((lParam & (1 << 30)) != 0);
            bool32 isDown = ((lParam & (1 << 31)) == 0);
            
            if (isDown != wasDown)
            {
                if (vkCode == VK_ESCAPE)
                {
                    g_Running = false;
        }
    }
} break;
        
        default:
        {
            result = DefWindowProc(hwnd, message, wParam, lParam);
        }
    }
    
    return result;
}


BTW, when re-openning the file in 4coder I do not get proper indententation on function parameters
1
2
3
4
5
6
7
8
9
int CALLBACK WinMain(HINSTANCE instance,
    HINSTANCE prevInstance, 
    LPSTR cmdLine,
    int cmdShow)
{
    HWND window = CreateWindowExA(0,
                        wc.lpszClassName,
                        ...);
}


Anything I should change to 4coder_auto_indent.cpp to make this work properly ?
Thanks !
Allen Webster
476 posts / 6 projects
Heyo
Weird indentation out of 4coder (4.0.13)
This is because of the way 4coder is separating actual whitespace from rendered whitespace. In the next few versions I plan to make tweaks so this issue won't be such an issue. In the mean time, you have two options. Either you can turn off virtual whitespace and line wrapping on your buffers, then you will be back to the old system of direct text indentation, OR you can set up your save command to auto-indent the text on save.