<commit_before>#include "kwm.h"

static const CGKeyCode kVK_SPECIAL_Å = 0x21;
static const CGKeyCode kVK_SPECIAL_Ø = 0x29;
static const CGKeyCode kVK_SPECIAL_Æ = 0x27;

extern "C" KWM_KEY_REMAP(RemapKeys)
{
    *Result = -1;

    /*
    if(*CmdKey && *AltKey && *CtrlKey)
    {
    }

    switch(Keycode)
    {
        case kVK_ANSI_A:
        {
            *Result = kVK_ANSI_S;
        } break;
    }
    */
}

extern "C" KWM_HOTKEY_COMMANDS(KWMHotkeyCommands)
{
    bool Result = true;
    if(CmdKey && AltKey && CtrlKey)
    {
        switch(Keycode)
        {
            case kVK_ANSI_T:
            {
                if(EX->KwmFocusMode == FocusFollowsMouse)
                {
                    EX->KwmFocusMode = FocusAutoraise;
                    DEBUG("KwmFocusMode: Autoraise")
                }
                else if(EX->KwmFocusMode == FocusAutoraise)
                {
                    EX->KwmFocusMode = FocusDisabled;
                    DEBUG("KwmFocusMode: Disabled")
                }
                else if(EX->KwmFocusMode == FocusDisabled)
                {
                    EX->KwmFocusMode = FocusFollowsMouse;
                    DEBUG("KwmFocusMode: Focus-follows-mouse")
                }
            } break;
            case kVK_ANSI_M:
            {
                EX->MarkWindowContainer();
            } break;
            case kVK_ANSI_W:
            {
                bool Found = false;
                for(int Index = 0; Index < EX->FloatingWindowLst.size(); ++Index)
                {
                    if(EX->FloatingWindowLst[Index] == EX->FocusedWindow->WID)
                    {
                        EX->FloatingWindowLst.erase(EX->FloatingWindowLst.begin() + Index);
                        Found = true;
                        EX->KwmFocusMode = FocusAutoraise;
                        EX->AddWindowToTree();
                        break;
                    }
                }

                if(!Found)
                {
                    EX->FloatingWindowLst.push_back(EX->FocusedWindow->WID);
                    EX->KwmFocusMode = FocusFollowsMouse;
                    EX->RemoveWindowFromTree();
                }
            } break;
            case kVK_ANSI_Q:
            {
                EX->KwmRestart();
            } break;
            case kVK_ANSI_7:
            {
                EX->KwmSplitMode = 1;
            } break;
            case kVK_ANSI_Slash:
            {
                EX->KwmSplitMode = 2;
            } break;
            default:
            {
                Result = false;
            } break;
        }
    }
    else
    {
        Result = false;
    }

    return Result;
}

extern "C" KWM_HOTKEY_COMMANDS(SystemHotkeyCommands)
{
    bool Result = true;
    if (CmdKey && !CtrlKey && !AltKey)
    {
        switch(Keycode)
        {
            // Spotlight fix
            case kVK_Space:
            {
                //EX->KwmFocusMode = FocusAutoraise;
            } break;
            default:
            {
                Result = false;
            } break;
        }
    }
    else
    {
        Result = false;
    }

    return Result;
}

