the-via / app

GNU General Public License v3.0
816 stars 186 forks source link

Feature: Make the JSON save format be aware of the actual keymap #131

Open alanhoyle opened 1 year ago

alanhoyle commented 1 year ago

It would be really cool if the JSON save files was aware of the layout of the actual keyboard. For example, instead of putting one like per key, it would only insert a line break when the keyboard row ended, and inserting a comment for section breaks and a comment for layer names

For example, for a typical 65% keyboard, the current JSON might look something like this (comments added for brevity):

 "layers": [
    [
      "KC_GESC",
      "KC_1",
      "KC_2",
      "KC_3",
      "KC_4",
   // ...rest of row 1...
      "KC_TAB",
      "KC_Q",
      "KC_W",
      "KC_E",
      "KC_R",
   // ...rest of row 2...
      "KC_CAPS",
      "KC_A",
      "KC_S",
      "KC_D",
      "KC_F",
  // to the end....

I imagine it might be easier/nicer for humans to edit if the output looked like this:

 "layers": [
    [
      "KC_GESC", "KC_1",    "KC_2",    "KC_3",    "KC_4",   // ...rest of row 1...
      "KC_TAB",  "KC_Q",    "KC_W",    "KC_E",    "KC_R",  // ...rest of row 2...
      "KC_CAPS", "KC_A",    "KC_S",    "KC_D",    "KC_F",  // to the end....
positivejam commented 1 year ago

Unfortunately, while an actual Javascript file supports comments, json does not.

alanhoyle commented 1 year ago

Even if comments are not possible in JSON (TIL! thanks!), the first part would still be helpful: i.e. inserting linebreaks only at the end of each row in the actual keymap.

I realize this would mean not piping the keymap through a standard JSON pretty-printer afterwards, but it would still be helpful if possible.

positivejam commented 1 year ago

Even if comments are not possible in JSON (TIL! thanks!), the first part would still be helpful: i.e. inserting linebreaks only at the end of each row in the actual keymap.

Seems reasonable, though I'm not very familiar with the codebase myself. I just noticed a question I knew I could give a partial answer to and thought I'd jump in. If a regular contributor or maintainer sees this, they'd be a better bet. Good luck!