* Some work on cursor hiding while redrawing. WIP.
This commit is contained in:
parent
10d8812300
commit
75bb9e91e4
|
@ -26,6 +26,7 @@ exports.goHome = goHome;
|
|||
exports.disableVT100LineWrapping = disableVT100LineWrapping;
|
||||
exports.setSyncTERMFont = setSyncTERMFont;
|
||||
exports.getSyncTERMFontFromAlias = getSyncTERMFontFromAlias;
|
||||
exports.setCursorStyle = setCursorStyle;
|
||||
exports.fromPipeCode = fromPipeCode;
|
||||
|
||||
|
||||
|
@ -247,6 +248,25 @@ function getSyncTERMFontFromAlias(alias) {
|
|||
return FONT_ALIAS_TO_SYNCTERM_MAP[alias.toLowerCase().replace(/ /g, '_')];
|
||||
}
|
||||
|
||||
var DEC_CURSOR_STYLE = {
|
||||
'blinking block' : 0,
|
||||
'default' : 1,
|
||||
'steady block' : 2,
|
||||
'blinking underline' : 3,
|
||||
'steady underline' : 4,
|
||||
'blinking bar' : 5,
|
||||
'steady bar' : 6,
|
||||
};
|
||||
|
||||
function setCursorStyle(cursorStyle) {
|
||||
var ps = DEC_CURSOR_STYLE[cursorStyle];
|
||||
if(ps) {
|
||||
return ESC_CSI + ps + ' q';
|
||||
}
|
||||
return '';
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
var FONT_MAP = {
|
||||
|
|
|
@ -23,6 +23,7 @@ var ANSI_KEY_NAME_MAP = {
|
|||
0x7f : 'del',
|
||||
0x1b : 'esc',
|
||||
0x0d : 'enter',
|
||||
0x19 : 'ctrl-y'
|
||||
};
|
||||
|
||||
var ANSI_KEY_CSI_NAME_MAP = {
|
||||
|
@ -94,6 +95,8 @@ function Client(input, output) {
|
|||
var c;
|
||||
var name;
|
||||
|
||||
console.log(data)
|
||||
|
||||
if(1 === len) {
|
||||
c = data[0];
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
var TextView = require('./text_view.js').TextView;
|
||||
var miscUtil = require('./misc_util.js');
|
||||
var strUtil = require('./string_util.js');
|
||||
var ansi = require('./ansi_term.js');
|
||||
|
||||
var util = require('util');
|
||||
var assert = require('assert');
|
||||
var _ = require('lodash');
|
||||
|
@ -13,6 +15,7 @@ exports.EditTextView = EditTextView;
|
|||
function EditTextView(options) {
|
||||
options.acceptsFocus = miscUtil.valueWithDefault(options.acceptsFocus, true);
|
||||
options.acceptsInput = miscUtil.valueWithDefault(options.acceptsInput, true);
|
||||
options.cursorStyle = miscUtil.valueWithDefault(options.cursorStyle, 'steady block');
|
||||
options.resizable = false;
|
||||
|
||||
TextView.call(this, options);
|
||||
|
@ -73,6 +76,10 @@ EditTextView.prototype.onSpecialKeyPress = function(keyName) {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if(this.isSpecialKeyMapped('clear', keyName)) {
|
||||
// :TODO: this doesn't work right at all:
|
||||
//this.setText('');
|
||||
//this.client.term.write(ansi.goto(this.position.x, this.position.y));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,20 +13,14 @@ exports.SpinnerMenuView = SpinnerMenuView;
|
|||
|
||||
function SpinnerMenuView(options) {
|
||||
options.justify = options.justify || 'center';
|
||||
options.cursor = options.cursor || 'hide';
|
||||
|
||||
MenuView.call(this, options);
|
||||
|
||||
var self = this;
|
||||
|
||||
this.cachePositions = function() {
|
||||
if(self.positionCacheExpired) {
|
||||
var count = this.items.length;
|
||||
// :TODO: change all xPosition, yPosition -> position.x, .y
|
||||
for(var i = 0; i < count; ++i) {
|
||||
self.items[i].xPosition = self.position.x;
|
||||
}
|
||||
self.positionCacheExpired = false;
|
||||
}
|
||||
};
|
||||
|
||||
this.updateSelection = function() {
|
||||
|
|
|
@ -42,6 +42,7 @@ function TextView(options) {
|
|||
// |ABCDEFG| ^_ this.text.length
|
||||
// ^-- this.dimens.width
|
||||
//
|
||||
console.log(this.position.x)
|
||||
var textToDraw = _.isString(this.textMaskChar) ?
|
||||
new Array(s.length + 1).join(this.textMaskChar) :
|
||||
strUtil.stylizeString(s, this.hasFocus ? this.focusTextStyle : this.textStyle);
|
||||
|
|
16
core/view.js
16
core/view.js
|
@ -18,6 +18,10 @@ var VIEW_SPECIAL_KEY_MAP_DEFAULT = {
|
|||
next : [ 'tab' ],
|
||||
up : [ 'up arrow' ],
|
||||
down : [ 'down arrow' ],
|
||||
|
||||
clear : [ 'ctrl-y' ],
|
||||
end : [ 'end' ],
|
||||
home : [ 'home' ],
|
||||
};
|
||||
|
||||
function View(options) {
|
||||
|
@ -31,6 +35,7 @@ function View(options) {
|
|||
this.client = options.client;
|
||||
|
||||
this.cursor = options.cursor || 'show';
|
||||
this.cursorStyle = options.cursorStyle || 'default';
|
||||
|
||||
this.acceptsFocus = options.acceptsFocus || false;
|
||||
this.acceptsInput = options.acceptsInput || false;
|
||||
|
@ -76,6 +81,15 @@ function View(options) {
|
|||
}
|
||||
return ansi.sgr(sgr);
|
||||
};
|
||||
|
||||
this.hideCusor = function() {
|
||||
self.client.term.write(ansi.hideCursor());
|
||||
};
|
||||
|
||||
this.restoreCursor = function() {
|
||||
//this.client.term.write(ansi.setCursorStyle(this.cursorStyle));
|
||||
this.client.term.write('show' === this.cursor ? ansi.showCursor() : ansi.hideCursor());
|
||||
};
|
||||
}
|
||||
|
||||
util.inherits(View, events.EventEmitter);
|
||||
|
@ -162,7 +176,7 @@ View.prototype.setFocus = function(focused) {
|
|||
assert(this.acceptsFocus, 'View does not accept focus');
|
||||
|
||||
this.hasFocus = focused;
|
||||
this.client.term.write('show' === this.cursor ? ansi.showCursor() : ansi.hideCursor());
|
||||
this.restoreCursor();
|
||||
};
|
||||
|
||||
View.prototype.onKeyPress = function(key, isSpecial) {
|
||||
|
|
Loading…
Reference in New Issue