extern "C" KWM_HOTKEY_COMMANDS(CustomHotkeyCommands)
{
    bool Result = true;
    if(CmdKey && AltKey && CtrlKey)
    {
        // Launch Application
        std::string SysCommand = "";
        switch(Keycode)
        {
            // Open New iTerm Window
            case kVK_Return:
            {
                SysCommand = "/Applications/iTerm.app/Contents/MacOS/iTerm2 --new-window &";
            } break;
            // Rebuild Hotkeys
            case kVK_ANSI_R:
            {
                SysCommand = "sh " + EX->KwmFilePath + "/sobuild.sh";
            } break;
            // YTD - Media Player Controls
            case kVK_ANSI_Z:
            {
                SysCommand = "ytc prev";
            } break;
            case kVK_ANSI_X:
            {
                SysCommand = "ytc play";
            } break;
            case kVK_ANSI_C:
            {<commit_msg>resize window to container size on cmd-alt-ctrl+r<commit_after>#include "kwm.h"

static const CGKeyCode kVK_SPECIAL_Å = 0x21;
static const CGKeyCode kVK_SPECIAL_Ø = 0x29;
static const CGKeyCode kVK_SPECIAL_Æ = 0x27;

extern "C" KWM_KEY_REMAP(RemapKeys)
{
    *Result = -1;

    /*
    if(*CmdKey && *AltKey && *CtrlKey)
    {
    }

    switch(Keycode)
    {
        case kVK_ANSI_A:
        {
            *Result = kVK_ANSI_S;
        } break;
    }
    */
}

extern "C" KWM_HOTKEY_COMMANDS(KWMHotkeyCommands)
{
    bool Result = true;
    if(CmdKey && AltKey && CtrlKey)
    {
        switch(Keycode)
        {
            case kVK_ANSI_T:
            {
                if(EX->KwmFocusMode == FocusFollowsMouse)
                {
                    EX->KwmFocusMode = FocusAutoraise;
                    DEBUG("KwmFocusMode: Autoraise")
                }
                else if(EX->KwmFocusMode == FocusAutoraise)
                {
                    EX->KwmFocusMode = FocusDisabled;
                    DEBUG("KwmFocusMode: Disabled")
                }
                else if(EX->KwmFocusMode == FocusDisabled)
                {
                    EX->KwmFocusMode = FocusFollowsMouse;
                    DEBUG("KwmFocusMode: Focus-follows-mouse")
                }
            } break;
            case kVK_ANSI_M:
            {
                EX->MarkWindowContainer();
            } break;
            case kVK_ANSI_W:
            {
                bool Found = false;
                for(int Index = 0; Index < EX->FloatingWindowLst.size(); ++Index)
                {
                    if(EX->FloatingWindowLst[Index] == EX->FocusedWindow->WID)
                    {
                        EX->FloatingWindowLst.erase(EX->FloatingWindowLst.begin() + Index);
                        Found = true;
                        EX->KwmFocusMode = FocusAutoraise;
                        EX->AddWindowToTree();
                        break;
                    }
                }

                if(!Found)
                {
                    EX->FloatingWindowLst.push_back(EX->FocusedWindow->WID);
                    EX->KwmFocusMode = FocusFollowsMouse;
                    EX->RemoveWindowFromTree();
                }
            } break;
            case kVK_ANSI_R:
            {
                EX->ResizeWindowToContainerSize();
            } break;
            case kVK_ANSI_Q:
            {
                EX->KwmRestart();
            } break;
            case kVK_ANSI_7:
            {
                EX->KwmSplitMode = 1;
            } break;
            case kVK_ANSI_Slash:
            {
                EX->KwmSplitMode = 2;
            } break;
            default:
            {
                Result = false;
            } break;
        }
    }
    else
    {
        Result = false;
    }

    return Result;
}

extern "C" KWM_HOTKEY_COMMANDS(SystemHotkeyCommands)
{
    bool Result = true;
    if (CmdKey && !CtrlKey && !AltKey)
    {
        switch(Keycode)
        {
            // Spotlight fix
            case kVK_Space:
            {
                //EX->KwmFocusMode = FocusAutoraise;
            } break;
            default:
            {
                Result = false;
            } break;
        }
    }
    else
    {
        Result = false;
    }

    return Result;
}

extern "C" KWM_HOTKEY_COMMANDS(CustomHotkeyCommands)
{
    bool Result = true;
    if(CmdKey && AltKey && CtrlKey)
    {
        // Launch Application
        std::string SysCommand = "";
        switch(Keycode)
        {
            // Open New iTerm Window
            case kVK_Return:
            {
                SysCommand = "/Applications/iTerm.app/Contents/MacOS/iTerm2 --new-window &";
            } break;
            // Rebuild Hotkeys
            // case kVK_ANSI_R:
            // {
            //     SysCommand = "sh " + EX->KwmFilePath + "/sobuild.sh";
            // } break;
            // YTD - Media Player Controls
            case kVK_ANSI_Z:
            {
                SysCommand = "ytc prev";
            } break;
            case kVK_ANSI_X:
            {
                SysCommand = "ytc play";
            } break;
            case kVK_ANSI_C:
            {
{'fraction_non_alphanumeric': 0.0950768114188944, 'fraction_numerical': 0.00362888593201887, 'mean_word_length': 1.065967016491754, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3565712', 'n_tokens_mistral': 2540, 'n_tokens_neox': 2408, 'n_words': 402}