-
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
It may not be possible, but this here is a pretty good start:
var child_process = require("child_process");
Barcli.prototype.update = function(data) {
var position = getPosition();
// Update the bar
// Restore to original position
process.stdout.write("\033["+position.row+";"+position.column+"H\033[?25h");
});
function getPosition() {
var output = child_process.execSync("exec < /dev/tty\noldstty=$(stty -g)\nstty raw -echo min 0\necho \"\\033[6n\" > /dev/tty\n\nIFS=\';\' read -r -d R -a pos\nstty $oldstty\nrow=$((${pos[0]:2}))\ncol=$((${pos[1]}))\necho \\{\\\"row\\\":$row, \\\"column\\\":$col\\}");
return JSON.parse(output.toString());
};Right now hitting any key causes the shell script to fail.
Other big problem to solve is how do we keep track of where our barcli graph is as the window scrolls?
Maybe it's possible to read each line in the window and find the bar if it's visible.
Metadata
Metadata
Assignees
Labels
No labels