| 1 | String.prototype.startsWith = function(list) |
| 2 | { |
| 3 | for (var i = 0; i < list.length; i++) { |
| 4 | var item = list[i]; |
| 5 | if (this.substr(0,item.length) == item) |
| 6 | return true; |
| 7 | } |
| 8 | return false; |
| 9 | } |
| 10 | |
| 11 | String.prototype.contains = function(str) { |
| 12 | return(this.indexOf(str) != -1); |
| 13 | } |
| 14 | |
| 15 | String.prototype.trim = function() { |
| 16 | return this.replace(/^\s+|\s+$/g,""); |
| 17 | } |
| 18 | |
| 19 | String.prototype.ltrim = function() { |
| 20 | return this.replace(/^\s+/,""); |
| 21 | } |
| 22 | |
| 23 | String.prototype.rtrim = function() { |
| 24 | return this.replace(/\s+$/,""); |
| 25 | } |
| 26 | |
| 27 | QTerm.Attr = { |
| 28 | Bold : 0x01, |
| 29 | Dimm : 0x02, |
| 30 | Default : 0x04, |
| 31 | Underline: 0x08, |
| 32 | Blink : 0x10, |
| 33 | Reverse : 0x40, |
| 34 | Invisible : 0x80 |
| 35 | } |
| 36 | |
| 37 | QTerm.Color = { |
| 38 | Black : 0, |
| 39 | Red : 1, |
| 40 | Green : 2, |
| 41 | Yellow : 3, |
| 42 | Blue : 4, |
| 43 | Magenta : 5, |
| 44 | Cyan : 6, |
| 45 | White : 7, |
| 46 | Highlight : 8 |
| 47 | } |
| 48 | |
| 49 | QTerm.setFG = function(color) |
| 50 | { |
| 51 | return color & 0x0f; |
| 52 | } |
| 53 | |
| 54 | QTerm.getFG = function(color) |
| 55 | { |
| 56 | return color & 0x0f; |
| 57 | } |
| 58 | |
| 59 | QTerm.setBG = function(color) |
| 60 | { |
| 61 | return (color << 4) & 0x0f; |
| 62 | } |
| 63 | |
| 64 | QTerm.getBG = function(color) |
| 65 | { |
| 66 | return (color & 0xf0) >> 4; |
| 67 | } |
| 68 | |
| 69 | QTerm.setColor = function(color) |
| 70 | { |
| 71 | return color & 0x00ff; |
| 72 | } |
| 73 | |
| 74 | QTerm.getColor = function(color) |
| 75 | { |
| 76 | return color & 0x00ff; |
| 77 | } |
| 78 | |
| 79 | QTerm.setAttr = function(attr) |
| 80 | { |
| 81 | return (attr << 8) & 0xff00; |
| 82 | } |
| 83 | |
| 84 | QTerm.getAttr = function(attr) |
| 85 | { |
| 86 | return (attr & 0xff00) >> 8; |
| 87 | } |
| 88 | |
| 89 | QTerm.defaultColor = function() |
| 90 | { |
| 91 | return setFG(QTerm.Color.White)|setBG(QTerm.Color.Black); |
| 92 | } |
| 93 | |
| 94 | QTerm.OSDType = { |
| 95 | None : 0, |
| 96 | Info : 1, |
| 97 | Warning : 2, |
| 98 | Error : 3 |
| 99 | } |
| 100 | |
| 101 | QTerm.getText = function(line) { |
| 102 | return QTerm.getLine(line).getText(); |
| 103 | } |