Skip to content

Added support for custom keymaps, added support for yaml configuration and refactored parts to modern C++23#7

Merged
maricn merged 8 commits into
maricn:masterfrom
662929:master
Mar 17, 2023
Merged

Added support for custom keymaps, added support for yaml configuration and refactored parts to modern C++23#7
maricn merged 8 commits into
maricn:masterfrom
662929:master

Conversation

@662929
Copy link
Copy Markdown
Collaborator

@662929 662929 commented Mar 14, 2023

Refactorings:

  • Update syntax to modern C++23
  • Use typealiases
  • Use modern trailing return type function definition syntax
  • Reduce pointer usages
  • Eliminate push_backs by using constructors
  • Eliminate using namespace std littering
  • Eliminate duplication of typenames using auto
  • Eliminate deletes at end of main
  • Eliminate unnecessary heap allocations
  • Eliminate unbraced if statements

Feature(custom keymaps):

  • use a filepath as the single commandline argument to load a custom keymap
  • syntax is the same as in the source: use the names of the keys as in the source
  • each line should contain two key names, space-seperated
  • the mapping maps the key on the left to the key on the right

662929 added 7 commits March 14, 2023 05:22
Refactorings:
- Update syntax to modern C++23
- Use typealiases
- Use modern trailing return type function definition syntax
- Reduce pointer usages
- Eliminate `push_backs` by using constructors
- Eliminate `using namespace std` littering
- Eliminate duplication of typenames using auto
- Eliminate deletes at end of main
- Eliminate unnecessary heap allocations
- Eliminate unbraced if statements
Added support for custom keymappings
Copy link
Copy Markdown
Owner

@maricn maricn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall, i'm very thankful for your contribution - looks great! just a couple of minor comments..

Comment on lines +192 to +230
// special chars
{KEY_E, KEY_ESC},
{KEY_D, KEY_DELETE},
{KEY_B, KEY_BACKSPACE},

// vim home row
{KEY_H, KEY_LEFT},
{KEY_J, KEY_DOWN},
{KEY_K, KEY_UP},
{KEY_L, KEY_RIGHT},

// vim above home row
{KEY_Y, KEY_HOME},
{KEY_U, KEY_PAGEDOWN},
{KEY_I, KEY_PAGEUP},
{KEY_O, KEY_END},

// number row to F keys
{KEY_1, KEY_F1},
{KEY_2, KEY_F2},
{KEY_3, KEY_F3},
{KEY_4, KEY_F4},
{KEY_5, KEY_F5},
{KEY_6, KEY_F6},
{KEY_7, KEY_F7},
{KEY_8, KEY_F8},
{KEY_9, KEY_F9},
{KEY_0, KEY_F10},
{KEY_MINUS, KEY_F11},
{KEY_EQUAL, KEY_F12},

// xf86 audio
{KEY_M, KEY_MUTE},
{KEY_COMMA, KEY_VOLUMEDOWN},
{KEY_DOT, KEY_VOLUMEUP},

// mouse navigation
{BTN_LEFT, BTN_BACK},
{BTN_RIGHT, BTN_FORWARD},
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate mappings?

Copy link
Copy Markdown
Collaborator Author

@662929 662929 Mar 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, they were in the original source.They don't affect the behaviour though, since existent keys get overridden.
Will remove them in a moment.

Comment thread interception-vimproved.cpp
Comment thread interception-vimproved.cpp
@662929 662929 changed the title Added support for custom keymaps and refactored parts to modern C++23 Added support for custom keymaps, added support for yaml configuration and refactored parts to modern C++23 Mar 14, 2023
@662929
Copy link
Copy Markdown
Collaborator Author

662929 commented Mar 14, 2023

I moved to the meson build system for portably including jbeder/yaml-cpp.
I updated the Makefile to reflect that. Some parts of the Makefile could also be handled by meson.
In any case, let me know what you think about where the mappings should come from, and if they should be already determined at compile time.

Comment thread config.yaml
- {from: KEY_D, to: KEY_DELETE}

# possibly even
- layer: KEY_SPACE
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i know this is a future suggestion only, but just a small comment that it would mean a lot of repetition compared to nested approach..

Comment thread config.yaml
Comment on lines +96 to +188
# special chars
- from: KEY_E
to: KEY_ESC

- from: KEY_D
to: KEY_DELETE

- from: KEY_B
to: KEY_BACKSPACE

# vim home row
- from: KEY_H
to: KEY_LEFT

- from: KEY_J
to: KEY_DOWN

- from: KEY_K
to: KEY_UP

- from: KEY_L
to: KEY_RIGHT

# vim above home row
- from: KEY_Y
to: KEY_HOME

- from: KEY_U
to: KEY_PAGEDOWN

- from: KEY_I
to: KEY_PAGEUP

- from: KEY_O
to: KEY_END


# number row to F keys
- from: KEY_1
to: KEY_F1

- from: KEY_2
to: KEY_F2

- from: KEY_3
to: KEY_F3

- from: KEY_4
to: KEY_F4

- from: KEY_5
to: KEY_F5

- from: KEY_6
to: KEY_F6

- from: KEY_7
to: KEY_F7

- from: KEY_8
to: KEY_F8

- from: KEY_9
to: KEY_F9

- from: KEY_0
to: KEY_F10

- from: KEY_MINUS
to: KEY_F11

- from: KEY_EQUAL
to: KEY_F12


# xf86 audio
- from: KEY_M
to: KEY_MUTE

- from: KEY_COMMA
to: KEY_VOLUMEDOWN

- from: KEY_DOT
to: KEY_VOLUMEUP


# mouse navigation
- from: BTN_LEFT
to: BTN_BACK

- from: BTN_RIGHT
to: BTN_FORWARD

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplication

@maricn
Copy link
Copy Markdown
Owner

maricn commented Mar 15, 2023

I moved to the meson build system for portably including jbeder/yaml-cpp. I updated the Makefile to reflect that. Some parts of the Makefile could also be handled by meson. In any case, let me know what you think about where the mappings should come from, and if they should be already determined at compile time.

I think reading config in runtime with fallback to hardcoded/compiled defaults is perfect, as you did.

Copy link
Copy Markdown
Owner

@maricn maricn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks great. If you feel this is ready, I'm approving it.

(at cost of breaking compatibility with future config.yaml structural changes, but i'm sure if we do break them, the changes will be minimal)

@maricn maricn merged commit 779a0cb into maricn:master Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants