IPC integration; custom keybinds

toast
Kit Kasune 3 years ago
parent 265d5705df
commit 946020a43a
  1. 5
      json/shortcuts.json
  2. 1
      scripts/fileview/load/render.js
  3. 1
      scripts/fileview/refresh.js
  4. 9
      scripts/keybinds/handle.js
  5. 14
      scripts/keybinds/handleKey.js
  6. 4
      scripts/keybinds/process/devtool.js
  7. 7
      scripts/keybinds/process/handleIpc.js
  8. 3
      scripts/keybinds/process/reload.js
  9. 4
      scripts/keybinds/reload.js
  10. 2
      scripts/renderer.js
  11. 7
      scripts/startup/preload.js

@ -1,4 +1,5 @@
{
"ctrl+r": "reload",
"command+r": "reload"
"ctrl+r": "reload",
"command+r": "reload",
"ctrl+shift+i": "devtool"
}

@ -56,6 +56,7 @@ module.exports = (dir) => {
size.className = 'file-size';
size.innerHTML = file.sizeString;
cfc.appendChild(size);
Array.from(cfc.children).forEach(el => el.classList.add('nosel'));
num++;
}

@ -16,6 +16,7 @@ module.exports = (newPath) => {
let temp = document.createElement('p');
temp.innerHTML = k;
temp.style = `flex-basis: ${headers[k]}%;`;
temp.className = 'nosel';
fh.appendChild(temp);
});
document.getElementById('header-nav').remove();

@ -1,9 +0,0 @@
const mousetrap = require('../dep/mousetrap');
const binds = require('../../json/shortcuts.json');
module.exports = () => {
Object.keys(binds).forEach((bind) => {
mousetrap.bind(bind, require(`./${binds[bind]}.js`));
});
};

@ -0,0 +1,14 @@
const mousetrap = require('../dep/mousetrap');
const electron = require('electron'); const ipc = electron.ipcRenderer;
const binds = require('../../json/shortcuts.json');
module.exports = () => {
const sendIpcMessage = (message) => {
ipc.sendSync('keybind', message);
};
Object.keys(binds).forEach((bind) => {
mousetrap.bind(bind, () => sendIpcMessage(binds[bind]));
});
};

@ -0,0 +1,4 @@
module.exports = (broswerWindow, app) => {
broswerWindow.webContents.openDevTools();
return 'opened inspect element';
};

@ -0,0 +1,7 @@
const {ipcMain: ipc} = require('electron');
module.exports = (browserWindow, app) => {
ipc.on('keybind', (event, arg) => {
try {event.returnValue = require(`./${arg}`)(browserWindow, app);} catch {}
});
};

@ -0,0 +1,3 @@
module.exports = (browserWindow, app) => {
browserWindow.reload();
};

@ -1,4 +0,0 @@
module.exports = () => {
window.reload();
console.log('e');
};

@ -1,5 +1,5 @@
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// be executed in the process process for that window.
// No Node.js APIs are available in this process because
// `nodeIntegration` is turned off. Use `preload.js` to
// selectively enable features needed in the rendering

@ -21,4 +21,11 @@ window.addEventListener('DOMContentLoaded', () => {
if (window.kade.cl) {window.kade.cl.classList.remove('file-active');}
}, 100);
}
require('../keybinds/handleKey')();
});
window.addEventListener('contextmenu', e => {
e.preventDefault();
});
Loading…
Cancel
Save