diff options
| author | Alee14 <Alee14498@gmail.com> | 2017-08-10 23:06:01 -0400 |
|---|---|---|
| committer | Alee14 <Alee14498@gmail.com> | 2017-08-10 23:06:01 -0400 |
| commit | 563b61b1026c0acc9a567bb9e5aa8f05617c6c33 (patch) | |
| tree | 6ae65169008dd61db42223ebe3cdac1b96b17e4f /abblessed.js | |
| parent | e7bb920e1ca70c74809491f7efb8ccb4a3387e98 (diff) | |
| download | AleeBot-563b61b1026c0acc9a567bb9e5aa8f05617c6c33.tar.gz AleeBot-563b61b1026c0acc9a567bb9e5aa8f05617c6c33.tar.bz2 AleeBot-563b61b1026c0acc9a567bb9e5aa8f05617c6c33.zip | |
Changes
Diffstat (limited to 'abblessed.js')
| -rw-r--r-- | abblessed.js | 136 |
1 files changed, 135 insertions, 1 deletions
diff --git a/abblessed.js b/abblessed.js index 1faa4be..a694345 100644 --- a/abblessed.js +++ b/abblessed.js @@ -1,6 +1,6 @@ var blessed = require('blessed'); var abversion = "1.0.9 Beta"; - +//Some of this code was made by vicr123 // Create a screen object. var screen = blessed.screen({ smartCSR: true @@ -108,6 +108,140 @@ function clearBoxes() { } +logBox.on('click', function(mouse) { + + var x = mouse.x; + + var y = mouse.y; + + + + //var line = logBox.getScreenLines()[y + 1]; + + var line = logBox.getBaseLine(y - 1); + + + + //Remove escapes + + while (line.indexOf("\x1b") != -1) { + + var removeStart = line.indexOf("\x1b"); + + var removeEnd = line.indexOf("m", removeStart); + + line = line.replace(line.slice(removeStart, removeEnd + 1), ""); + + } + + //logBox.log(line); + + + + //Get word around line + + var previousSpace = line.lastIndexOf(" ", x - 2); + + var nextSpace = line.indexOf(" ", x - 2); + + + + previousSpace++; + + + + if (nextSpace == -1) { + + nextSpace = line.length;// - previousSpace; + + } + + var word = line.substring(previousSpace, nextSpace); + + + + if (word.startsWith("[")) word = word.substr(1); + + if (word.endsWith("]")) word = word.substr(0, word.length - 2); + + + + var goUpwards = false; + + var top = y + 1; + + if (top + 7 > screen.height) { + + top = y - 7; + + goUpwards = true; + + } + + + + var left = x - 10; + + if (left + 50 > screen.width) { + + left = screen.width - 50; + + } else if (left < 0) { + + left = 0; + + } + + + + var boxOptions = { + + top: top, + + left: left, + + width: 50, + + style: { + + fg: "black", + + bg: "white", + + border: { + + fg: 'white', + + bg: 'black' + + } + + }, + + border: { + + type: "line" + + }, + + padding: { + + left: 2, + + top: 1, + + right: 2, + + bottom: 1 + + } + + }; + + + + clearBoxes(); + // Quit on Escape, q, or Control-C. screen.key(['q', 'C-c'], function(ch, key) { return process.exit(0); |
