Comparing version 2.2.0 to 2.3.0
@@ -45,2 +45,3 @@ /// <reference types="node" /> | ||
clear(): this; | ||
clearSoft(): this; | ||
write(s: string): this; | ||
@@ -47,0 +48,0 @@ draw(other: Region): this; |
@@ -124,7 +124,3 @@ "use strict"; | ||
all() { | ||
const r = new Region(this.canvas, 0, 0, this.canvas.cols, this.canvas.rows); | ||
r.cursorX = this.cursorX + this.x1; | ||
r.cursorY = this.cursorY + this.y1; | ||
r.attr = this.attr; | ||
return r; | ||
return this; | ||
} | ||
@@ -137,6 +133,4 @@ clip(x1, y1, x2, y2) { | ||
const r = new Region(this.canvas, x1, y1, x2, y2); | ||
r.cursorX = this.cursorX; | ||
r.cursorY = this.cursorY; | ||
r.attr = this.attr; | ||
return r; | ||
return r.at(this.cursorX - x1, this.cursorY - y1); | ||
} | ||
@@ -169,4 +163,4 @@ // usually called by a layout engine | ||
at(x, y) { | ||
this.cursorX = Math.max(Math.min(x, this.cols), 0); | ||
this.cursorY = Math.max(Math.min(y, this.rows), 0); | ||
this.cursorX = Math.max(Math.min(x, this.cols - 1), 0); | ||
this.cursorY = Math.max(Math.min(y, this.rows - 1), 0); | ||
return this; | ||
@@ -179,2 +173,9 @@ } | ||
} | ||
// clear region without memoizing the "clear screen" (mostly for testing) | ||
clearSoft() { | ||
for (let y = this.y1; y < this.y2; y++) | ||
this.canvas.nextBuffer.clearBox(this.x1, y, this.x2, y + 1, this.attr); | ||
this.canvas.setDirty(); | ||
return this; | ||
} | ||
write(s) { | ||
@@ -204,3 +205,5 @@ let chars = [...s]; | ||
other = other.clip(0, 0, maxx, maxy); | ||
this.canvas.nextBuffer.putBox(this.x1, this.y1, other.canvas.nextBuffer, other.x1, other.y1, other.x2, other.y2); | ||
const x = this.x1 + this.cursorX; | ||
const y = this.y1 + this.cursorY; | ||
this.canvas.nextBuffer.putBox(x, y, other.canvas.nextBuffer, other.x1, other.y1, other.x2, other.y2); | ||
this.canvas.setDirty(); | ||
@@ -207,0 +210,0 @@ return this; |
@@ -32,2 +32,4 @@ export declare enum Modifier { | ||
constructor(modifiers: Modifier, type: KeyType, key?: string); | ||
static normal(modifiers: Modifier, key: string): Key; | ||
equals(other: Key): boolean; | ||
toString(): string; | ||
@@ -34,0 +36,0 @@ } |
@@ -52,2 +52,8 @@ "use strict"; | ||
} | ||
static normal(modifiers, key) { | ||
return new Key(modifiers, KeyType.Normal, key); | ||
} | ||
equals(other) { | ||
return this.modifiers == other.modifiers && this.type == other.type && this.key == other.key; | ||
} | ||
toString() { | ||
@@ -54,0 +60,0 @@ const segments = []; |
@@ -120,2 +120,10 @@ "use strict"; | ||
`[[8;5H+--+[[H`); | ||
// move the box one place back, using the cursor instead of the clip region | ||
c.all().draw(bg.all()); | ||
c.all().at(3, 3).draw(box.all()); | ||
escpaint(c).should.eql(`[[4;4H+--+` + | ||
`[[5;4H| |[[37m[[44m ` + | ||
`[[6;4H[[38;5;15m[[41m| |[[37m[[44m ` + | ||
`[[7;4H[[38;5;15m[[41m+--+[[37m[[44m ` + | ||
`[[8H[[K[[7A`); | ||
}); | ||
@@ -122,0 +130,0 @@ it("places the cursor", () => { |
{ | ||
"name": "antsy", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "draw full-color (xterm-256) ansi graphics into a buffer", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
174134
2051