Skip to content
Snippets Groups Projects
Commit c2b25b09 authored by mcmlxxix's avatar mcmlxxix
Browse files

use InputLine.attr getter/setter instead of colors.bg/fg. persist control-a...

use InputLine.attr getter/setter instead of colors.bg/fg. persist control-a through multiple Frame.putmsg() calls. add auto_clear setting to Inputline
parent 828671cd
No related branches found
No related tags found
No related merge requests found
......@@ -118,6 +118,7 @@ function Frame(x,y,width,height,attr,parent) {
display:undefined,
data:[],
open:false,
ctrl_a:false,
id:0
}
var settings = {
......@@ -707,7 +708,6 @@ function Frame(x,y,width,height,attr,parent) {
if(str == undefined)
return;
str = str.toString().split('');
var control_a = false;
var curattr = attr;
if(!curattr)
curattr = this.attr;
......@@ -715,7 +715,7 @@ function Frame(x,y,width,height,attr,parent) {
while(str.length > 0) {
var ch = str.shift();
if(control_a) {
if(properties.ctrl_a) {
var k = ch;
if(k)
k = k.toUpperCase();
......@@ -804,12 +804,12 @@ function Frame(x,y,width,height,attr,parent) {
pos.x+=ch.charCodeAt(0)-127;
break;
}
control_a = false;
properties.ctrl_a = false;
}
else {
switch(ch) {
case '\1': /* CTRL-A code */
control_a = true;
properties.ctrl_a = true;
break;
case '\7': /* Beep */
break;
......
......@@ -8,13 +8,15 @@ function InputLine(frame,text) {
var properties = {
frame:undefined,
text:undefined,
attr:undefined,
buffer:[]
};
var settings = {
show_border:true,
show_title:true,
auto_clear:true,
timeout:10,
max_buffer:200
max_buffer:200,
};
/* protected properties */
......@@ -22,12 +24,26 @@ function InputLine(frame,text) {
return properties.frame;
});
this.__defineGetter__("max_buffer",function() {
return properties.max_buffer;
return settings.max_buffer;
});
this.__defineSetter__("max_buffer",function(num) {
if(num > 0 && num < 10000)
settings.max_buffer = Number(num);
});
this.__defineGetter__("auto_clear",function() {
return settings.auto_clear;
});
this.__defineSetter__("auto_clear",function(bool) {
if(typeof bool == "boolean")
settings.auto_clear = bool;
});
this.__defineGetter__("attr",function() {
return properties.frame.attr;
});
this.__defineSetter__("attr",function(num) {
if(num >= 0 && num < 512)
properties.frame.attr = Number(num);
});
this.__defineGetter__("timeout",function() {
return properties.timeout;
});
......@@ -40,12 +56,6 @@ function InputLine(frame,text) {
return properties.buffer;
});
/* public properties */
this.colors = {
bg:BG_BLUE,
fg:WHITE
};
/* public methods */
this.clear = function() {
reset();
......@@ -97,8 +107,7 @@ function InputLine(frame,text) {
return bufferKey(key);
}
}
this.init = function(x,y,w,h,frame) {
var attr = this.colors.bg + this.colors.fg;
this.init = function(x,y,w,h,frame,attr) {
properties.frame = new Frame(x,y,w,h,attr,frame);
properties.frame.v_scroll = false;
properties.frame.h_scroll = true;
......@@ -120,7 +129,7 @@ function InputLine(frame,text) {
if(properties.buffer.length>properties.frame.width)
printBuffer();
else
properties.frame.putmsg(key);
properties.frame.putmsg(key,properties.frame.attr);
return undefined;
}
function backspace() {
......@@ -162,7 +171,8 @@ function InputLine(frame,text) {
}
}
var cmd=properties.buffer;
reset();
if(settings.auto_clear)
reset();
return cmd;
}
function init(frame,text) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment