Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(developer): Cleanup multidimensional array to map #9945

Open
darcywong00 opened this issue Nov 6, 2023 · 0 comments
Open

chore(developer): Cleanup multidimensional array to map #9945

darcywong00 opened this issue Nov 6, 2023 · 0 comments

Comments

@darcywong00
Copy link
Contributor

darcywong00 commented Nov 6, 2023

          We are using a multidimensional array here instead of a map, due to the conversion from Delphi. One day should clean this up

Originally posted by @mcdurdin in #9846 (comment)

Regarding

function TransformSpecialKeys14(FDebug: boolean, sLayoutFile: string): string {
  // Rewrite Special key labels that are only supported in Keyman 14+
  // This code is a little ugly but effective.
  if(!IsKeyboardVersion14OrLater()) {
    for(let i = 0; i < CSpecialText14Map.length; i++) {
      // Assumes the JSON output format will not change
      if(FDebug) {
        sLayoutFile = sLayoutFile.replaceAll('"text": "'+CSpecialText14Map[i][0]+'"', '"text": this._v>13 ? "'+CSpecialText14Map[i][0]+'" : "'+CSpecialText14Map[i][1]+'"');
      } else {
        sLayoutFile = sLayoutFile.replaceAll('"text":"'+CSpecialText14Map[i][0]+'"', '"text":this._v>13?"'+CSpecialText14Map[i][0]+'":"'+CSpecialText14Map[i][1]+'"');
      }
    }
  }
  return sLayoutFile;
}

function TransformSpecialKeys17(FDebug: boolean, sLayoutFile: string): string {
  // Rewrite Special key labels that are only supported in Keyman 17+
  // This code is a little ugly but effective.
  if(!IsKeyboardVersion17OrLater()) {
    for(let i = 0; i < CSpecialText17Map.length; i++) {
      // Assumes the JSON output format will not change
      if(FDebug) {
        sLayoutFile = sLayoutFile.replaceAll('"text": "'+CSpecialText17Map[i][0]+'"', '"text": this._v>16 ? "'+CSpecialText17Map[i][0]+'" : "'+CSpecialText17Map[i][1]+'"');
      } else {
        sLayoutFile = sLayoutFile.replaceAll('"text":"'+CSpecialText17Map[i][0]+'"', '"text":this._v>16?"'+CSpecialText17Map[i][0]+'":"'+CSpecialText17Map[i][1]+'"');
      }
    }
  }
  return sLayoutFile;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant