mirror of
https://github.com/slap-editor/slap.git
synced 2024-09-19 08:47:18 +03:00
Throttles selection match finding, render throttling now configurable
This commit is contained in:
parent
3c075a9456
commit
04b337ccd9
@ -7,6 +7,7 @@ var fs = Promise.promisifyAll(require('fs'));
|
||||
var extname = require('path').extname;
|
||||
var chardet = Promise.promisifyAll(require('chardet'));
|
||||
var iconv = require('iconv-lite');
|
||||
var lodash = require('lodash');
|
||||
|
||||
var Slap = require('./Slap');
|
||||
var BaseElement = require('./BaseElement');
|
||||
@ -791,7 +792,7 @@ Editor.prototype._initHandlers = function () {
|
||||
});
|
||||
|
||||
['cursor', 'startSelection'].forEach(function (evt) {
|
||||
self.on(evt, function () {
|
||||
self.on(evt, lodash.throttle(function () {
|
||||
if (self.screen.focused === self) {
|
||||
var selection = self.select();
|
||||
var line = self.line(selection.end.y);
|
||||
@ -804,7 +805,7 @@ Editor.prototype._initHandlers = function () {
|
||||
: [];
|
||||
self.screen.render();
|
||||
}
|
||||
});
|
||||
}, self.options.perf.matchesRenderThrottle));
|
||||
});
|
||||
|
||||
self.on('path', function (path) { self.language(extname(path).slice(1)); });
|
||||
|
@ -32,6 +32,10 @@ function Slap (opts) {
|
||||
self.fileBrowser.focus();
|
||||
|
||||
self.toggleInsertMode();
|
||||
|
||||
self.render = lodash.throttle(function () {
|
||||
return blessed.Screen.prototype.render.apply(self, arguments);
|
||||
}, self.options.perf.renderThrottle);
|
||||
}
|
||||
Slap.prototype.__proto__ = blessed.Screen.prototype;
|
||||
Slap.global = null;
|
||||
@ -205,10 +209,6 @@ Slap.prototype._initHandlers = function () {
|
||||
return BaseElement.prototype._initHandlers.apply(self, arguments);
|
||||
};
|
||||
|
||||
Slap.prototype.render = lodash.throttle(function () {
|
||||
return blessed.Screen.prototype.render.apply(this, arguments);
|
||||
}, 33);
|
||||
|
||||
module.exports = Slap;
|
||||
|
||||
// circular imports
|
||||
|
13
slap.ini
13
slap.ini
@ -42,9 +42,6 @@ bottom = 0
|
||||
[logger]
|
||||
level = "info"
|
||||
|
||||
[perf]
|
||||
profile = false
|
||||
|
||||
;;;;;;;;;;;;
|
||||
; Bindings ;
|
||||
;;;;;;;;;;;;
|
||||
@ -260,3 +257,13 @@ bg = "yellow"
|
||||
|
||||
[button.danger.style.hover]
|
||||
bg = "red"
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;
|
||||
; Performance tweaks ;
|
||||
;;;;;;;;;;;;;;;;;;;;;;
|
||||
[perf]
|
||||
profile = false
|
||||
renderThrottle = 50
|
||||
|
||||
[editor.perf]
|
||||
matchesRenderThrottle = 150
|
||||
|
Loading…
Reference in New Issue
Block a user