comparison termemu.js @ 150:1d3cfe10974a

termemu.js: implement cursor hiding.
author John "Elwin" Edwards
date Sun, 26 Jan 2014 19:56:02 -0800
parents 6758d832c10c
children d60063a674e1
comparison
equal deleted inserted replaced
149:6758d832c10c 150:1d3cfe10974a
35 this.inverse = src.inverse; 35 this.inverse = src.inverse;
36 this.uline = src.uline; 36 this.uline = src.uline;
37 this.fg = src.fg; 37 this.fg = src.fg;
38 this.bg = src.bg; 38 this.bg = src.bg;
39 this.cset = src.cset; 39 this.cset = src.cset;
40 this.visible = src.visible;
40 } 41 }
41 else { 42 else {
42 this.x = 0; 43 this.x = 0;
43 this.y = 0; 44 this.y = 0;
44 this.bold = false; 45 this.bold = false;
45 this.inverse = false; 46 this.inverse = false;
46 this.uline = false; 47 this.uline = false;
47 this.fg = null; 48 this.fg = null;
48 this.bg = null; 49 this.bg = null;
49 this.cset = "B"; 50 this.cset = "B";
51 this.visible = true;
50 } 52 }
51 return; 53 return;
52 } 54 }
53 55
54 // An object representing the terminal emulator. 56 // An object representing the terminal emulator.
266 comseq: [], // Part of an impending control sequence 268 comseq: [], // Part of an impending control sequence
267 flipCursor: function () { 269 flipCursor: function () {
268 /* Swaps the text and background colors of the active location. */ 270 /* Swaps the text and background colors of the active location. */
269 /* This will change when other cursor styles are supported. */ 271 /* This will change when other cursor styles are supported. */
270 /* Check: the cursor might be offscreen if it was resized. */ 272 /* Check: the cursor might be offscreen if it was resized. */
273 if (!this.c.visible)
274 return;
271 if (this.c.x != null && this.c.y != null && this.c.x >= 0 && 275 if (this.c.x != null && this.c.y != null && this.c.x >= 0 &&
272 this.c.x < this.w && this.c.y >= 0 && this.c.y < this.h) { 276 this.c.x < this.w && this.c.y >= 0 && this.c.y < this.h) {
273 var oldcell = this.screen.childNodes[this.c.y].childNodes[this.c.x]; 277 var oldcell = this.screen.childNodes[this.c.y].childNodes[this.c.x];
274 var tempswap = oldcell.style.color; 278 var tempswap = oldcell.style.color;
275 oldcell.style.color = oldcell.style.backgroundColor; 279 oldcell.style.color = oldcell.style.backgroundColor;
1013 } 1017 }
1014 else if (params[i] == 7) { 1018 else if (params[i] == 7) {
1015 /* Wraparound ON is the only mode implemented. */ 1019 /* Wraparound ON is the only mode implemented. */
1016 debug(0, "Wraparound mode"); 1020 debug(0, "Wraparound mode");
1017 } 1021 }
1022 else if (params[i] == 25) {
1023 /* Show the cursor. */
1024 if (!this.c.visible) {
1025 this.c.visible = true;
1026 this.flipCursor();
1027 }
1028 debug(0, "Showing cursor");
1029 }
1018 else if (params[i] == 1048) { 1030 else if (params[i] == 1048) {
1019 this.saveCursor(); 1031 this.saveCursor();
1020 } 1032 }
1021 else if (params[i] == 1049) { 1033 else if (params[i] == 1049) {
1022 this.toAltBuf(); 1034 this.toAltBuf();
1039 } 1051 }
1040 } 1052 }
1041 for (var i = 0; i < params.length; i++) { 1053 for (var i = 0; i < params.length; i++) {
1042 if (params[i] == 1) { 1054 if (params[i] == 1) {
1043 keyHexCodes.appCursor(false); 1055 keyHexCodes.appCursor(false);
1056 }
1057 else if (params[i] == 12) {
1058 debug(0, "Stopping blinking cursor");
1059 }
1060 else if (params[i] == 25) {
1061 /* Hide the cursor. */
1062 if (this.c.visible) {
1063 this.flipCursor();
1064 this.c.visible = false;
1065 }
1066 debug(0, "Hiding cursor");
1044 } 1067 }
1045 else if (params[i] == 1048) { 1068 else if (params[i] == 1048) {
1046 this.restoreCursor(); 1069 this.restoreCursor();
1047 } 1070 }
1048 else if (params[i] == 1049) { 1071 else if (params[i] == 1049) {