mirror of
https://github.com/nuintun/command-manager.git
synced 2025-12-20 10:35:53 +08:00
update files
This commit is contained in:
49
bin/terminal/lib/focused.js
Normal file
49
bin/terminal/lib/focused.js
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Created by nuintun on 2015/11/25.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = function (Terminal){
|
||||
Terminal.focus = null;
|
||||
|
||||
/**
|
||||
* isFocused
|
||||
* @returns {boolean}
|
||||
*/
|
||||
Terminal.prototype.isFocused = function (){
|
||||
return Terminal.focus === this;
|
||||
};
|
||||
|
||||
/**
|
||||
* focus
|
||||
*/
|
||||
Terminal.prototype.focus = function (){
|
||||
if (Terminal.focus === this) return;
|
||||
|
||||
if (Terminal.focus) {
|
||||
Terminal.focus.blur();
|
||||
}
|
||||
|
||||
Terminal.focus = this;
|
||||
|
||||
if (this.cursor) {
|
||||
this.showCursor();
|
||||
}
|
||||
|
||||
if (this.cursorBlink) {
|
||||
this.startBlink();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* blur
|
||||
*/
|
||||
Terminal.prototype.blur = function (){
|
||||
if (Terminal.focus !== this) return;
|
||||
|
||||
this.hideCursor();
|
||||
|
||||
Terminal.focus = null;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user