ImportKeymap.hx 613 B

123456789101112131415161718192021
  1. package arm.io;
  2. import arm.sys.Path;
  3. import arm.sys.File;
  4. class ImportKeymap {
  5. public static function run(path: String) {
  6. if (!Path.isJson(path)) {
  7. Console.error(Strings.error1());
  8. return;
  9. }
  10. var filename = path.substr(path.lastIndexOf(Path.sep) + 1);
  11. var dstPath = Path.data() + Path.sep + "keymap_presets" + Path.sep + filename;
  12. File.copy(path, dstPath); // Copy to preset folder
  13. arm.ui.BoxPreferences.fetchKeymaps(); // Refresh file list
  14. arm.ui.BoxPreferences.presetHandle.position = arm.ui.BoxPreferences.getPresetIndex();
  15. Console.info(tr("Keymap imported:") + " " + filename);
  16. }
  17. }