Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions src/parser/AnsiParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ TERM.AnsiParser = function (viewer){
};

this.readByte = function (b) {

if(b == ESCAPE) {
escapeCommand = [];
escapeCommand.push(b);
Expand All @@ -64,22 +63,18 @@ TERM.AnsiParser = function (viewer){
} else {
switch(b) {
case BACKSPACE:
viewer.moveBackward(1, true);
break;

viewer.moveBackward(1, false);
break;
case LINE_FEED:
viewer.carriageReturn();
viewer.moveDown(1);
break;

break;
case CARRIAGE_RETURN:
viewer.carriageReturn();
break;

break;
case FORM_FEED:
viewer.eraseScreen();
viewer.reposition(0, 0);
break;
break;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/parser/CharacterCodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @author Peter Nitsch
*/

const NULL = 0
const NULL = 0;
const START_OF_HEADING = 1;
const START_OF_TEXT = 2;
const END_OF_TEXT = 3;
Expand Down
144 changes: 120 additions & 24 deletions src/parser/EscapeSequencer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ TERM.EscapeSequencer = function (viewer){

this.init = function() {
this.actionCharacterLib[ LATIN_CAPITAL_LETTER_H ] = this.cursorPosition;
this.actionCharacterLib[ LATIN_SMALL_LETTER_F ] = this.cursorPosition;
this.actionCharacterLib[ LATIN_SMALL_LETTER_F ] = this.cursorPosition;
this.actionCharacterLib[ LATIN_CAPITAL_LETTER_G ] = this.cursorPosition;
this.actionCharacterLib[ LATIN_CAPITAL_LETTER_A ] = this.cursorUp;
this.actionCharacterLib[ LATIN_CAPITAL_LETTER_B ] = this.cursorDown;
this.actionCharacterLib[ LATIN_CAPITAL_LETTER_C] = this.cursorForward;
Expand All @@ -28,18 +29,22 @@ TERM.EscapeSequencer = function (viewer){
this.actionCharacterLib[ LATIN_SMALL_LETTER_H ] = this.setMode;
this.actionCharacterLib[ LATIN_SMALL_LETTER_L ] = this.resetMode;
this.actionCharacterLib[ LATIN_SMALL_LETTER_P ] = this.setKeyboardStrings;
this.actionCharacterLib[ LATIN_CAPITAL_LETTER_M ] = this.scrollUp;
this.actionCharacterLib[ LATIN_CAPITAL_LETTER_M ] = this.reverseIndex;
this.actionCharacterLib[ LATIN_SMALL_LETTER_R ] = this.scrollScreen;
this.actionCharacterLib[ LATIN_CAPITAL_LETTER_X ] = this.eraseChars;
this.actionCharacterLib[ LATIN_SMALL_LETTER_N ] = this.reportCursorPos;

// TO DO
this.actionCharacterLib[ LESS_THAN_SIGN ] = this.unused;
this.actionCharacterLib[ GREATER_THAN_SIGN ] = this.unused;
this.actionCharacterLib[ EQUALS_SIGN ] = this.unused;
this.actionCharacterLib[ LATIN_SMALL_LETTER_A ] = this.unused;
this.actionCharacterLib[ LATIN_SMALL_LETTER_D ] = this.unused;
this.actionCharacterLib[ LATIN_SMALL_LETTER_E ] = this.unused;
this.actionCharacterLib[ LATIN_CAPITAL_LETTER_L ] = this.unused;
this.actionCharacterLib[ LATIN_CAPITAL_LETTER_P ] = this.unused;
this.actionCharacterLib[ LATIN_CAPITAL_LETTER_E ] = this.unused;
this.actionCharacterLib[ LATIN_CAPITAL_LETTER_F ] = this.unused;
this.actionCharacterLib[ LATIN_CAPITAL_LETTER_X ] = this.unused;

};

Expand Down Expand Up @@ -116,22 +121,47 @@ TERM.EscapeSequencer = function (viewer){
}
column = parseInt(columnStr);

column = (column>0) ? column-1 : 0;
line = (line>0) ? line-1 : 0;

viewer.reposition(column, line);

} else if(params.slice(2, params.indexOf(lastCharacter)).length > 0){
lineArray = params.slice(2, params.length-1);
for( i=0; i<lineArray.length; i++ ){
lineStr += (lineArray[i] - 48).toString();
if (lastCharacter == LATIN_CAPITAL_LETTER_H || lastCharacter == LATIN_SMALL_LETTER_F ) {
lineArray = params.slice(2, params.length-1);
for( i=0; i<lineArray.length; i++ ){
lineStr += (lineArray[i] - 48).toString();
}
line = parseInt(lineStr);

column = (column>0) ? column-1 : 0;
line = (line>0) ? line-1 : 0;

viewer.reposition(column, line);

} else if (lastCharacter == LATIN_CAPITAL_LETTER_G) {
columnArray = params.slice(2, params.length-1);
for( i=0; i<columnArray.length; i++ ){
columnStr += (columnArray[i] - 48).toString();
}
column = parseInt(columnStr);
column = (column>0) ? column-1 : 0;

viewer.repositionColumn(column);
}
line = parseInt(lineStr);
}

column = (column>0) ? column-1 : 0;
line = (line>0) ? line-1 : 0;

viewer.reposition(column, line);
}
};


this.cursorUp = function(params) {
if (params[1] == LEFT_PARENTHESIS|| params[1] == RIGHT_PARENTHESIS )
{
//Set Alternate char set A
return;
}
var valueArray = params.slice(2, params.length-1);
var valueStr = "";
for( i=0; i<valueArray.length; i++ ){
Expand All @@ -143,17 +173,26 @@ TERM.EscapeSequencer = function (viewer){
};

this.cursorDown = function(params) {
if (params[1] == LEFT_PARENTHESIS|| params[1] == RIGHT_PARENTHESIS )
{
//Set Alternate char set B
return;
}
var valueArray = params.slice(2, params.length-1);
var valueStr = "";
for( i=0; i<valueArray.length; i++ ){
valueStr += (valueArray[i] - 48).toString();
}
var value = (valueStr.length > 0) ? parseInt(valueStr) : 1;

viewer.moveDown(value);
};

this.cursorForward = function(params) {
this.cursorForward = function(params) {
if (params[1] == LEFT_PARENTHESIS|| params[1] == RIGHT_PARENTHESIS )
{
//Set Alternate char set C
return;
}
var valueArray = params.slice(2, params.length-1);
var valueStr = "";
for( i=0; i<valueArray.length; i++ ){
Expand All @@ -165,6 +204,11 @@ TERM.EscapeSequencer = function (viewer){
};

this.cursorBackward = function(params) {
if (params[1] == LEFT_PARENTHESIS|| params[1] == RIGHT_PARENTHESIS )
{
//Set Alternate char set D
return;
}
var valueArray = params.slice(2, params.length-1);
var valueStr = "";
for( i=0; i<valueArray.length; i++ ){
Expand Down Expand Up @@ -253,7 +297,7 @@ TERM.EscapeSequencer = function (viewer){
_currentForegroundColor = (_bold) ? _boldColors[position] : _normalColors[position];
viewer.foregroundColorChanged(_currentForegroundColor);
}

i++;
}
}
break;
Expand All @@ -270,7 +314,7 @@ TERM.EscapeSequencer = function (viewer){
_currentBackgroundColor = _normalColors[position];
viewer.backgroundColorChanged(_currentBackgroundColor);
}

i++;
/* Underline ON */
} else {
// TO DO
Expand All @@ -286,7 +330,13 @@ TERM.EscapeSequencer = function (viewer){
/* Reverse ON */
case DIGIT_SEVEN:
if(params[i-1] == SEMICOLON || params[i-1] == LEFT_SQUARE_BRACKET)
{
_reverse = true;
_currentForegroundColor = viewer.cursor.backgroundColor;
_currentBackgroundColor = viewer.cursor.foregroundColor;
viewer.backgroundColorChanged(viewer.cursor.foregroundColor);
viewer.foregroundColorChanged(_currentForegroundColor);
}
break;

/* Concealed ON */
Expand Down Expand Up @@ -335,20 +385,31 @@ TERM.EscapeSequencer = function (viewer){
}
};

this.scrollUp = function(params) {
viewer.scrollUp(1);
this.reverseIndex = function(params) {
viewer.reverseIndex();
};

this.eraseLine = function(params) {
if( params[2]==DIGIT_ONE ){
viewer.eraseStartOfLine();
} else if( params[2]==DIGIT_TWO ) {
viewer.eraseLine();
} else {
} else if ( params[2]==DIGIT_ONE || params[2]==LATIN_CAPITAL_LETTER_K ){
viewer.eraseEndOfLine();
}
};

this.eraseChars = function(params) {
var valueArray = params.slice(2, params.length-1);
var valueStr = "";
for( i=0; i<valueArray.length; i++ ){
valueStr += (valueArray[i] - 48).toString();
}
var value = (valueStr.length > 0) ? parseInt(valueStr) : 1;
viewer.eraseChars(value);
};


this.eraseDisplay = function(params) {
if( params[2]==DIGIT_ONE ){
viewer.eraseUp();
Expand All @@ -361,19 +422,54 @@ TERM.EscapeSequencer = function (viewer){
}
};

// Terminal functions
this.setMode = function(){
// TO DO
this.reportCursorPos = function(params) {
if (params[2] == DIGIT_SIX){
var x = (viewer.cursor.x / viewer.cursor.columnWidth).toString();
var y = (viewer.cursor.y / viewer.cursor.lineHeight).toString();
var cmd=[];
cmd.push(ESCAPE);
cmd.push(LEFT_SQUARE_BRACKET);
for(var i=0;i<y.length;i++) {
cmd.push(y.charCodeAt(i));
}
cmd.push(SEMICOLON);

for(var i=0;i<x.length;i++) {
cmd.push(x.charCodeAt(i));
}
cmd.push(LATIN_CAPITAL_LETTER_R);
TERM.socket.send(cmd);
}
};

this.resetMode = function(){
// TO DO
this.setMode = function(params){
Util.Debug("Set Mode function : " + params[3]);
if (params[3] == DIGIT_ONE) {
Util.Debug("Set Cursor Keys to Application Mode");
viewer.cursorKeyToAppMode(true);
}
if (params[3] == DIGIT_SEVEN) {
Util.Debug("AutoWrap mode on");
viewer.setAutoWrap(true);
}
};

this.resetMode = function(params){
Util.Debug("Reset Mode function : " + params[3]);
if (params[3] == DIGIT_ONE) {
Util.Debug("Reset Cursor Keys from Application Mode back to Cursor Mode");
viewer.cursorKeyToAppMode(false);
}
if (params[3] == DIGIT_SEVEN) {
Util.Debug("AutoWrap mode off");
viewer.setAutoWrap(false);
}
};

this.setKeyboardStrings = function(){
// TO DO

};

this.init();

};
};
16 changes: 16 additions & 0 deletions src/parser/Keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,19 @@ const KEYBOARD_DOWN = 40;
const KEYBOARD_PAGE_UP = 33;
const KEYBOARD_PAGE_DOWN = 34;
const KEYBOARD_HOME = 36;
const KEYBOARD_ENTER = 13;
const KEYBOARD_BACKSPACE=8;
const KEYBOARD_TAB=9;
const KEYBOARD_ESC=27;
const KEYBOARD_F1 = 112;
const KEYBOARD_F2 = 113;
const KEYBOARD_F3 = 114;
const KEYBOARD_F4 = 115;
const KEYBOARD_F5 = 116;
const KEYBOARD_F6 = 117;
const KEYBOARD_F7 = 118;
const KEYBOARD_F8 = 119;
const KEYBOARD_F9 = 120;
const KEYBOARD_F10 = 121;
const KEYBOARD_F11 = 122;
const KEYBOARD_F12 = 123;
Loading