Full Code of lesderid/keynavish for AI

master 7695a31c73a5 cached
25 files
116.2 KB
30.2k tokens
1 requests
Download .txt
Repository: lesderid/keynavish
Branch: master
Commit: 7695a31c73a5
Files: 25
Total size: 116.2 KB

Directory structure:
gitextract_zeup618b/

├── .gitattributes
├── .github/
│   ├── FUNDING.yml
│   └── workflows/
│       ├── cd.yml
│       └── ci.yml
├── .gitignore
├── LICENSE
├── README.md
├── dub.sdl
├── generate-version-info.bat
├── keynavish.sln
├── keynavish.visualdproj
├── keynavrc
├── src/
│   └── keynavish/
│       ├── commands.d
│       ├── config.d
│       ├── errorhandling.d
│       ├── grid.d
│       ├── helpers.d
│       ├── keyboardinput.d
│       ├── main.d
│       ├── notifyicon.d
│       ├── package.d
│       ├── recording.d
│       └── window.d
└── tools/
    ├── LICENSE.LLVM
    └── README.md

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitattributes
================================================
*keynavrc* text eol=crlf


================================================
FILE: .github/FUNDING.yml
================================================
github: [lesderid]
ko_fi: les
custom: ['https://paypal.me/les']


================================================
FILE: .github/workflows/cd.yml
================================================
name: CD

on:
  push:
    tags:
    - 'v*'

jobs:
  build:
    runs-on: windows-latest
    steps:
      - name: Checkout keynavish
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Install dmd and dub
        uses: dlang-community/setup-dlang@v1
        with:
          compiler: dmd-2.100.2
      - name: Build keynavish (x86_64)
        run: dub build -b=release -a=x86_64
      - name: Create release
        id: create-release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: ${{ github.ref }}
          draft: false
          prerelease: false
      - name: Get release version
        id: get-release-version
        uses: little-core-labs/get-git-tag@v3.0.1
      - name: Upload release asset (x86_64)
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create-release.outputs.upload_url }}
          asset_path: ./out/keynavish.exe
          asset_name: keynavish-${{ steps.get-release-version.outputs.tag }}-x86_64.exe
          asset_content_type: application/octet-stream
      - name: Build keynavish (x86)
        run: dub build -b=release -a=x86
      - name: Upload release asset (x86)
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create-release.outputs.upload_url }}
          asset_path: ./out/keynavish.exe
          asset_name: keynavish-${{ steps.get-release-version.outputs.tag }}-x86.exe
          asset_content_type: application/octet-stream


================================================
FILE: .github/workflows/ci.yml
================================================
name: CI

on: [push, pull_request]

jobs:
  build:
    runs-on: windows-latest

    steps:
        - name: Checkout keynavish
          uses: actions/checkout@v2
          with:
            fetch-depth: 0
        - name: Install dmd and dub
          uses: dlang-community/setup-dlang@v1
          with:
            compiler: dmd-latest
        - name: Build keynavish (x86_64)
          run: dub build -a=x86_64
        - name: Rename artifact
          run: Rename-Item -Path out/keynavish.exe -NewName "keynavish-${{ github.sha }}-x86_64.exe"
        - name: Upload keynavish (x86_64)
          uses: actions/upload-artifact@v4
          with:
            name: keynavish-${{ github.sha }}-x86_64
            path: out/keynavish-${{ github.sha }}-x86_64.exe


================================================
FILE: .gitignore
================================================
/Win32/
/x64/
/out/
/.vs/
/enc_temp_folder/
/.dub/
/src/keynavish/versioninfo.*


================================================
FILE: LICENSE
================================================
                    GNU GENERAL PUBLIC LICENSE
                       Version 2, June 1991

 Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The licenses for most software are designed to take away your
freedom to share and change it.  By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users.  This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it.  (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.)  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

  To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must show them these terms so they know their
rights.

  We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

  Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

  Finally, any free program is threatened constantly by software
patents.  We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary.  To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

  The precise terms and conditions for copying, distribution and
modification follow.

                    GNU GENERAL PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License.  The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language.  (Hereinafter, translation is included without limitation in
the term "modification".)  Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope.  The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

  1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

  2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

    a) You must cause the modified files to carry prominent notices
    stating that you changed the files and the date of any change.

    b) You must cause any work that you distribute or publish, that in
    whole or in part contains or is derived from the Program or any
    part thereof, to be licensed as a whole at no charge to all third
    parties under the terms of this License.

    c) If the modified program normally reads commands interactively
    when run, you must cause it, when started running for such
    interactive use in the most ordinary way, to print or display an
    announcement including an appropriate copyright notice and a
    notice that there is no warranty (or else, saying that you provide
    a warranty) and that users may redistribute the program under
    these conditions, and telling the user how to view a copy of this
    License.  (Exception: if the Program itself is interactive but
    does not normally print such an announcement, your work based on
    the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole.  If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works.  But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

  3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

    a) Accompany it with the complete corresponding machine-readable
    source code, which must be distributed under the terms of Sections
    1 and 2 above on a medium customarily used for software interchange; or,

    b) Accompany it with a written offer, valid for at least three
    years, to give any third party, for a charge no more than your
    cost of physically performing source distribution, a complete
    machine-readable copy of the corresponding source code, to be
    distributed under the terms of Sections 1 and 2 above on a medium
    customarily used for software interchange; or,

    c) Accompany it with the information you received as to the offer
    to distribute corresponding source code.  (This alternative is
    allowed only for noncommercial distribution and only if you
    received the program in object code or executable form with such
    an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it.  For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable.  However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

  4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License.  Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

  5. You are not required to accept this License, since you have not
signed it.  However, nothing else grants you permission to modify or
distribute the Program or its derivative works.  These actions are
prohibited by law if you do not accept this License.  Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

  6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions.  You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

  7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all.  For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices.  Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

  8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded.  In such case, this License incorporates
the limitation as if written in the body of this License.

  9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number.  If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation.  If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

  10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission.  For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this.  Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

                            NO WARRANTY

  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

    Gnomovision version 69, Copyright (C) year name of author
    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary.  Here is a sample; alter the names:

  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
  `Gnomovision' (which makes passes at compilers) written by James Hacker.

  <signature of Ty Coon>, 1 April 1989
  Ty Coon, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs.  If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.


================================================
FILE: README.md
================================================
# keynavish

[![Latest release](https://img.shields.io/github/v/release/lesderid/keynavish?sort=semver)](https://github.com/lesderid/keynavish/releases/latest)
[![CI build status](https://img.shields.io/github/actions/workflow/status/lesderid/keynavish/ci.yml)](https://github.com/lesderid/keynavish/actions?query=workflow%3ACI)
[![Compatibility issues](https://img.shields.io/github/issues/lesderid/keynavish/compatibility)](https://github.com/lesderid/keynavish/labels/compatibility)

Control the mouse with the keyboard, on Windows.

This is a rewrite of [keynav](https://github.com/jordansissel/keynav)
for Windows. It is fully compatible with the original (modulo
[bugs](https://github.com/lesderid/keynavish/labels/compatibility)),
so you can use the same configuration files for both programs.

keynavish works on Windows XP and later, but only versions of Windows
that still receive support from Microsoft (currently 8.1 and 10) are
officially supported.

## Demo

[![Demo](https://lesderid.net/keynavish-demo.gif)](https://lesderid.net/keynavish-demo.webm)

(click for full quality video)

## Installing

You can 'install' keynavish by downloading the [latest
release](https://github.com/lesderid/keynavish/releases/latest)
executable, running it, and selecting `Launch keynavish on startup` from
the notification icon context menu.

## Configuration

Configuration format: [keynav
documentation](https://github.com/jordansissel/keynav/blob/master/keynav.pod)

On startup, keynavish loads a set of
[default keybindings](https://github.com/lesderid/keynavish/blob/9cce3b7c8ae03791f8ef3aedcc3015bde2f8a054/src/keynavish/keyboardinput.d#L11-L51)
, and then tries
to load the following configuration files:

* `<executable path>/keynavrc` (for portability)
* `~/.keynavrc`
* `~/keynavrc`
* `~/.config/keynav/keynavrc`

Tildes (`~`) in paths are expanded to the value of `%HOME%` if it's set,
with fallback to `%USERPROFILE%` (usually `C:\Users\<username>`).

## Building

Install [dub](https://dub.pm/) and run `dub build`.

For development, using [VisualD](https://rainers.github.io/visuald/)
with the supplied solution file is recommended.

## Contributing

If you'd like to contribute, thank you! Please feel free to make a pull
request (or open an issue), but make sure that your contribution does
not break compatibility with keynav. In particular, any changes to the
configuration format that are not compatible with keynav will generally
be rejected.

## License

keynavish is licensed under the [GNU GPLv2](/LICENSE).

For commercial licensing or support, please [contact
me](https://lesderid.net).


================================================
FILE: dub.sdl
================================================
name "keynavish"
description "Control the mouse with the keyboard, on Windows."
authors "lesderid"
copyright "Copyright © 2021, Les De Ridder"
license "GPL-2.0"

preBuildCommands "generate-version-info.bat"

libs "User32" "Gdi32"
stringImportPaths "."

targetPath "out"

lflags "/SUBSYSTEM:WINDOWS"
sourceFiles "src/keynavish/versioninfo.res"


================================================
FILE: generate-version-info.bat
================================================
@ECHO OFF

REM
REM This file is a bit of a mess, suggestions for alternatives would be
REM much appreciated.
REM

SETLOCAL ENABLEDELAYEDEXPANSION

WHERE /q git

IF ERRORLEVEL 1 (
    ECHO Please install git in your PATH to generate version info.
    EXIT /B 1
) ELSE (
    FOR /F "delims=" %%i IN ('git describe --tags') DO (
        SET VERSION=%%i
        FOR /F "tokens=1,2,3,4 delims=.-" %%a IN ("!VERSION:v=!.0") DO SET WINVERSION=%%a,%%b,%%c,%%d

        ECHO /* This file is automatically generated on build! */ > src/keynavish/versioninfo.d
        ECHO[ >> src/keynavish/versioninfo.d
        ECHO module keynavish.versioninfo; >> src/keynavish/versioninfo.d
        ECHO[ >> src/keynavish/versioninfo.d
        ECHO enum gitVersion = "!VERSION!"; >> src/keynavish/versioninfo.d

        ECHO 1 VERSIONINFO ^

        FILEVERSION !WINVERSION! ^

        PRODUCTVERSION !WINVERSION! ^

        FILEOS 0x40004 ^

        FILETYPE 0x1 ^

        { ^

        BLOCK "StringFileInfo" ^

        { ^

        	BLOCK "040904B0" ^

        	{ ^

        		VALUE "FileDescription", "keynavish – Control the mouse with the keyboard, on Windows" ^

        		VALUE "InternalName", "keynavish.exe" ^

        		VALUE "OriginalFilename", "keynavish.exe" ^

        		VALUE "CompanyName", "Les De Ridder" ^

        		VALUE "LegalCopyright", "© 2021, Les De Ridder <les@lesderid.net>" ^

        		VALUE "ProductName", "keynavish" ^

        		VALUE "FileVersion", "!VERSION:v=!" ^

        		VALUE "ProductVersion", "!VERSION:v=!" ^

        	} ^

        } ^

         ^

        BLOCK "VarFileInfo" ^

        { ^

        	VALUE "Translation", 0x0409 0x04B0 ^

        } ^

        } > src/keynavish/versioninfo.rc

        ECHO Version info written to 'src/keynavish/versioninfo.{d,rc}'.
        .\tools\llvm-rc.exe /C 65001 src\keynavish\versioninfo.rc
        ECHO Converted 'src/keynavish/versioninfo.rc' to 'src/keynavish/versioninfo.res'.
    )
)

ENDLOCAL


================================================
FILE: keynavish.sln
================================================

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30804.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{002A2DE9-8BB6-484D-9802-7E4AD4084715}") = "keynavish", "keynavish.visualdproj", "{9C2A0942-A891-44EF-B55A-F0DBAAC311C1}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|x64 = Debug|x64
		Debug|x86 = Debug|x86
		Release|x64 = Release|x64
		Release|x86 = Release|x86
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{9C2A0942-A891-44EF-B55A-F0DBAAC311C1}.Debug|x64.ActiveCfg = Debug|x64
		{9C2A0942-A891-44EF-B55A-F0DBAAC311C1}.Debug|x64.Build.0 = Debug|x64
		{9C2A0942-A891-44EF-B55A-F0DBAAC311C1}.Debug|x86.ActiveCfg = Debug|Win32
		{9C2A0942-A891-44EF-B55A-F0DBAAC311C1}.Debug|x86.Build.0 = Debug|Win32
		{9C2A0942-A891-44EF-B55A-F0DBAAC311C1}.Release|x64.ActiveCfg = Release|x64
		{9C2A0942-A891-44EF-B55A-F0DBAAC311C1}.Release|x64.Build.0 = Release|x64
		{9C2A0942-A891-44EF-B55A-F0DBAAC311C1}.Release|x86.ActiveCfg = Release|Win32
		{9C2A0942-A891-44EF-B55A-F0DBAAC311C1}.Release|x86.Build.0 = Release|Win32
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {05ACC96F-91A0-4D4B-945D-6BCFC33DB289}
	EndGlobalSection
EndGlobal


================================================
FILE: keynavish.visualdproj
================================================
<DProject>
 <ProjectGuid>{9C2A0942-A891-44EF-B55A-F0DBAAC311C1}</ProjectGuid>
 <Config platform="Win32" name="Debug">
  <obj>0</obj>
  <link>0</link>
  <lib>0</lib>
  <subsystem>2</subsystem>
  <multiobj>0</multiobj>
  <singleFileCompilation>0</singleFileCompilation>
  <oneobj>0</oneobj>
  <mscoff>1</mscoff>
  <trace>0</trace>
  <quiet>0</quiet>
  <verbose>0</verbose>
  <vtls>0</vtls>
  <vgc>0</vgc>
  <symdebug>1</symdebug>
  <symdebugref>1</symdebugref>
  <optimize>0</optimize>
  <cpu>0</cpu>
  <isX86_64>0</isX86_64>
  <isLinux>0</isLinux>
  <isOSX>0</isOSX>
  <isWindows>0</isWindows>
  <isFreeBSD>0</isFreeBSD>
  <isSolaris>0</isSolaris>
  <scheduler>0</scheduler>
  <useDeprecated>0</useDeprecated>
  <errDeprecated>0</errDeprecated>
  <useAssert>0</useAssert>
  <useInvariants>0</useInvariants>
  <useIn>0</useIn>
  <useOut>0</useOut>
  <useArrayBounds>0</useArrayBounds>
  <boundscheck>0</boundscheck>
  <useSwitchError>0</useSwitchError>
  <useUnitTests>0</useUnitTests>
  <useInline>0</useInline>
  <release>0</release>
  <preservePaths>0</preservePaths>
  <warnings>0</warnings>
  <infowarnings>0</infowarnings>
  <genStackFrame>0</genStackFrame>
  <pic>0</pic>
  <cov>0</cov>
  <nofloat>0</nofloat>
  <ignoreUnsupportedPragmas>0</ignoreUnsupportedPragmas>
  <allinst>0</allinst>
  <stackStomp>0</stackStomp>
  <betterC>0</betterC>
  <dip25>0</dip25>
  <dip1000>0</dip1000>
  <dip1008>0</dip1008>
  <dip1021>0</dip1021>
  <transition_field>0</transition_field>
  <revert_import>0</revert_import>
  <preview_dtorfields>0</preview_dtorfields>
  <transition_checkimports>0</transition_checkimports>
  <transition_complex>0</transition_complex>
  <preview_intpromote>0</preview_intpromote>
  <preview_fixAliasThis>0</preview_fixAliasThis>
  <preview_markdown>0</preview_markdown>
  <preview_rvaluerefparam>0</preview_rvaluerefparam>
  <preview_nosharedaccess>0</preview_nosharedaccess>
  <preview_in>0</preview_in>
  <preview_inclincontracts>0</preview_inclincontracts>
  <transition_vmarkdown>0</transition_vmarkdown>
  <compiler>2</compiler>
  <otherDMD>0</otherDMD>
  <cccmd>$(CC) -c</cccmd>
  <ccTransOpt>1</ccTransOpt>
  <addDepImp>0</addDepImp>
  <program>$(DMDInstallDir)windows\bin\dmd.exe</program>
  <imppath>src</imppath>
  <fileImppath>.</fileImppath>
  <outdir>out</outdir>
  <objdir>$(OutDir)</objdir>
  <objname />
  <libname />
  <doDocComments>0</doDocComments>
  <docdir />
  <docname />
  <modules_ddoc />
  <ddocfiles />
  <doHdrGeneration>0</doHdrGeneration>
  <hdrdir />
  <hdrname />
  <doXGeneration>1</doXGeneration>
  <xfilename>$(IntDir)\$(TargetName).json</xfilename>
  <debuglevel>0</debuglevel>
  <debugids />
  <versionlevel>0</versionlevel>
  <versionids />
  <dump_source>0</dump_source>
  <mapverbosity>0</mapverbosity>
  <createImplib>0</createImplib>
  <debuglib>0</debuglib>
  <defaultlibname />
  <debuglibname />
  <moduleDepsFile />
  <run>0</run>
  <runargs />
  <runCv2pdb>1</runCv2pdb>
  <pathCv2pdb>$(VisualDInstallDir)cv2pdb\cv2pdb.exe</pathCv2pdb>
  <cv2pdbNoDemangle>0</cv2pdbNoDemangle>
  <cv2pdbEnumType>0</cv2pdbEnumType>
  <cv2pdbOptions />
  <enableMixin>0</enableMixin>
  <mixinPath>$(IntDir)\$(SafeProjectName).mixin</mixinPath>
  <objfiles />
  <linkswitches />
  <libfiles />
  <libpaths />
  <deffile />
  <resfile>src\keynavish\versioninfo.res</resfile>
  <exefile>$(OutDir)\$(ProjectName).exe</exefile>
  <pdbfile>$(IntDir)\$(SafeProjectName).pdb</pdbfile>
  <impfile>$(IntDir)\$(SafeProjectName).lib</impfile>
  <mapfile>$(IntDir)\$(SafeProjectName).map</mapfile>
  <useStdLibPath>1</useStdLibPath>
  <cRuntime>2</cRuntime>
  <privatePhobos>0</privatePhobos>
  <additionalOptions />
  <preBuildCommand>call generate-version-info.bat</preBuildCommand>
  <postBuildCommand />
  <filesToClean>*.obj;*.cmd;*.build;*.json;*.dep;*.tlog</filesToClean>
 </Config>
 <Config platform="Win32" name="Release">
  <obj>0</obj>
  <link>0</link>
  <lib>0</lib>
  <subsystem>2</subsystem>
  <multiobj>0</multiobj>
  <singleFileCompilation>0</singleFileCompilation>
  <oneobj>0</oneobj>
  <mscoff>1</mscoff>
  <trace>0</trace>
  <quiet>0</quiet>
  <verbose>0</verbose>
  <vtls>0</vtls>
  <vgc>0</vgc>
  <symdebug>0</symdebug>
  <symdebugref>1</symdebugref>
  <optimize>1</optimize>
  <cpu>0</cpu>
  <isX86_64>0</isX86_64>
  <isLinux>0</isLinux>
  <isOSX>0</isOSX>
  <isWindows>0</isWindows>
  <isFreeBSD>0</isFreeBSD>
  <isSolaris>0</isSolaris>
  <scheduler>0</scheduler>
  <useDeprecated>0</useDeprecated>
  <errDeprecated>0</errDeprecated>
  <useAssert>0</useAssert>
  <useInvariants>0</useInvariants>
  <useIn>0</useIn>
  <useOut>0</useOut>
  <useArrayBounds>0</useArrayBounds>
  <boundscheck>0</boundscheck>
  <useSwitchError>0</useSwitchError>
  <useUnitTests>0</useUnitTests>
  <useInline>1</useInline>
  <release>1</release>
  <preservePaths>0</preservePaths>
  <warnings>0</warnings>
  <infowarnings>0</infowarnings>
  <genStackFrame>0</genStackFrame>
  <pic>0</pic>
  <cov>0</cov>
  <nofloat>0</nofloat>
  <ignoreUnsupportedPragmas>0</ignoreUnsupportedPragmas>
  <allinst>0</allinst>
  <stackStomp>0</stackStomp>
  <betterC>0</betterC>
  <dip25>0</dip25>
  <dip1000>0</dip1000>
  <dip1008>0</dip1008>
  <dip1021>0</dip1021>
  <transition_field>0</transition_field>
  <revert_import>0</revert_import>
  <preview_dtorfields>0</preview_dtorfields>
  <transition_checkimports>0</transition_checkimports>
  <transition_complex>0</transition_complex>
  <preview_intpromote>0</preview_intpromote>
  <preview_fixAliasThis>0</preview_fixAliasThis>
  <preview_markdown>0</preview_markdown>
  <preview_rvaluerefparam>0</preview_rvaluerefparam>
  <preview_nosharedaccess>0</preview_nosharedaccess>
  <preview_in>0</preview_in>
  <preview_inclincontracts>0</preview_inclincontracts>
  <transition_vmarkdown>0</transition_vmarkdown>
  <compiler>2</compiler>
  <otherDMD>0</otherDMD>
  <cccmd>$(CC) -c</cccmd>
  <ccTransOpt>1</ccTransOpt>
  <addDepImp>0</addDepImp>
  <program>$(DMDInstallDir)windows\bin\dmd.exe</program>
  <imppath>src</imppath>
  <fileImppath>.</fileImppath>
  <outdir>out</outdir>
  <objdir>$(OutDir)</objdir>
  <objname />
  <libname />
  <doDocComments>0</doDocComments>
  <docdir />
  <docname />
  <modules_ddoc />
  <ddocfiles />
  <doHdrGeneration>0</doHdrGeneration>
  <hdrdir />
  <hdrname />
  <doXGeneration>1</doXGeneration>
  <xfilename>$(IntDir)\$(TargetName).json</xfilename>
  <debuglevel>0</debuglevel>
  <debugids />
  <versionlevel>0</versionlevel>
  <versionids />
  <dump_source>0</dump_source>
  <mapverbosity>0</mapverbosity>
  <createImplib>0</createImplib>
  <debuglib>0</debuglib>
  <defaultlibname />
  <debuglibname />
  <moduleDepsFile />
  <run>0</run>
  <runargs />
  <runCv2pdb>0</runCv2pdb>
  <pathCv2pdb>$(VisualDInstallDir)cv2pdb\cv2pdb.exe</pathCv2pdb>
  <cv2pdbNoDemangle>0</cv2pdbNoDemangle>
  <cv2pdbEnumType>0</cv2pdbEnumType>
  <cv2pdbOptions />
  <enableMixin>0</enableMixin>
  <mixinPath>$(IntDir)\$(SafeProjectName).mixin</mixinPath>
  <objfiles />
  <linkswitches />
  <libfiles />
  <libpaths />
  <deffile />
  <resfile>src\keynavish\versioninfo.res</resfile>
  <exefile>$(OutDir)\$(ProjectName).exe</exefile>
  <pdbfile>$(IntDir)\$(SafeProjectName).pdb</pdbfile>
  <impfile>$(IntDir)\$(SafeProjectName).lib</impfile>
  <mapfile>$(IntDir)\$(SafeProjectName).map</mapfile>
  <useStdLibPath>1</useStdLibPath>
  <cRuntime>2</cRuntime>
  <privatePhobos>0</privatePhobos>
  <additionalOptions />
  <preBuildCommand>call generate-version-info.bat</preBuildCommand>
  <postBuildCommand />
  <filesToClean>*.obj;*.cmd;*.build;*.json;*.dep;*.tlog</filesToClean>
 </Config>
 <Config platform="x64" name="Debug">
  <obj>0</obj>
  <link>0</link>
  <lib>0</lib>
  <subsystem>2</subsystem>
  <multiobj>0</multiobj>
  <singleFileCompilation>0</singleFileCompilation>
  <oneobj>0</oneobj>
  <mscoff>0</mscoff>
  <trace>0</trace>
  <quiet>0</quiet>
  <verbose>0</verbose>
  <vtls>0</vtls>
  <vgc>0</vgc>
  <symdebug>1</symdebug>
  <symdebugref>1</symdebugref>
  <optimize>0</optimize>
  <cpu>0</cpu>
  <isX86_64>1</isX86_64>
  <isLinux>0</isLinux>
  <isOSX>0</isOSX>
  <isWindows>0</isWindows>
  <isFreeBSD>0</isFreeBSD>
  <isSolaris>0</isSolaris>
  <scheduler>0</scheduler>
  <useDeprecated>0</useDeprecated>
  <errDeprecated>0</errDeprecated>
  <useAssert>0</useAssert>
  <useInvariants>0</useInvariants>
  <useIn>0</useIn>
  <useOut>0</useOut>
  <useArrayBounds>0</useArrayBounds>
  <boundscheck>0</boundscheck>
  <useSwitchError>0</useSwitchError>
  <useUnitTests>0</useUnitTests>
  <useInline>0</useInline>
  <release>0</release>
  <preservePaths>0</preservePaths>
  <warnings>0</warnings>
  <infowarnings>0</infowarnings>
  <genStackFrame>0</genStackFrame>
  <pic>0</pic>
  <cov>0</cov>
  <nofloat>0</nofloat>
  <ignoreUnsupportedPragmas>0</ignoreUnsupportedPragmas>
  <allinst>0</allinst>
  <stackStomp>0</stackStomp>
  <betterC>0</betterC>
  <dip25>0</dip25>
  <dip1000>0</dip1000>
  <dip1008>0</dip1008>
  <dip1021>0</dip1021>
  <transition_field>0</transition_field>
  <revert_import>0</revert_import>
  <preview_dtorfields>0</preview_dtorfields>
  <transition_checkimports>0</transition_checkimports>
  <transition_complex>0</transition_complex>
  <preview_intpromote>0</preview_intpromote>
  <preview_fixAliasThis>0</preview_fixAliasThis>
  <preview_markdown>0</preview_markdown>
  <preview_rvaluerefparam>0</preview_rvaluerefparam>
  <preview_nosharedaccess>0</preview_nosharedaccess>
  <preview_in>0</preview_in>
  <preview_inclincontracts>0</preview_inclincontracts>
  <transition_vmarkdown>0</transition_vmarkdown>
  <compiler>2</compiler>
  <otherDMD>0</otherDMD>
  <cccmd>$(CC) -c</cccmd>
  <ccTransOpt>1</ccTransOpt>
  <addDepImp>0</addDepImp>
  <program>$(DMDInstallDir)windows\bin\dmd.exe</program>
  <imppath>src</imppath>
  <fileImppath>.</fileImppath>
  <outdir>out</outdir>
  <objdir>$(OutDir)</objdir>
  <objname />
  <libname />
  <doDocComments>0</doDocComments>
  <docdir />
  <docname />
  <modules_ddoc />
  <ddocfiles />
  <doHdrGeneration>0</doHdrGeneration>
  <hdrdir />
  <hdrname />
  <doXGeneration>1</doXGeneration>
  <xfilename>$(IntDir)\$(TargetName).json</xfilename>
  <debuglevel>0</debuglevel>
  <debugids />
  <versionlevel>0</versionlevel>
  <versionids />
  <dump_source>0</dump_source>
  <mapverbosity>0</mapverbosity>
  <createImplib>0</createImplib>
  <debuglib>0</debuglib>
  <defaultlibname />
  <debuglibname />
  <moduleDepsFile />
  <run>0</run>
  <runargs />
  <runCv2pdb>1</runCv2pdb>
  <pathCv2pdb>$(VisualDInstallDir)cv2pdb\cv2pdb.exe</pathCv2pdb>
  <cv2pdbNoDemangle>0</cv2pdbNoDemangle>
  <cv2pdbEnumType>0</cv2pdbEnumType>
  <cv2pdbOptions />
  <enableMixin>0</enableMixin>
  <mixinPath>$(IntDir)\$(SafeProjectName).mixin</mixinPath>
  <objfiles />
  <linkswitches />
  <libfiles />
  <libpaths />
  <deffile />
  <resfile>src\keynavish\versioninfo.res</resfile>
  <exefile>$(OutDir)\$(ProjectName).exe</exefile>
  <pdbfile>$(IntDir)\$(SafeProjectName).pdb</pdbfile>
  <impfile>$(IntDir)\$(SafeProjectName).lib</impfile>
  <mapfile>$(IntDir)\$(SafeProjectName).map</mapfile>
  <useStdLibPath>1</useStdLibPath>
  <cRuntime>2</cRuntime>
  <privatePhobos>0</privatePhobos>
  <additionalOptions />
  <preBuildCommand>call generate-version-info.bat</preBuildCommand>
  <postBuildCommand />
  <filesToClean>*.obj;*.cmd;*.build;*.json;*.dep;*.tlog</filesToClean>
 </Config>
 <Config platform="x64" name="Release">
  <obj>0</obj>
  <link>0</link>
  <lib>0</lib>
  <subsystem>2</subsystem>
  <multiobj>0</multiobj>
  <singleFileCompilation>0</singleFileCompilation>
  <oneobj>0</oneobj>
  <mscoff>0</mscoff>
  <trace>0</trace>
  <quiet>0</quiet>
  <verbose>0</verbose>
  <vtls>0</vtls>
  <vgc>0</vgc>
  <symdebug>0</symdebug>
  <symdebugref>1</symdebugref>
  <optimize>1</optimize>
  <cpu>0</cpu>
  <isX86_64>1</isX86_64>
  <isLinux>0</isLinux>
  <isOSX>0</isOSX>
  <isWindows>0</isWindows>
  <isFreeBSD>0</isFreeBSD>
  <isSolaris>0</isSolaris>
  <scheduler>0</scheduler>
  <useDeprecated>0</useDeprecated>
  <errDeprecated>0</errDeprecated>
  <useAssert>0</useAssert>
  <useInvariants>0</useInvariants>
  <useIn>0</useIn>
  <useOut>0</useOut>
  <useArrayBounds>0</useArrayBounds>
  <boundscheck>0</boundscheck>
  <useSwitchError>0</useSwitchError>
  <useUnitTests>0</useUnitTests>
  <useInline>1</useInline>
  <release>1</release>
  <preservePaths>0</preservePaths>
  <warnings>0</warnings>
  <infowarnings>0</infowarnings>
  <genStackFrame>0</genStackFrame>
  <pic>0</pic>
  <cov>0</cov>
  <nofloat>0</nofloat>
  <ignoreUnsupportedPragmas>0</ignoreUnsupportedPragmas>
  <allinst>0</allinst>
  <stackStomp>0</stackStomp>
  <betterC>0</betterC>
  <dip25>0</dip25>
  <dip1000>0</dip1000>
  <dip1008>0</dip1008>
  <dip1021>0</dip1021>
  <transition_field>0</transition_field>
  <revert_import>0</revert_import>
  <preview_dtorfields>0</preview_dtorfields>
  <transition_checkimports>0</transition_checkimports>
  <transition_complex>0</transition_complex>
  <preview_intpromote>0</preview_intpromote>
  <preview_fixAliasThis>0</preview_fixAliasThis>
  <preview_markdown>0</preview_markdown>
  <preview_rvaluerefparam>0</preview_rvaluerefparam>
  <preview_nosharedaccess>0</preview_nosharedaccess>
  <preview_in>0</preview_in>
  <preview_inclincontracts>0</preview_inclincontracts>
  <transition_vmarkdown>0</transition_vmarkdown>
  <compiler>2</compiler>
  <otherDMD>0</otherDMD>
  <cccmd>$(CC) -c</cccmd>
  <ccTransOpt>1</ccTransOpt>
  <addDepImp>0</addDepImp>
  <program>$(DMDInstallDir)windows\bin\dmd.exe</program>
  <imppath>src</imppath>
  <fileImppath>.</fileImppath>
  <outdir>out</outdir>
  <objdir>$(OutDir)</objdir>
  <objname />
  <libname />
  <doDocComments>0</doDocComments>
  <docdir />
  <docname />
  <modules_ddoc />
  <ddocfiles />
  <doHdrGeneration>0</doHdrGeneration>
  <hdrdir />
  <hdrname />
  <doXGeneration>1</doXGeneration>
  <xfilename>$(IntDir)\$(TargetName).json</xfilename>
  <debuglevel>0</debuglevel>
  <debugids />
  <versionlevel>0</versionlevel>
  <versionids />
  <dump_source>0</dump_source>
  <mapverbosity>0</mapverbosity>
  <createImplib>0</createImplib>
  <debuglib>0</debuglib>
  <defaultlibname />
  <debuglibname />
  <moduleDepsFile />
  <run>0</run>
  <runargs />
  <runCv2pdb>0</runCv2pdb>
  <pathCv2pdb>$(VisualDInstallDir)cv2pdb\cv2pdb.exe</pathCv2pdb>
  <cv2pdbNoDemangle>0</cv2pdbNoDemangle>
  <cv2pdbEnumType>0</cv2pdbEnumType>
  <cv2pdbOptions />
  <enableMixin>0</enableMixin>
  <mixinPath>$(IntDir)\$(SafeProjectName).mixin</mixinPath>
  <objfiles />
  <linkswitches />
  <libfiles />
  <libpaths />
  <deffile />
  <resfile>src\keynavish\versioninfo.res</resfile>
  <exefile>$(OutDir)\$(ProjectName).exe</exefile>
  <pdbfile>$(IntDir)\$(SafeProjectName).pdb</pdbfile>
  <impfile>$(IntDir)\$(SafeProjectName).lib</impfile>
  <mapfile>$(IntDir)\$(SafeProjectName).map</mapfile>
  <useStdLibPath>1</useStdLibPath>
  <cRuntime>1</cRuntime>
  <privatePhobos>0</privatePhobos>
  <additionalOptions />
  <preBuildCommand>call generate-version-info.bat</preBuildCommand>
  <postBuildCommand />
  <filesToClean>*.obj;*.cmd;*.build;*.json;*.dep;*.tlog</filesToClean>
 </Config>
 <Folder name="keynavish">
  <Folder name="src">
   <Folder name="keynavish">
    <File path="src\keynavish\commands.d" />
    <File path="src\keynavish\config.d" />
    <File path="src\keynavish\errorhandling.d" />
    <File path="src\keynavish\grid.d" />
    <File path="src\keynavish\helpers.d" />
    <File path="src\keynavish\keyboardinput.d" />
    <File path="src\keynavish\main.d" />
    <File path="src\keynavish\notifyicon.d" />
    <File path="src\keynavish\package.d" />
    <File path="src\keynavish\recording.d" />
    <File path="src\keynavish\window.d" />
   </Folder>
  </Folder>
 </Folder>
</DProject>


================================================
FILE: keynavrc
================================================
# Project page; https://github.com/lesderid/keynavish

# Use 'clear' to blow away any previous keybindings
#clear

ctrl+semicolon start
Escape end
ctrl+bracketleft end
h cut-left
j cut-down
k cut-up
l cut-right
y cut-left,cut-up
u cut-right,cut-up
b cut-left,cut-down
n cut-right,cut-down
shift+h move-left
shift+j move-down
shift+k move-up
shift+l move-right
shift+y move-left,move-up
shift+u move-right,move-up
shift+b move-left,move-down
shift+n move-right,move-down
space warp,click 1,end
semicolon warp,end
1 click 1
2 click 2
3 click 3

# Zoom to the current window
w windowzoom

# Zoom to the cursor location with a given height and width
c cursorzoom 200 200

# Handy for holding ctrl while using keynav(ish):
ctrl+h cut-left
ctrl+j cut-down
ctrl+k cut-up
ctrl+l cut-right
ctrl+y cut-left,cut-up
ctrl+u cut-right,cut-up
ctrl+b cut-left,cut-down
ctrl+n cut-right,cut-down

# Arrow keys can move the grid as welll
Left cut-left
Down cut-down
Up cut-up
Right cut-right
shift+Left move-left
shift+Down move-down
shift+Up move-up
shift+Right move-right
ctrl+Left cut-left
ctrl+Down cut-down
ctrl+Up cut-up
ctrl+Right cut-right
ctrl+shift+Left move-left
ctrl+shift+Down move-down
ctrl+shift+Up move-up
ctrl+shift+Right move-right

# Record keynav(ish) actions
q record
shift+at playback

### Example using the 'sh' command.
v sh "notepad"

### Drag examples
# Start drag holding the left mouse button
#q drag 1
# Start drag holding middle mouse + control and shift
#w drag 2 ctrl+shift
# Dragging with modifiers
#q drag 1
#ctrl+q drag 1 ctrl
#shift+q drag 1 shift
#shift+ctrl+q drag 1 shift+ctrl

### History
a history-back

### Example of cut and move without the default values
#h cut-left .75
#j cut-down .75
#k cut-up .75
#l cut-right .75
#shift+h move-left .50
#shift+j move-down .50
#shift+k move-up .50
#shift+l move-right .50

### Example using a 2-row, 3-column grid,
# mapped to Insert/Home/PageUp/etc...
6 grid 3x2
Insert cell-select 1x1
Home cell-select 2x1
Page_Up cell-select 3x1   # PageUp
Delete cell-select 1x2
End cell-select 2x2
Page_Down cell-select 3x2   # PageDown

### Example using a 3x3 grid with nethack-vi keys
#ctrl+semicolon start, grid 3x3
#h cell-select 1x2      # left
#j cell-select 2x3      # down
#k cell-select 2x1      # up
#l cell-select 3x2      # right
#y cell-select 1x1      # up-left
#u cell-select 3x1      # up-right
#b cell-select 1x3      # down-left
#n cell-select 3x3      # down-right
#period cell-select 2x2 # center


================================================
FILE: src/keynavish/commands.d
================================================
module keynavish.commands;

import keynavish;

import core.sys.windows.windows : LONG, DWORD;

DWORD draggingFlag;
long delayMilliseconds = 0;

enum Direction
{
    up, down, left, right
}

Direction commandToDirection(string commandString)
{
    import std.algorithm : findSkip;
    findSkip(commandString, "-");
    switch (commandString)
    {
        case "up":    return Direction.up;
        case "down":  return Direction.down;
        case "left":  return Direction.left;
        case "right": return Direction.right;
        default:      assert(false);
    }
}

void redrawWindow()
{
    import core.sys.windows.windows : InvalidateRect;

    if (windowHandle == null) return;

    InvalidateRect(windowHandle, null, true);
}

private void start()
{
    import core.sys.windows.windows : MoveWindow;

    resetGrid();
    if (gridNavEnabled)
    {
        resetGridNavSelection();
    }

    auto virtualScreen = virtualScreenRectangle;
    MoveWindow(windowHandle, virtualScreen.left, virtualScreen.top, virtualScreen.width, virtualScreen.height, false);

    showWindow();
}

private void end()
{
    hideWindow();
}

private void toggleStart()
{
    if (active) end();
    else start();
}

private void quit()
{
    import core.sys.windows.windows : PostQuitMessage;

    PostQuitMessage(0);
}

void restart()
{
    import core.sys.windows.windows : GetModuleFileName;
    import std.process : spawnProcess;
    import std.conv : to;
    import core.runtime : Runtime;

    spawnProcess(Runtime.args);

    quit();
}

private LONG getCutMoveValue(Direction direction, string arg)
{
    import std.algorithm : canFind;
    import std.conv : to;

    if (arg == "0")
    {
        return 0;
    }

    auto original = (direction == Direction.up || direction == Direction.down) ? grid.rect.height : grid.rect.width;

    if (arg == "1")
    {
        return original;
    }
    else if (arg.canFind('.'))
    {
        return cast(LONG)(arg.to!double * original);
    }
    else
    {
        return arg.to!LONG;
    }
}

private void cut(Direction direction, string arg)
{
    import core.sys.windows.windows : RECT;

    if (!active) return;

    auto value = getCutMoveValue(direction, arg != null ? arg : "0.5");
    auto diff = (direction == Direction.up || direction == Direction.down) ? grid.rect.height - value : grid.rect.width - value;

    auto virtualScreen = virtualScreenRectangle;

    Grid newGrid = grid;
    final switch (direction) with (Direction)
    {
        case up:
            newGrid.rect.bottom -= diff;
            if (newGrid.rect.bottom < virtualScreen.top) newGrid.rect.bottom = virtualScreen.top;
            break;
        case down:
            newGrid.rect.top += diff;
            if (newGrid.rect.top < virtualScreen.top) newGrid.rect.top = virtualScreen.top;
            break;
        case left:
            newGrid.rect.right -= diff;
            if (newGrid.rect.right < virtualScreen.left) newGrid.rect.right = virtualScreen.left;
            break;
        case right:
            newGrid.rect.left += diff;
            if (newGrid.rect.left < virtualScreen.left) newGrid.rect.left = virtualScreen.left;
            break;
    }

    grid = newGrid;
    redrawWindow();

    if (newGrid.rect.height < 2 || newGrid.rect.width < 2)
    {
        resetGrid();
        hideWindow();
    }
}

private void move(Direction direction, string arg)
{
    import core.sys.windows.windows : RECT;

    if (!active) return;

    auto virtualScreen = virtualScreenRectangle;
    auto virtualScreenRight = virtualScreen.left + virtualScreen.width;
    auto virtualScreenBottom = virtualScreen.top + virtualScreen.height;

    auto value = getCutMoveValue(direction, arg != null ? arg : "1");

    Grid newGrid = grid;
    final switch (direction) with (Direction)
    {
        case up:
            newGrid.rect.top -= value;
            newGrid.rect.bottom -= value;
            if (newGrid.rect.top < virtualScreen.top)
            {
                newGrid.rect.bottom -= (newGrid.rect.top - virtualScreen.top);
                newGrid.rect.top = virtualScreen.top;
            }
            break;
        case down:
            newGrid.rect.top += value;
            newGrid.rect.bottom += value;
            if (newGrid.rect.bottom > virtualScreenBottom)
            {
                newGrid.rect.top -= (newGrid.rect.bottom - virtualScreenBottom);
                newGrid.rect.bottom = virtualScreenBottom;
            }
            break;
        case left:
            newGrid.rect.left -= value;
            newGrid.rect.right -= value;
            if (newGrid.rect.left < virtualScreen.left)
            {
                newGrid.rect.right -= (newGrid.rect.left - virtualScreen.left);
                newGrid.rect.left = virtualScreen.left;
            }
            break;
        case right:
            newGrid.rect.left += value;
            newGrid.rect.right += value;
            if (newGrid.rect.right > virtualScreenRight)
            {
                newGrid.rect.left -= (newGrid.rect.right - virtualScreenRight);
                newGrid.rect.right = virtualScreenRight;
            }
            break;
    }

    grid = newGrid;

    redrawWindow();
}

private void warp()
{
    import core.sys.windows.windows : SetCursorPos;
    import core.sys.windows.winuser;

    if (!active) return;

    auto resolution = primaryDeviceResolution;

    auto middleX = grid.rect.left + grid.rect.width / 2;
    auto middleY = grid.rect.top + grid.rect.height / 2;

    INPUT input;
    input.type = INPUT_MOUSE;
    input.mi.dx = middleX * 65536 / resolution.width;
    input.mi.dy = middleY * 65536 / resolution.height;
    input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE | draggingFlag;
    SendInput(1, &input, INPUT.sizeof);
}

private void cursorZoom(int width, int height)
{
    import core.sys.windows.windows : RECT, POINT, GetCursorPos;

    POINT cursorPosition;

    auto result = GetCursorPos(&cursorPosition);
    assert(result);

    Grid newGrid = grid;
    newGrid.rect.left = cursorPosition.x - width / 2;
    newGrid.rect.right = cursorPosition.x + width / 2;
    newGrid.rect.top = cursorPosition.y - height / 2;
    newGrid.rect.bottom = cursorPosition.y + height / 2;
    grid = newGrid;

    redrawWindow();
}

private void windowZoom()
{
    import core.sys.windows.windows : RECT, GetForegroundWindow, GetWindowRect;

    Grid newGrid = grid;
    GetWindowRect(GetForegroundWindow(), &newGrid.rect);
    grid = newGrid;

    redrawWindow();
}

private void click(string button)
{
    import core.sys.windows.winuser;
    import core.thread.osthread : Thread;
    import core.time : dur;

    INPUT[2] inputs;

    inputs[0].type = INPUT_MOUSE;
    inputs[1].type = INPUT_MOUSE;

    switch (button)
    {
        case "1":
            inputs[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
            inputs[1].mi.dwFlags = MOUSEEVENTF_LEFTUP;
            break;
        case "2":
            inputs[0].mi.dwFlags = MOUSEEVENTF_MIDDLEDOWN;
            inputs[1].mi.dwFlags = MOUSEEVENTF_MIDDLEUP;
            break;
        case "3":
            inputs[0].mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
            inputs[1].mi.dwFlags = MOUSEEVENTF_RIGHTUP;
            break;
        case "4":
            inputs[0].mi.dwFlags = MOUSEEVENTF_WHEEL;
            inputs[0].mi.mouseData = WHEEL_DELTA;
            inputs[1].mi.dwFlags = 0;
            break;
        case "5":
            inputs[0].mi.dwFlags = MOUSEEVENTF_WHEEL;
            inputs[0].mi.mouseData = -WHEEL_DELTA;
            inputs[1].mi.dwFlags = 0;
            break;
        default:
            showError("Invalid mouse button: " ~ button);
            break;
    }

    if (delayMilliseconds == 0)
    {
        SendInput(2, inputs.ptr, INPUT.sizeof);
    }
    else
    {
        SendInput(1, inputs.ptr, INPUT.sizeof);
        Thread.sleep(dur!("msecs")(delayMilliseconds));
        SendInput(1, inputs.ptr + 1, INPUT.sizeof);
    }
}

private void doubleClick(string button)
{
    import core.sys.windows.winuser;
    import core.thread.osthread : Thread;
    import core.time : dur;

    INPUT[4] inputs;

    inputs[0].type = INPUT_MOUSE;
    inputs[1].type = INPUT_MOUSE;

    switch (button)
    {
        case "1":
            inputs[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
            inputs[1].mi.dwFlags = MOUSEEVENTF_LEFTUP;
            break;
        case "2":
            inputs[0].mi.dwFlags = MOUSEEVENTF_MIDDLEDOWN;
            inputs[1].mi.dwFlags = MOUSEEVENTF_MIDDLEUP;
            break;
        case "3":
            inputs[0].mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
            inputs[1].mi.dwFlags = MOUSEEVENTF_RIGHTUP;
            break;
        default:
            showError("Invalid mouse button: " ~ button);
            break;
    }

    inputs[2] = inputs[0];
    inputs[3] = inputs[1];

    if (delayMilliseconds == 0)
    {
        SendInput(4, inputs.ptr, INPUT.sizeof);
    }
    else
    {
        SendInput(1, inputs.ptr, INPUT.sizeof);
        Thread.sleep(dur!("msecs")(delayMilliseconds));
        SendInput(1, inputs.ptr + 1, INPUT.sizeof);

        SendInput(1, inputs.ptr + 2, INPUT.sizeof);
        Thread.sleep(dur!("msecs")(delayMilliseconds));
        SendInput(1, inputs.ptr + 3, INPUT.sizeof);
    }
}

private void drag(string button, string modifiers)
{
    import core.sys.windows.windows;
    import std.string : split;

    static bool dragging = false;

    INPUT mouseInput;

    mouseInput.type = INPUT_MOUSE;

    switch (button)
    {
        case "1":
            mouseInput.mi.dwFlags = !draggingFlag ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP;
            break;
        case "2":
            mouseInput.mi.dwFlags = !draggingFlag ? MOUSEEVENTF_MIDDLEDOWN : MOUSEEVENTF_MIDDLEUP;
            break;
        case "3":
            mouseInput.mi.dwFlags = !draggingFlag ? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_RIGHTUP;
            break;
        default:
            showError("Invalid mouse button: " ~ button);
            break;
    }

    if (draggingFlag && modifiers != null)
    {
        INPUT[] keyUpInputs;
        INPUT[] keyDownInputs;

        foreach (modifier; modifiers.split('+'))
        {
            INPUT keyboardInput;
            keyboardInput.type = INPUT_KEYBOARD;
            switch (modifier)
            {
                case "ctrl":
                    keyboardInput.ki.wVk = VK_CONTROL;
                    break;
                case "shift":
                    keyboardInput.ki.wVk = VK_SHIFT;
                    break;
                case "alt":
                    keyboardInput.ki.wVk = VK_MENU;
                    break;
                case "super":
                    keyboardInput.ki.wVk = VK_LWIN;
                    break;
                default:
                    break;
            }

            keyUpInputs ~= keyboardInput;

            keyboardInput.ki.dwFlags = KEYEVENTF_KEYUP;
            keyDownInputs ~= keyboardInput;
        }

        INPUT[] inputs = keyUpInputs ~ [mouseInput] ~ keyDownInputs;
        SendInput(cast(DWORD) inputs.length, inputs.ptr, INPUT.sizeof);
    }
    else
    {
        SendInput(1, &mouseInput, INPUT.sizeof);
    }

    draggingFlag = !draggingFlag ? mouseInput.mi.dwFlags : 0;
}

private void runShellCommand(string shellCommand)
{
    import std.process : spawnShell;

    spawnShell(shellCommand);
}

void loadAllConfigs()
{
    import std.file : thisExePath;
    import std.path : dirName, buildPath;

    recordings = [];

    auto portableConfigPath = dirName(thisExePath()).buildPath("keynavrc");

    foreach (path; [portableConfigPath] ~ configFilePaths)
    {
        loadConfig(path, true);
    }

    loadRecordings();
}

void loadConfig(string pathString, bool silent = false)
{
    import std.file : exists, readText;
    import std.range : array;
    import std.conv : to;
    import std.format : format;
    import std.array : replace, split;

    string path = pathString.expandPath;

    if (!path.exists)
    {
        if (!silent)
        {
            if (path == pathString)
            {
                showError(format!"Error loading config file: %s does not exist"(path));
            }
            else
            {
                showError(format!"Error loading config file: %s (expanded to: %s) does not exist"(pathString, path));
            }
        }
        return;
    }

    foreach (line; path.readText.replace('\r', "").split('\n'))
    {
        registerKeyBinding(line.to!string);
    }
}

private void historyBack()
{
    tryPopGrid();

    redrawWindow();
}

private void changeGrid(string columnsAndRows)
{
    import std.range : split, array;
    import std.algorithm : map;
    import std.conv : to;

    auto dimArray = columnsAndRows.split('x').map!(to!int).array;

    Grid newGrid = grid;
    newGrid.columns = dimArray[0];
    newGrid.rows = dimArray[1];
    grid = newGrid;

    redrawWindow();
}

private void setGridNav(string value)
{
    import std.string : toLower;

    switch (value.toLower)
    {
        case "on":
            enableGridNav(true);
            break;
        case "off":
            enableGridNav(false);
            break;
        case "toggle":
            enableGridNav(!gridNavEnabled);
            break;
        default:
            showError("Invalid grid-nav value: " ~ value);
            return;
    }

    redrawWindow();
}

void cellSelect(string columnsAndRows)
{
    import core.sys.windows.windows : RECT;
    import std.range : split, array;
    import std.algorithm : map;
    import std.conv : to;

    auto dimArray = columnsAndRows.split('x').map!(to!int).array;

    auto x = grid.rect.left;
    auto y = grid.rect.top;
    auto width = grid.rect.width / grid.columns;
    auto height = grid.rect.height / grid.rows;

    Grid newGrid = grid;
    newGrid.rect = RECT(x + (dimArray[0] - 1) * width, y + (dimArray[1] - 1) * height, x + dimArray[0] * width, y + dimArray[1] * height);
    if (newGrid.rect.height < 2 || newGrid.rect.width < 2)
    {
        resetGrid();
        hideWindow();
    }
    else
    {
        grid = newGrid;
        redrawWindow();
    }
}

private void record(string path = null)
{
    if (recordingActive)
    {
        stopRecording();
    }
    else
    {
        startRecording(path);
    }
}

private void replay()
{
    startReplaying();
}

private void clear()
{
    startKeyBindings = [];
    regularKeyBindings = [];
    delayMilliseconds = 0;
}

private void setDelay(string delayString)
{
    import std.conv : to;

    delayMilliseconds = delayString.to!long;
}

void processCommands(string[][] commands)
{
    foreach (command; commands)
    {
        processCommand(command);
    }
}

bool verifyCommands(string[][] commands)
{
    auto allCorrect = true;
    foreach (command; commands)
    {
        if (!verifyCommand(command))
        {
            allCorrect = false;
        }
    }
    return allCorrect;
}

void processCommand(string[] command)
{
    import std.conv : to;

    switch (command[0])
    {
        case "start":
            start();
            break;
        case "end":
            end();
            break;
        case "toggle-start":
            toggleStart();
            break;
        case "quit":
            quit();
            break;
        case "restart":
            restart();
            break;
        case "warp":
            warp();
            break;
        case "windowzoom":
            windowZoom();
            break;
        case "click":
            click(command[1]);
            break;
        case "doubleclick":
            doubleClick(command[1]);
            break;
        case "drag":
            drag(command[1], command.length == 3 ? command[2] : null);
            break;
        case "cursorzoom":
            cursorZoom(command[1].to!int, command[2].to!int);
            break;
        case "history-back":
            historyBack();
            break;
        case "grid":
            changeGrid(command[1]);
            break;
        case "grid-nav":
            setGridNav(command[1]);
            break;
        case "cell-select":
            cellSelect(command[1]);
            break;
        case "cut-up":
        case "cut-down":
        case "cut-left":
        case "cut-right":
            cut(command[0].commandToDirection(), command.length == 2 ? command[1] : null);
            break;
        case "move-up":
        case "move-down":
        case "move-left":
        case "move-right":
            move(command[0].commandToDirection(), command.length == 2 ? command[1] : null);
            break;
        case "sh":
            runShellCommand(command[1]);
            break;
        case "loadconfig":
            loadConfig(command[1]);
            break;
        case "record":
            record(command.length == 2 ? command[1] : null);
            break;
        case "playback":
            replay();
            break;
        case "daemonize":
            //we ignore this as we always add a notification icon
            break;
        case "x-set-delay":
            setDelay(command[1]);
            break;
        case "clear":
            clear();
            break;
        default:
            showError("Command not implemented: " ~ command[0]);
            break;
    }
}

bool verifyCommand(string[] command)
{
    //TODO: More command verification (arg types etc.)
    //TODO: Refactor (with UDAs?)

    import std.format : format;
    import std.string : join;

    auto commandString = command.join(' ');
    bool argCount(int minCount, int maxCount)
    {
        auto count = command.length - 1;
        if (count >= minCount && count <= maxCount)
        {
            return true;
        }
        
        if (minCount == maxCount)
        {
            showError(format!"Command '%s' needs %d %s but %d %s given: %s"(command[0],
                                                                            minCount,
                                                                            minCount == 1 ? "arg" : "args",
                                                                            count,
                                                                            count == 1 ? "was" : "were",
                                                                            commandString));
        }
        else
        {
            showError(format!"Command '%s' needs %d~%d %s but %d %s given: %s"(command[0],
                                                                               minCount,
                                                                               maxCount,
                                                                               maxCount == 1 ? "arg" : "args",
                                                                               count,
                                                                               count == 1 ? "was" : "were",
                                                                               commandString));
        }
        return false;
    }

    switch (command[0])
    {
        case "start":
        case "end":
        case "toggle-start":
        case "warp":
        case "windowzoom":
        case "history-back":
        case "quit":
        case "restart":
            if (!argCount(0, 0)) return false;
            break;
        case "cut-up":
        case "cut-down":
        case "cut-left":
        case "cut-right":
            if (!argCount(0, 1)) return false;
            break;
        case "move-up":
        case "move-down":
        case "move-left":
        case "move-right":
            if (!argCount(0, 1)) return false;
            break;
        case "click":
        case "doubleclick":
            if (!argCount(1, 1)) return false;
            break;
        case "drag":
            if (!argCount(1, 2)) return false;
            break;
        case "cursorzoom":
            if (!argCount(2, 2)) return false;
            break;
        case "grid":
            if (!argCount(1, 1)) return false;
            break;
        case "cell-select":
            if (!argCount(1, 1)) return false;
            break;
        case "sh":
            if (!argCount(1, 1)) return false;
            break;
        case "loadconfig":
            if (!argCount(1, 1)) return false;
            break;
        case "daemonize":
            if (!argCount(0, 0)) return false;
            break;
        case "clear":
            if (!argCount(0, 0)) return false;
            break;
        case "record":
            if (!argCount(0, 1)) return false;
            break;
        case "playback":
            if (!argCount(0, 0)) return false;
            break;
        case "grid-nav":
            if (!argCount(1, 1)) return false;
            break;
        case "x-set-delay":
            if (!argCount(1, 1)) return false;
            break;
        default:
            showError("Unknown command: " ~ command[0]);
            return false;
    }
    return true;
}


================================================
FILE: src/keynavish/config.d
================================================
module keynavish.config;

import core.sys.windows.windows;

enum windowClassName = "keynavish-grid"w;
enum windowColourKey = RGB(255, 0, 255);

enum mainPenColour = RGB(30, 64, 64);
enum mainPenWidth = 1;
enum borderPenColour = RGB(255, 255, 255);
enum borderPenWidth = 1;

static assert(windowColourKey != mainPenColour, "Colour key and main pen colour can't be the same");
static assert(windowColourKey != borderPenColour, "Colour key and border pen colour can't be the same");

enum programName = "keynavish"w;
enum programInfo = programName ~ q"EOS
 – Control the mouse with the keyboard, on Windows.

Copyright © 2021, Les De Ridder <les@lesderid.net>
EOS" ~ "Home page: <" ~ programUrl ~ ">";
enum programUrl = "https://github.com/lesderid/keynavish";

enum usageHelpString = "Usage: " ~ programName ~ ".exe [options] [optional-startup-commands]\r\n" ~
"Example: " ~ programName ~ ".exe \"loadconfig ~/myconfigs/keynavrc,loadconfig ~/myconfigs/anotherkeynavrc\"\r\n";

enum configFilePaths = ["~/.keynavrc", "~/keynavrc", "~/.config/keynav/keynavrc"];

enum unhandledExceptionMessage = "This is a bug, please press Ctrl+C and report it at https://github.com/lesderid/keynavish/issues/new.";


================================================
FILE: src/keynavish/errorhandling.d
================================================
module keynavish.errorhandling;

import keynavish;

void showError(Stringish)(Stringish message)
{
    import core.sys.windows.windows : MessageBox, MB_ICONERROR;
    import std.utf : toUTF16z;

    MessageBox(null, message.toUTF16z, programName.ptr, MB_ICONERROR);
}

void showWarning(Stringish)(Stringish message)
{
    import core.sys.windows.windows : MessageBox, MB_ICONWARNING;
    import std.utf : toUTF16z;

    MessageBox(null, message.toUTF16z, programName.ptr, MB_ICONWARNING);
}

void showInfo(Stringish)(Stringish message)
{
    import core.sys.windows.windows : MessageBox, MB_ICONINFORMATION;
    import std.utf : toUTF16z;

    MessageBox(null, message.toUTF16z, programName.ptr, MB_ICONINFORMATION);
}

template exceptionHandlerWrapper(alias func)
{
    import std.traits;
    import std.exception;
    import std.utf : toUTF16z;
    import core.sys.windows.windows : MessageBox, MB_ICONERROR, MB_SYSTEMMODAL;

    extern(Windows)
    ReturnType!func exceptionHandlerWrapper(Parameters!func args) nothrow @system
    {
        try
        {
            return func(args);
        }
        catch(Throwable t)
        {
            auto message = "Unhandled exception: " ~ t.message.assumeWontThrow ~ "\r\n\r\n" ~ unhandledExceptionMessage;

            MessageBox(null, message.toUTF16z, programName.ptr, MB_ICONERROR | MB_SYSTEMMODAL).assumeWontThrow;

            assert(0);
        }
    }
}

================================================
FILE: src/keynavish/grid.d
================================================
module keynavish.grid;

import core.sys.windows.windows : RECT, HDC, HPEN, HFONT;
import std.container : SList;
import std.typecons : Tuple;
import keynavish;

struct Grid
{
    RECT rect;
    int rows;
    int columns;
}

private Grid grid_;
private SList!Grid gridStack;

HPEN mainPen;
HPEN borderPen;
HFONT labelFont;

enum GridNavState
{
    row,
    column,
}

bool gridNavEnabled;
GridNavState gridNavState = GridNavState.row;
int gridNavRow = -1;
int gridNavColumn = -1;

void enableGridNav(bool enabled)
{
    gridNavEnabled = enabled;
    gridNavState = GridNavState.row;
    gridNavRow = -1;
    gridNavColumn = -1;
}

void resetGridNavSelection()
{
    gridNavState = GridNavState.row;
    gridNavRow = -1;
    gridNavColumn = -1;
}

@property
Tuple!(int, "width", int, "height") primaryDeviceResolution()
{
    import core.sys.windows.windows : GetDC, GetDeviceCaps, HORZRES, VERTRES;

    auto rootDeviceContext = GetDC(null);

    auto resolution = typeof(return)();
    resolution.width = GetDeviceCaps(rootDeviceContext, HORZRES);
    resolution.height = GetDeviceCaps(rootDeviceContext, VERTRES);

    return resolution;
}

@property
RECT[] displayRectangles()
{
    import core.sys.windows.windows : EnumDisplayMonitors, MONITORENUMPROC, BOOL, TRUE, HMONITOR, HDC, LPRECT, LPARAM;

    RECT[] displayRectangles = [];

    static extern(Windows) BOOL callback(HMONITOR, HDC, LPRECT rectangle, LPARAM userData)
    {
        RECT[]* displayRectangles = cast(RECT[]*) cast(void*) userData;

        *displayRectangles ~= *rectangle;

        return TRUE;
    }

    EnumDisplayMonitors(null, null, &callback, cast(LPARAM) cast(void*) &displayRectangles);

    return displayRectangles;
}

@property
Tuple!(int, "width", int, "height", int, "left", int, "top") virtualScreenRectangle()
{
    import core.sys.windows.windows : GetSystemMetrics, SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN, SM_XVIRTUALSCREEN, SM_YVIRTUALSCREEN;

    auto virtualScreen = typeof(return)();
    virtualScreen.width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
    virtualScreen.height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
    virtualScreen.left = GetSystemMetrics(SM_XVIRTUALSCREEN);
    virtualScreen.top = GetSystemMetrics(SM_YVIRTUALSCREEN);

    return virtualScreen;
}

const(Grid) grid()
{
    return grid_;
}

void grid(Grid newGrid)
{
    if (newGrid == grid) return;

    gridStack.insertFront(grid);
    grid_ = newGrid;
}

void tryPopGrid()
{
    if (gridStack.empty) return;

    grid_ = gridStack.front;
    gridStack.removeFront();
}

void resetGrid()
{
    import core.sys.windows.windows : POINT, GetCursorPos;
    import std.algorithm : find;
    import std.range : empty;

    POINT cursorPosition;
    auto result = GetCursorPos(&cursorPosition);
    assert(result);

    auto cursorScreen = displayRectangles.find!(r => r.contains(cursorPosition));
    assert(!cursorScreen.empty);

    grid_.rect = cursorScreen[0];
    grid_.rows = 2;
    grid_.columns = 2;
    gridStack = typeof(gridStack)();
}

private const(RECT[]) splitGrid()
{
    import std.algorithm : cartesianProduct, map;
    import std.range : array, iota;

    auto x = grid.rect.left;
    auto y = grid.rect.top;
    auto width = grid.rect.width / grid.columns;
    auto height = grid.rect.height / grid.rows;

    return cartesianProduct(grid.columns.iota, grid.rows.iota).map!(t => t.rename!("x", "y"))
            .map!(t => RECT(x + t.x * width, y + t.y * height, x + (t.x + 1) * width, y + (t.y + 1) * height))
            .array;
}

void paintGrid(HDC deviceContext)
{
    import core.sys.windows.windows : DWORD, POINT, PolyPolyline, SelectObject, SetBkMode, SetTextColor, GetTextExtentPoint32, TextOut, Rectangle, TRANSPARENT, RGB, SIZE, HGDIOBJ, GetStockObject, DC_BRUSH, SetDCBrushColor;
    import std.algorithm : map;
    import std.range : repeat, join, array;
    import std.utf : toUTF16z;

    auto virtualScreen = virtualScreenRectangle;
    auto cells = splitGrid;

    auto pointArrays = cells.map!(r => [
        POINT(r.left, r.top),
        POINT(r.right, r.top),
        POINT(r.right, r.bottom),
        POINT(r.left, r.bottom),
        POINT(r.left, r.top)
    ].map!(p => POINT(p.x - virtualScreen.left, p.y - virtualScreen.top))).join;

    DWORD[] sizes = uint(5).repeat(pointArrays.length).array;

    SelectObject(deviceContext, borderPen);
    PolyPolyline(deviceContext, pointArrays.ptr, sizes.ptr, grid.columns * grid.rows);

    SelectObject(deviceContext, mainPen);
    PolyPolyline(deviceContext, pointArrays.ptr, sizes.ptr, grid.columns * grid.rows);

    if (!gridNavEnabled) return;

    auto oldFont = SelectObject(deviceContext, cast(HGDIOBJ) labelFont);
    auto oldBrush = SelectObject(deviceContext, GetStockObject(DC_BRUSH));
    auto oldBkMode = SetBkMode(deviceContext, TRANSPARENT);

    scope(exit)
    {
        SelectObject(deviceContext, oldBrush);
        SelectObject(deviceContext, oldFont);
        SetBkMode(deviceContext, oldBkMode);
    }

    SIZE textSize;
    auto sampleText = "AA".toUTF16z;
    GetTextExtentPoint32(deviceContext, sampleText, 2, &textSize);

    foreach (column; 0 .. grid.columns)
    {
        foreach (row; 0 .. grid.rows)
        {
            auto cell = cells[column * grid.rows + row];
            auto centerX = cell.left + cell.width / 2 - virtualScreen.left;
            auto centerY = cell.top + cell.height / 2 - virtualScreen.top;

            wchar[3] label;
            label[0] = cast(wchar) ('A' + row);
            label[1] = cast(wchar) ('A' + column);
            label[2] = 0;

            auto labelWidth = textSize.cx + 25;
            auto labelHeight = textSize.cy + 8;
            auto labelRectangle = RECT(centerX - labelWidth / 2, centerY - labelHeight / 2, centerX + labelWidth / 2, centerY + labelHeight / 2);

            auto rowSelected = gridNavState == GridNavState.column && gridNavRow == row;

            SetDCBrushColor(deviceContext, rowSelected ? RGB(0, 77, 77) : RGB(0, 51, 0));
            Rectangle(deviceContext, labelRectangle.left, labelRectangle.top, labelRectangle.right, labelRectangle.bottom);

            SetTextColor(deviceContext, rowSelected ? RGB(255, 255, 255) : RGB(204, 204, 204));
            auto textX = centerX - textSize.cx / 2;
            auto textY = centerY - textSize.cy / 2;
            TextOut(deviceContext, textX, textY, label.ptr, 2);
        }
    }
}


================================================
FILE: src/keynavish/helpers.d
================================================
module keynavish.helpers;

import keynavish;
import core.sys.windows.windows;

LONG width(RECT rect)
{
    return rect.right - rect.left;
}

LONG height(RECT rect)
{
    return rect.bottom - rect.top;
}

bool contains(RECT rect, POINT point)
{
    return point.x >= rect.left && point.x < rect.right &&
           point.y >= rect.top && point.y < rect.bottom;
}

string expandPath(string inputString)
{
    import std.process : environment;
    import std.algorithm : canFind;
    import std.array : replace;

    if (inputString.canFind('~'))
    {
        auto homeDir = environment.get("HOME", environment.get("USERPROFILE"));

        if (homeDir is null)
        {
            showWarning(inputString ~ ": USERPROFILE and HOME environment variables both missing, defaulting to working dir for path expansion");
            homeDir = ".";
        }

        inputString = inputString.replace("~", homeDir);
    }

    return inputString.replace("/", "\\");
}

string[][] parseCommaDelimitedCommands(string input)
{
    import std.csv : csvReader, Malformed;
    import std.algorithm : map;
    import std.array : array;
    import std.string : strip;

    //abusing csvReader so quoted strings are handled properly
    return input.csvReader!(string, Malformed.ignore).front
                .map!strip
                .map!(c => c.csvReader!(string, Malformed.ignore)(' ').front.array)
                .array;
}

================================================
FILE: src/keynavish/keyboardinput.d
================================================
module keynavish.keyboardinput;

import core.sys.windows.windows;
import std.typecons : Nullable, BitFlags;
import keynavish;

static this()
{
    registerKeyBinding("clear");
    registerKeyBinding("ctrl+semicolon start");
    registerKeyBinding("Escape end");
    registerKeyBinding("ctrl+bracketleft end");
    registerKeyBinding("q record ~/.keynav_macros");
    registerKeyBinding("shift+at playback");
    registerKeyBinding("a history-back");
    registerKeyBinding("h cut-left");
    registerKeyBinding("j cut-down");
    registerKeyBinding("k cut-up");
    registerKeyBinding("l cut-right");
    registerKeyBinding("shift+h move-left");
    registerKeyBinding("shift+j move-down");
    registerKeyBinding("shift+k move-up");
    registerKeyBinding("shift+l move-right");
    registerKeyBinding("space warp,click 1,end");
    registerKeyBinding("Return warp,click 1,end");
    registerKeyBinding("semicolon warp,end");
    registerKeyBinding("w warp");
    registerKeyBinding("t windowzoom");
    registerKeyBinding("c cursorzoom 300 300");
    registerKeyBinding("e end");
    registerKeyBinding("1 click 1");
    registerKeyBinding("2 click 2");
    registerKeyBinding("3 click 3");
    registerKeyBinding("ctrl+h cut-left");
    registerKeyBinding("ctrl+j cut-down");
    registerKeyBinding("ctrl+k cut-up");
    registerKeyBinding("ctrl+l cut-right");
    registerKeyBinding("y cut-left,cut-up");
    registerKeyBinding("u cut-right,cut-up");
    registerKeyBinding("b cut-left,cut-down");
    registerKeyBinding("n cut-right,cut-down");
    registerKeyBinding("shift+y move-left,move-up");
    registerKeyBinding("shift+u move-right,move-up");
    registerKeyBinding("shift+b move-left,move-down");
    registerKeyBinding("shift+n move-right,move-down");
    registerKeyBinding("ctrl+y cut-left,cut-up");
    registerKeyBinding("ctrl+u cut-right,cut-up");
    registerKeyBinding("ctrl+b cut-left,cut-down");
    registerKeyBinding("ctrl+n cut-right,cut-down");
}

enum ModifierKey
{
    none   = 0,
    ctrl   = 1 << 0,
    shift  = 1 << 1,
    alt    = 1 << 2,
    super_ = 1 << 3,
}

struct KeyCombination
{
    DWORD vkCode;
    BitFlags!ModifierKey modifiers;
}

struct KeyBinding
{
    KeyCombination keyCombination;
    string[][] commands;
}

KeyBinding[] regularKeyBindings;
KeyBinding[] startKeyBindings;

void registerKeyboardHook()
{
    SetWindowsHookEx(WH_KEYBOARD_LL, &exceptionHandlerWrapper!lowLevelKeyboardProc, GetModuleHandle(null), 0);
}

Nullable!KeyBinding parseKeyBindingString(string bindingString)
{
    import std.algorithm : findSplit, map, until, startsWith;
    import std.array : array;
    import std.format : format;
    import std.conv : to;
    import std.string : strip, split;

    //strip comments, whitespace, and stop if string is empty
    bindingString = bindingString.until('#').to!string.strip;
    if (bindingString.length == 0)
    {
        return typeof(return)();
    }

    if (bindingString.startsWith("daemonize", "clear", "loadconfig", "x-set-delay"))
    {
        auto command = bindingString.parseCommaDelimitedCommands()[0];
        verifyCommand(command) && processCommand(command);
        return typeof(return)();
    }

    auto parts = bindingString.findSplit(" ");

    string[] keyStrings = parts[0].split('+');

    string[][] commands = parts[2].parseCommaDelimitedCommands();

    auto keyCombination = keyStrings.parseKeyCombination();
    if (!verifyCommands(commands) || keyCombination.isNull)
    {
        return typeof(return)();
    }

    return typeof(return)(KeyBinding(keyCombination.get(), commands));
}

Nullable!KeyCombination parseKeyCombination(string[] keyStrings)
{
    //TODO: Refactor
    //TODO: Add more keys from X11/keysymdef.h

    KeyCombination combination;

    foreach (keyString; keyStrings)
    {
        bool setVkCode(DWORD vkCode)
        {
            if (combination.vkCode != 0)
            {
                showError("More than one non-modifier key given: " ~ keyString);
                return false;
            }
            combination.vkCode = vkCode;
            return true;
        }

        switch (keyString)
        {
            case "ctrl":
                combination.modifiers |= ModifierKey.ctrl;
                break;
            case "alt":
                combination.modifiers |= ModifierKey.alt;
                break;
            case "shift":
                combination.modifiers |= ModifierKey.shift;
                break;
            case "super":
                combination.modifiers |= ModifierKey.super_;
                break;
            case "Super_L":
                if (!setVkCode(VK_LWIN)) return typeof(return)();
                break;
            case "Super_R":
                if (!setVkCode(VK_RWIN)) return typeof(return)();
                break;
            case "semicolon":
                if (!setVkCode(VK_OEM_1)) return typeof(return)();
                break;
            case "Escape":
                if (!setVkCode(VK_ESCAPE)) return typeof(return)();
                break;
            case "Tab":
                if (!setVkCode(VK_TAB)) return typeof(return)();
                break;
            case "Left":
                if (!setVkCode(VK_LEFT)) return typeof(return)();
                break;
            case "Up":
                if (!setVkCode(VK_UP)) return typeof(return)();
                break;
            case "Right":
                if (!setVkCode(VK_RIGHT)) return typeof(return)();
                break;
            case "Down":
                if (!setVkCode(VK_DOWN)) return typeof(return)();
                break;
            case "Insert":
                if (!setVkCode(VK_INSERT)) return typeof(return)();
                break;
            case "Home":
                if (!setVkCode(VK_HOME)) return typeof(return)();
                break;
            case "End":
                if (!setVkCode(VK_END)) return typeof(return)();
                break;
            case "Prior":
            case "Page_Up":
                if (!setVkCode(VK_PRIOR)) return typeof(return)();
                break;
            case "Next":
            case "Page_Down":
                if (!setVkCode(VK_NEXT)) return typeof(return)();
                break;
            case "Delete":
                if (!setVkCode(VK_DELETE)) return typeof(return)();
                break;
            case "Return":
                if (!setVkCode(VK_RETURN)) return typeof(return)();
                break;
            case "space":
                if (!setVkCode(VK_SPACE)) return typeof(return)();
                break;
            case "bracketleft":
                if (!setVkCode(VK_OEM_4)) return typeof(return)();
                break;
            case "backslash":
                if (!setVkCode(VK_OEM_5)) return typeof(return)();
                break;
            case "bracketright":
                if (!setVkCode(VK_OEM_6)) return typeof(return)();
                break;
            case "at":
                //HACK: This doesn't have its own vkcode on Windows, but on X11 it has its own keysym
                if (!setVkCode('2')) return typeof(return)();
                break;
            case "plus":
                if (!setVkCode(VK_OEM_PLUS)) return typeof(return)();
                break;
            case "comma":
                if (!setVkCode(VK_OEM_COMMA)) return typeof(return)();
                break;
            case "minus":
                if (!setVkCode(VK_OEM_MINUS)) return typeof(return)();
                break;
            case "period":
                if (!setVkCode(VK_OEM_PERIOD)) return typeof(return)();
                break;
            case "a":
            case "b":
            case "c":
            case "d":
            case "e":
            case "f":
            case "g":
            case "h":
            case "i":
            case "j":
            case "k":
            case "l":
            case "m":
            case "n":
            case "o":
            case "p":
            case "q":
            case "r":
            case "s":
            case "t":
            case "u":
            case "v":
            case "w":
            case "x":
            case "y":
            case "z":
                if(!setVkCode('A' + (keyString[0] - 'a'))) return typeof(return)();
                break;
            case "0":
            case "1":
            case "2":
            case "3":
            case "4":
            case "5":
            case "6":
            case "7":
            case "8":
            case "9":
                if (!setVkCode(keyString[0])) return typeof(return)();
                break;
            case "KP_0":
            case "KP_1":
            case "KP_2":
            case "KP_3":
            case "KP_4":
            case "KP_5":
            case "KP_6":
            case "KP_7":
            case "KP_8":
            case "KP_9":
                if (!setVkCode(0x60 + keyString[3] - '0')) return typeof(return)();
                break;
            default:
                showError("Unknown key: " ~ keyString);
                return typeof(return)();
        }
    }

    return typeof(return)(combination);
}

bool registerKeyBinding(string bindingString)
{
    import std.algorithm : find;
    import std.range : empty;

    auto nullableKeyBinding = bindingString.parseKeyBindingString();
    if (nullableKeyBinding.isNull)
    {
        return false;
    }
    auto keyBinding = nullableKeyBinding.get();

    if (keyBinding.commands[0][0] == "start")
    {
        startKeyBindings ~= keyBinding;
    }
    else
    {
        auto originalBinding = regularKeyBindings.find!(b => b.keyCombination == keyBinding.keyCombination);
        if (!originalBinding.empty)
        {
            originalBinding[0] = keyBinding;
        }
        else
        {
            regularKeyBindings ~= keyBinding;
        }

        if (keyBinding.commands[0][0] == "toggle-start")
        {
            startKeyBindings ~= keyBinding;
        }
    }

    return true;
}

extern(Windows)
LRESULT lowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
    import std.algorithm : find;
    import std.ascii : toLower;
    import std.conv : to;
    import std.range : empty;

    auto hookStruct = cast(PKBDLLHOOKSTRUCT) lParam;

    bool handleGridNavKey(DWORD vkCode, BitFlags!ModifierKey modifiers)
    {
        import core.sys.windows.windows : VK_ESCAPE;

        if (!gridNavEnabled)
        {
            return false;
        }

        if (vkCode == VK_ESCAPE)
        {
            enableGridNav(false);
            redrawWindow();
            return true;
        }

        if (modifiers || vkCode < 'A' || vkCode > 'Z')
        {
            return false;
        }

        auto value = toLower(cast(char) vkCode) - 'a';

        if (gridNavState == GridNavState.row)
        {
            if (value >= grid.rows)
            {
                return false;
            }

            gridNavRow = value;
            gridNavState = GridNavState.column;
            redrawWindow();
            return true;
        }

        if (value >= grid.columns)
        {
            return false;
        }

        gridNavColumn = value;
        cellSelect((gridNavColumn + 1).to!string ~ "x" ~ (gridNavRow + 1).to!string);
        resetGridNavSelection();
        redrawWindow();
        return true;
    }

    if (nCode == HC_ACTION)
    {
        switch (wParam)
        {
            case WM_KEYDOWN:
            case WM_SYSKEYDOWN:
                BitFlags!ModifierKey modifiers = ModifierKey.none;
                modifiers |= (GetKeyState(VK_CONTROL) & 0x8000) != 0 ? ModifierKey.ctrl : ModifierKey.none;
                modifiers |= (GetKeyState(VK_SHIFT  ) & 0x8000) != 0 ? ModifierKey.shift : ModifierKey.none;
                modifiers |= (hookStruct.flags & LLKHF_ALTDOWN) != 0 ? ModifierKey.alt : ModifierKey.none;
                modifiers |= ((GetKeyState(VK_LWIN) & 0x8000) | (GetKeyState(VK_RWIN) & 0x8000)) != 0 ? ModifierKey.super_ : ModifierKey.none;

                auto pressedCombination = KeyCombination(hookStruct.vkCode, modifiers);

                if (!active)
                {
                    auto keyBindingRange = startKeyBindings.find!(b => b.keyCombination == pressedCombination);
                    if (!keyBindingRange.empty)
                    {
                        processCommands(keyBindingRange[0].commands);
                        return 1;
                    }
                    else
                    {
                        return CallNextHookEx(null, nCode, wParam, lParam);
                    }
                }
                else
                {
                    if (waitingForRecordingKey)
                    {
                        setRecordingKey(hookStruct.vkCode);
                    }
                    else if (replaying)
                    {
                        replay(hookStruct.vkCode);
                    }
                    else if (handleGridNavKey(hookStruct.vkCode, modifiers))
                    {
                        return 1;
                    }
                    else
                    {
                        auto keyBindingRange = regularKeyBindings.find!(b => b.keyCombination == pressedCombination);
                        if (!keyBindingRange.empty)
                        {
                            if (recordingActive)
                            {
                                recordCommands(keyBindingRange[0].commands);
                            }
                            processCommands(keyBindingRange[0].commands);
                        }
                    }

                    return ((hookStruct.vkCode >= VK_LSHIFT && hookStruct.vkCode <= VK_RCONTROL) || hookStruct.vkCode == VK_LWIN || hookStruct.vkCode == VK_RWIN)
                        ? CallNextHookEx(null, nCode, wParam, lParam)
                        : 1;
                }
            default:
                break;
        }
    }

    return CallNextHookEx(null, nCode, wParam, lParam);
}


================================================
FILE: src/keynavish/main.d
================================================
module keynavish.main;

import core.sys.windows.windows;
static import std.getopt;
import keynavish;

alias extern(C) int function(string[] args) MainFunc;
extern (C) int _d_run_main(int argc, char **argv, MainFunc mainFunc);

int WinMain_(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    import std.algorithm : map;
    import std.conv : to;
    import std.array : array;
    import std.string : fromStringz;

    int argCount;
    wchar** wideArgs = CommandLineToArgvW(GetCommandLine(), &argCount);
    char** args = wideArgs[0 .. argCount].map!(cs => cs.fromStringz.to!(char[]).ptr).array.ptr;

    return _d_run_main(argCount, args, &_main);
}

extern(Windows)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    return exceptionHandlerWrapper!WinMain_(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
}

static this()
{
    import core.sys.windows.windows : CreateFont, CreatePen, FW_BOLD, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FIXED_PITCH, FF_MODERN, DEFAULT_CHARSET, PS_SOLID;

    registerWindowClass();
    registerKeyboardHook();

    mainPen = CreatePen(PS_SOLID, mainPenWidth, mainPenColour);
    borderPen = CreatePen(PS_SOLID, borderPenWidth * 2 + mainPenWidth, borderPenColour);
    labelFont = CreateFont(18, 0, 0, 0, FW_BOLD, false, false, false, DEFAULT_CHARSET,
                           OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
                           FIXED_PITCH | FF_MODERN, "Courier New"w.ptr);
}

extern(C)
int _main(string[] args)
{
    loadAllConfigs();

    if (handleArgsAndContinue(args))
    {
        createWindow();

        resetGrid();

        addNotifyIcon();

        messageLoop();

        removeNotifyIcon();
    }

    return 0;
}

bool handleArgsAndContinue(string[] args)
{
    import std.getopt;
    import std.algorithm : canFind;

    bool printVersion;
    auto getoptResult = getopt(args, config.passThrough, "version|V", "Program version information.", &printVersion);
    printVersion = printVersion || args.canFind("version");

    if (printVersion)
    {
        showVersion();
        return false;
    }
    else if (getoptResult.helpWanted || args.length > 2)
    {
        showHelp(getoptResult.options);
        return false;
    }
    else
    {
        if (args.length == 2)
        {
            auto commands = args[1].parseCommaDelimitedCommands();
            verifyCommands(commands) && processCommands(commands);
        }
        return true;
    }
}

void showHelp(std.getopt.Option[] getoptOptions)
{
    import std.getopt : defaultGetoptFormatter;
    import std.array : appender;
    import std.conv : to;

    auto helpAppender = appender!(char[]);
    defaultGetoptFormatter(helpAppender, (programInfo ~ "\r\n\r\n"w ~ usageHelpString).to!string, getoptOptions);

    showInfo(helpAppender[]);
}

void showVersion()
{
    showInfo(programName ~ " " ~ gitVersion);
}

void messageLoop()
{
    MSG msg;
    while (GetMessage(&msg, null, 0, 0) && !quitting)
    {
        DispatchMessage(&msg);
    }
}


================================================
FILE: src/keynavish/notifyicon.d
================================================
module keynavish.notifyicon;

import keynavish;

import core.sys.windows.windows;

NOTIFYICONDATA notifyIconData;
HMENU popupMenu;
HKEY registryKey;

//TODO: Error handling

void addNotifyIcon()
{
    auto icon = LoadIcon(LoadLibrary("main.cpl"), MAKEINTRESOURCE(108));

    notifyIconData.uVersion = 0;
    notifyIconData.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
    notifyIconData.hWnd = windowHandle;
    notifyIconData.szTip = programName;
    notifyIconData.hIcon = icon;
    notifyIconData.uCallbackMessage = WM_USER;

    Shell_NotifyIcon(NIM_ADD, &notifyIconData);

    openRegistryKey();
}

void removeNotifyIcon()
{
    Shell_NotifyIcon(NIM_DELETE, &notifyIconData);
}

void handleNotifyIconMessage(WPARAM wParam, LPARAM lParam)
{
    if (lParam == WM_RBUTTONUP || lParam == WM_LBUTTONUP)
    {
        POINT cursorPosition;
        GetCursorPos(&cursorPosition);

        SetForegroundWindow(windowHandle);
        createPopUpMenu();

        auto alignment = GetSystemMetrics(SM_MENUDROPALIGNMENT) != 0 ? TPM_RIGHTALIGN : TPM_LEFTALIGN;
        auto command = cast(MenuItem) TrackPopupMenu(popupMenu,
                                                     alignment | TPM_BOTTOMALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD,
                                                     cursorPosition.x,
                                                     cursorPosition.y,
                                                     0,
                                                     windowHandle,
                                                     null);

        handleCommand(command);
    }
}

void handleCommand(MenuItem menuItem)
{
    final switch (menuItem) with (MenuItem)
    {
        case Help:
            ShellExecute(null, "open", programUrl, null, null, SW_SHOWNORMAL);
            break;
        case ToggleLaunchOnStartup:
            toggleLaunchValue();
            break;
        case EditConfigFile:
            editConfigFile();
            break;
        case ReloadConfig:
            loadAllConfigs();
            break;
        case About:
            showInfo(programInfo);
            break;
        case Restart:
            restart();
            break;
        case Exit:
            PostQuitMessage(0);
            break;
        case None:
            break;
    }
}

enum MenuItem
{
    None,
    Help,
    ToggleLaunchOnStartup,
    EditConfigFile,
    ReloadConfig,
    About,
    Restart,
    Exit
}

void createPopUpMenu()
{
    import std.format : format;
    import std.utf : toUTF16z;

    if (popupMenu)
    {
        DestroyMenu(popupMenu);
    }

    popupMenu = CreatePopupMenu();

    void addSeparator()
    {
        InsertMenu(popupMenu, -1, MF_BYPOSITION | MF_SEPARATOR, 0, null);
    }

    void addStringItem(alias formatString, MenuItem menuItem, Args...)(Args args)
    {
        InsertMenu(popupMenu, -1, MF_BYPOSITION | MF_STRING, menuItem, format!formatString(args).toUTF16z);
    }

    void addCheckboxItem(alias formatString, MenuItem menuItem, Args...)(bool checked, Args args)
    {
        InsertMenu(popupMenu, -1, MF_BYPOSITION | (checked ? MF_CHECKED : MF_UNCHECKED), menuItem, format!formatString(args).toUTF16z);
    }

    addStringItem!("About %s (%s)...", MenuItem.About)(programName, gitVersion);
    addStringItem!("Home page", MenuItem.Help);
    addSeparator();
    addCheckboxItem!("Launch %s on startup", MenuItem.ToggleLaunchOnStartup)(launchValueExists, programName);
    addStringItem!("Edit config file", MenuItem.EditConfigFile);
    addStringItem!("Reload configuration", MenuItem.ReloadConfig);
    addSeparator();
    addStringItem!("Restart %s", MenuItem.Restart)(programName);
    addStringItem!("Exit", MenuItem.Exit);
}

void openRegistryKey()
{
    auto result = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_READ | KEY_SET_VALUE, &registryKey);
    assert(result == ERROR_SUCCESS);
}

bool launchValueExists()
{
    return RegQueryValueExW(registryKey, programName.ptr, null, null, null, null) != ERROR_FILE_NOT_FOUND;
}

void toggleLaunchValue()
{
    import core.runtime : Runtime;
    import std.algorithm : map;
    import std.string : join;
    import std.conv : to;
    import std.utf : toUTF16z;

    if (launchValueExists)
    {
        RegDeleteValue(registryKey, programName.ptr);
    }
    else
    {
        //HACK: We should properly quote the strings when necessary
        auto launchValue = Runtime.args.map!(s => '"' ~ s ~ '"').join(' ');

        RegSetValueEx(registryKey, programName.ptr, 0, REG_SZ, cast(ubyte*) launchValue.toUTF16z, cast(uint) (launchValue.length * wchar.sizeof));
    }
}

void editConfigFile()
{
    import std.file : exists, write;
    import std.range : empty;
    import std.algorithm : map, find;
    import std.utf : toUTF16z;
    import std.format : format;

    string path;

    auto configFileRange = configFilePaths.map!expandPath.find!exists;
    if (configFileRange.empty)
    {
        path = configFilePaths[0].expandPath;

        auto result = MessageBox(null,
                                 format!"No config file found, one will be created at %s. Would you like to use an example config?"(path).toUTF16z,
                                 programName.ptr,
                                 MB_YESNOCANCEL);
        if (result == IDCANCEL)
        {
            return;
        }
        else if (result == IDYES)
        {
            write(path, import("keynavrc"));
        }
        else if (result == IDNO)
        {
            write(path, []);
        }
        else
        {
            assert(false);
        }
    }
    else
    {
        path = configFileRange[0];
    }

    ShellExecute(null, "open", path.toUTF16z, null, null, SW_SHOWNORMAL);
}

================================================
FILE: src/keynavish/package.d
================================================
module keynavish;

public import keynavish.versioninfo;
public import keynavish.config;

public import keynavish.errorhandling;
public import keynavish.helpers;

public import keynavish.commands;
public import keynavish.grid;
public import keynavish.keyboardinput;
public import keynavish.window;
public import keynavish.recording;
public import keynavish.notifyicon;

================================================
FILE: src/keynavish/recording.d
================================================
module keynavish.recording;

import keynavish;

import core.sys.windows.windows : DWORD;

struct Recording
{
    DWORD vkCode;
    string[][] commands;
    string path;

    string toString()
    {
        import std.algorithm : map;
        import std.string : join;
        import std.format : format;

        return format!"%d %s\r\n"(vkCode, commands.map!(c => c.join(' ')).join(", "));
    }
}

Recording[] recordings;

bool waitingForRecordingKey;
Recording activeRecording;

bool replaying;

bool recordingActive()
{
    return activeRecording.vkCode != 0;
}

void loadRecordings()
{
    import std.algorithm : map, filter, joiner, splitter, findSplit, find;
    import std.file : exists, readText;
    import std.conv : to;
    import std.array : replace, array;
    import std.string : strip;
    import std.format : format;
    import std.range : empty;

    foreach (path; regularKeyBindings.map!(b => b.commands)
                                        .joiner
                                        .filter!(c => c[0] == "record" && c.length == 2)
                                        .map!(c => expandPath(c[1]))
                                        .filter!(p => p.exists))
    {
        foreach (line; path.readText.replace('\r', "").splitter('\n'))
        {
            auto parts = line.findSplit(" ");

            if (parts[0].length == 0)
                continue;

            auto vkCode = parts[0].to!DWORD;

            auto commands = parts[2].parseCommaDelimitedCommands();

            auto recording = Recording(vkCode, commands, path);
            auto recordingRange = recordings.find!(r => r.vkCode == vkCode);
            if (!recordingRange.empty)
            {
                showWarning(format!"More than one recording found for key code '%d', last one will be used!"(vkCode));
                recordingRange[0] = recording;
            }
            else
            {
                recordings ~= recording;
            }
        }
    }
}

void startReplaying()
{
    replaying = true;
}

void replay(DWORD vkCode)
{
    import std.algorithm : find;
    import std.range : empty;
    import std.format : format;

    auto recordingRange = recordings.find!(r => r.vkCode == vkCode);
    if (recordingRange.empty)
    {
        showWarning(format!"No recording found for key code '%d'!"(vkCode));
    }
    else
    {
        processCommands(recordingRange[0].commands);
    }

    replaying = false;
}

void startRecording(string path)
{
    waitingForRecordingKey = true;

    activeRecording.path = path.expandPath;
}

void stopRecording()
{
    import std.algorithm : find, filter, map;
    import std.range: empty;
    import std.array : join;
    import std.file : write, exists;
    import std.path : dirName;

    auto recordingRange = recordings.find!(r => r.vkCode == activeRecording.vkCode);
    if (recordingRange.empty)
    {
        recordings ~= activeRecording;
    }
    else
    {
        recordingRange[0] = activeRecording;
    }

    if (activeRecording.path != null)
    {
        auto recordingText = recordings.filter!(r => r.path == activeRecording.path).map!(r => r.toString).join;

        if (!activeRecording.path.dirName.exists)
        {
            showError("Can't save recording, parent dir doesn't exist: " ~ activeRecording.path.dirName);
        }
        else
        {
            activeRecording.path.write(recordingText);
        }
    }

    activeRecording = Recording();
}

void setRecordingKey(DWORD vkCode)
{
    activeRecording.vkCode = vkCode;

    waitingForRecordingKey = false;
}

void recordCommands(string[][] commands)
{
    foreach (command; commands)
    {
        if (command[0] == "record")
        {
            break;
        }

        activeRecording.commands ~= command;
    }
}

================================================
FILE: src/keynavish/window.d
================================================
module keynavish.window;

import core.sys.windows.windows;
import keynavish;

HWND windowHandle;

bool active;
bool quitting;

UINT taskbarCreatedMessage;

void registerWindowClass()
{
    WNDCLASSEX windowsClassEx;
    windowsClassEx.style = CS_HREDRAW | CS_VREDRAW;
    windowsClassEx.lpfnWndProc = &exceptionHandlerWrapper!windowProc;
    windowsClassEx.hInstance = GetModuleHandle(null);
    windowsClassEx.hbrBackground = CreateSolidBrush(windowColourKey);
    windowsClassEx.lpszClassName = windowClassName.ptr;

    RegisterClassEx(&windowsClassEx);
}

void createWindow()
{
    auto resolution = virtualScreenRectangle;

    windowHandle = CreateWindowEx(WS_EX_LAYERED | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE | WS_EX_TRANSPARENT | WS_EX_TOPMOST,
                                  windowClassName.ptr,
                                  programName.ptr,
                                  WS_POPUP,
                                  0,
                                  0,
                                  resolution.width,
                                  resolution.height,
                                  null,
                                  null,
                                  GetModuleHandle(null),
                                  null);

    SetLayeredWindowAttributes(windowHandle, windowColourKey, 0, LWA_COLORKEY);
    SetWindowPos(windowHandle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}

void showWindow()
{
    active = true;

    ShowWindow(windowHandle, SW_SHOW);
    UpdateWindow(windowHandle);
}

void hideWindow()
{
    active = false;

    ShowWindow(windowHandle, SW_HIDE);
    UpdateWindow(windowHandle);
}

extern(Windows)
LRESULT windowProc(HWND handle, UINT message, WPARAM wParam, LPARAM lParam)
{
    assert(handle == windowHandle || windowHandle == null);

    switch (message)
    {
        case WM_CREATE:
            taskbarCreatedMessage = RegisterWindowMessage("TaskbarCreated");
            goto default;
        case WM_PAINT:
            PAINTSTRUCT ps;
            auto deviceContext = BeginPaint(handle, &ps);
            paintGrid(deviceContext);
            EndPaint(handle, &ps);
            break;
        case WM_DESTROY:
        case WM_QUIT:
            quitting = true;
            break;
        case WM_USER:
            handleNotifyIconMessage(wParam, lParam);
            break;
        default:
            if (message == taskbarCreatedMessage)
            {
                removeNotifyIcon();
                addNotifyIcon();
            }

            return DefWindowProc(handle, message, wParam, lParam);
    }
    return 0;
}


================================================
FILE: tools/LICENSE.LLVM
================================================
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

    TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

    1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

    2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

    3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

    4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

    5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

    6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

    7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

    8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

    9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

    END OF TERMS AND CONDITIONS

    APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

    Copyright [yyyy] [name of copyright owner]

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.


--- LLVM Exceptions to the Apache 2.0 License ----

As an exception, if, as a result of your compiling your source code, portions
of this Software are embedded into an Object form of such source code, you
may redistribute such embedded portions in such Object form without complying
with the conditions of Sections 4(a), 4(b) and 4(d) of the License.

In addition, if you combine or link compiled forms of this Software with
software that is licensed under the GPLv2 ("Combined Software") and if a
court of competent jurisdiction determines that the patent provision (Section
3), the indemnity provision (Section 9) or other Section of the License
conflicts with the conditions of the GPLv2, you may retroactively and
prospectively choose to deem waived or otherwise exclude such Section(s) of
the License, but only in their entirety and only with respect to the Combined
Software.



================================================
FILE: tools/README.md
================================================
# Tools

This directory contains tools required for building the project.

## llvm-rc.exe

This tool is used to compile .rc files to .res, and is part of the LLVM
Project, which is under the [Apache License v2.0 with LLVM
Exceptions](./LICENSE.LLVM).
Download .txt
gitextract_zeup618b/

├── .gitattributes
├── .github/
│   ├── FUNDING.yml
│   └── workflows/
│       ├── cd.yml
│       └── ci.yml
├── .gitignore
├── LICENSE
├── README.md
├── dub.sdl
├── generate-version-info.bat
├── keynavish.sln
├── keynavish.visualdproj
├── keynavrc
├── src/
│   └── keynavish/
│       ├── commands.d
│       ├── config.d
│       ├── errorhandling.d
│       ├── grid.d
│       ├── helpers.d
│       ├── keyboardinput.d
│       ├── main.d
│       ├── notifyicon.d
│       ├── package.d
│       ├── recording.d
│       └── window.d
└── tools/
    ├── LICENSE.LLVM
    └── README.md
Condensed preview — 25 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (125K chars).
[
  {
    "path": ".gitattributes",
    "chars": 25,
    "preview": "*keynavrc* text eol=crlf\n"
  },
  {
    "path": ".github/FUNDING.yml",
    "chars": 64,
    "preview": "github: [lesderid]\nko_fi: les\ncustom: ['https://paypal.me/les']\n"
  },
  {
    "path": ".github/workflows/cd.yml",
    "chars": 1751,
    "preview": "name: CD\n\non:\n  push:\n    tags:\n    - 'v*'\n\njobs:\n  build:\n    runs-on: windows-latest\n    steps:\n      - name: Checkout"
  },
  {
    "path": ".github/workflows/ci.yml",
    "chars": 761,
    "preview": "name: CI\n\non: [push, pull_request]\n\njobs:\n  build:\n    runs-on: windows-latest\n\n    steps:\n        - name: Checkout keyn"
  },
  {
    "path": ".gitignore",
    "chars": 80,
    "preview": "/Win32/\n/x64/\n/out/\n/.vs/\n/enc_temp_folder/\n/.dub/\n/src/keynavish/versioninfo.*\n"
  },
  {
    "path": "LICENSE",
    "chars": 18092,
    "preview": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 2, June 1991\n\n Copyright (C) 1989, 1991 Fr"
  },
  {
    "path": "README.md",
    "chars": 2612,
    "preview": "# keynavish\n\n[![Latest release](https://img.shields.io/github/v/release/lesderid/keynavish?sort=semver)](https://github."
  },
  {
    "path": "dub.sdl",
    "chars": 343,
    "preview": "name \"keynavish\"\ndescription \"Control the mouse with the keyboard, on Windows.\"\nauthors \"lesderid\"\ncopyright \"Copyright "
  },
  {
    "path": "generate-version-info.bat",
    "chars": 1962,
    "preview": "@ECHO OFF\n\nREM\nREM This file is a bit of a mess, suggestions for alternatives would be\nREM much appreciated.\nREM\n\nSETLOC"
  },
  {
    "path": "keynavish.sln",
    "chars": 1408,
    "preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 16\nVisualStudioVersion = 16.0.3080"
  },
  {
    "path": "keynavish.visualdproj",
    "chars": 15694,
    "preview": "<DProject>\n <ProjectGuid>{9C2A0942-A891-44EF-B55A-F0DBAAC311C1}</ProjectGuid>\n <Config platform=\"Win32\" name=\"Debug\">\n  "
  },
  {
    "path": "keynavrc",
    "chars": 2586,
    "preview": "# Project page; https://github.com/lesderid/keynavish\r\n\r\n# Use 'clear' to blow away any previous keybindings\r\n#clear\r\n\r\n"
  },
  {
    "path": "src/keynavish/commands.d",
    "chars": 21033,
    "preview": "module keynavish.commands;\n\nimport keynavish;\n\nimport core.sys.windows.windows : LONG, DWORD;\n\nDWORD draggingFlag;\nlong "
  },
  {
    "path": "src/keynavish/config.d",
    "chars": 1197,
    "preview": "module keynavish.config;\n\nimport core.sys.windows.windows;\n\nenum windowClassName = \"keynavish-grid\"w;\nenum windowColourK"
  },
  {
    "path": "src/keynavish/errorhandling.d",
    "chars": 1411,
    "preview": "module keynavish.errorhandling;\n\nimport keynavish;\n\nvoid showError(Stringish)(Stringish message)\n{\n    import core.sys.w"
  },
  {
    "path": "src/keynavish/grid.d",
    "chars": 6384,
    "preview": "module keynavish.grid;\n\nimport core.sys.windows.windows : RECT, HDC, HPEN, HFONT;\nimport std.container : SList;\nimport s"
  },
  {
    "path": "src/keynavish/helpers.d",
    "chars": 1415,
    "preview": "module keynavish.helpers;\n\nimport keynavish;\nimport core.sys.windows.windows;\n\nLONG width(RECT rect)\n{\n    return rect.r"
  },
  {
    "path": "src/keynavish/keyboardinput.d",
    "chars": 14086,
    "preview": "module keynavish.keyboardinput;\n\nimport core.sys.windows.windows;\nimport std.typecons : Nullable, BitFlags;\nimport keyna"
  },
  {
    "path": "src/keynavish/main.d",
    "chars": 3088,
    "preview": "module keynavish.main;\n\nimport core.sys.windows.windows;\nstatic import std.getopt;\nimport keynavish;\n\nalias extern(C) in"
  },
  {
    "path": "src/keynavish/notifyicon.d",
    "chars": 5755,
    "preview": "module keynavish.notifyicon;\n\nimport keynavish;\n\nimport core.sys.windows.windows;\n\nNOTIFYICONDATA notifyIconData;\nHMENU "
  },
  {
    "path": "src/keynavish/package.d",
    "chars": 367,
    "preview": "module keynavish;\n\npublic import keynavish.versioninfo;\npublic import keynavish.config;\n\npublic import keynavish.errorha"
  },
  {
    "path": "src/keynavish/recording.d",
    "chars": 3789,
    "preview": "module keynavish.recording;\n\nimport keynavish;\n\nimport core.sys.windows.windows : DWORD;\n\nstruct Recording\n{\n    DWORD v"
  },
  {
    "path": "src/keynavish/window.d",
    "chars": 2608,
    "preview": "module keynavish.window;\n\nimport core.sys.windows.windows;\nimport keynavish;\n\nHWND windowHandle;\n\nbool active;\nbool quit"
  },
  {
    "path": "tools/LICENSE.LLVM",
    "chars": 12263,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "tools/README.md",
    "chars": 251,
    "preview": "# Tools\n\nThis directory contains tools required for building the project.\n\n## llvm-rc.exe\n\nThis tool is used to compile "
  }
]

About this extraction

This page contains the full source code of the lesderid/keynavish GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 25 files (116.2 KB), approximately 30.2k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!