« get me outta code hell

Vim HJKL keybindings :) - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2019-04-02 08:29:10 -0300
committerFlorrie <towerofnix@gmail.com>2019-04-02 08:29:10 -0300
commitdb24b6377c67006b9f1578ef073f50180442933a (patch)
treeee6a6a4f25d710bac0f83b3473dc651b504fd070
parent253a637e08365ad5d78215f90ca4c4dcbb6680a8 (diff)
Vim HJKL keybindings :)
-rw-r--r--todo.txt4
-rw-r--r--ui.js11
2 files changed, 15 insertions, 0 deletions
diff --git a/todo.txt b/todo.txt
index c0a00e1..9d0fc15 100644
--- a/todo.txt
+++ b/todo.txt
@@ -119,6 +119,7 @@ TODO: A "remove from queue" option for tracks and groups, which removes them
 TODO: After the end of a shuffled queue, the next song from the group of the
       last track is played (and so on, until the group is empty). This seems
       definitely wrong.
+      (Done! At the end of a shuffle queue, it just stops now.)
 
 TODO: Show a preview of where "Jump to" will go while typing.
       (Done!)
@@ -215,3 +216,6 @@ TODO: Don't store duplicate metadata entries (prereq for tags, custom metadata,
 
 TODO: Metadata process status bar.
       (Done!)
+
+TODO: Add Vim arrow keys. Please forgive me.
+      (Done!)
diff --git a/ui.js b/ui.js
index e78caa9..0be43e3 100644
--- a/ui.js
+++ b/ui.js
@@ -35,6 +35,17 @@ const { promisify } = require('util')
 const readFile = promisify(fs.readFile)
 const writeFile = promisify(fs.writeFile)
 
+// Sneaky hack :)
+const addKey = (prop, key) => {
+  const oldFunc = telc[prop]
+  telc[prop] = input => input.toString().toLowerCase() === key || oldFunc(input)
+}
+
+addKey('isDown', 'j')
+addKey('isUp', 'k')
+addKey('isLeft', 'h')
+addKey('isRight', 'l')
+
 class AppElement extends FocusElement {
   constructor() {
     super()