minitel-standalone
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -24,3 +24,3 @@ import { Focusable, FocusableAttributes } from '../abstract/focusable.js'; | ||
multiline: boolean; | ||
onChange: (value: string) => void; | ||
onChange: (value: Input) => void; | ||
} |
@@ -66,3 +66,3 @@ "use strict"; | ||
if (this.attributes.onChange) | ||
this.attributes.onChange(this.value); | ||
this.attributes.onChange(this); | ||
} | ||
@@ -72,3 +72,3 @@ else if (key === '\x13\x47') { | ||
if (this.attributes.onChange) | ||
this.attributes.onChange(this.value); | ||
this.attributes.onChange(this); | ||
} | ||
@@ -75,0 +75,0 @@ this.minitel.queueImmediateRenderToStream(); |
{ | ||
"name": "minitel-standalone", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "A standalone package for minitel components", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -41,70 +41,70 @@ import { Focusable, FocusableAttributes } from '../abstract/focusable.js'; | ||
case '\x1b\x5b\x41': // up | ||
if (this.attributes.multiline) { | ||
this.focusCursorAt[0] -= 1; | ||
this.focusCursorAt[0] = Math.max(this.focusCursorAt[0], 0); | ||
if (this.attributes.multiline) { | ||
this.focusCursorAt[0] -= 1; | ||
this.focusCursorAt[0] = Math.max(this.focusCursorAt[0], 0); | ||
currentLine = this.value.split('\n')[this.focusCursorAt[0]]; | ||
this.focusCursorAt[1] = Math.min( | ||
this.lastFocusCursorX, | ||
currentLine.length, | ||
); | ||
this.minitel.queueImmediateRenderToStream(); | ||
} | ||
break; | ||
case '\x1b\x5b\x42': // down | ||
if (this.attributes.multiline) { | ||
this.focusCursorAt[0] += 1; | ||
this.focusCursorAt[0] = Math.min( | ||
this.focusCursorAt[1], | ||
this.value.split('\n').length, | ||
); | ||
currentLine = this.value.split('\n')[this.focusCursorAt[0]]; | ||
this.focusCursorAt[1] = Math.min( | ||
this.lastFocusCursorX, | ||
currentLine.length, | ||
); | ||
this.minitel.queueImmediateRenderToStream(); | ||
} | ||
break; | ||
case '\x1b\x5b\x43': // right | ||
this.focusCursorAt[1] += 1; | ||
currentLine = this.value.split('\n')[this.focusCursorAt[0]]; | ||
this.focusCursorAt[1] = Math.min( | ||
this.lastFocusCursorX, | ||
currentLine.length, | ||
); | ||
if (this.focusCursorAt[1] > currentLine.length) { | ||
this.focusCursorAt[0] += 1; | ||
this.focusCursorAt[0] = Math.min( | ||
this.focusCursorAt[0], | ||
this.value.split('\n').length, | ||
); | ||
this.focusCursorAt[1] = 0; | ||
} | ||
this.lastFocusCursorX = this.focusCursorAt[1]; | ||
this.minitel.queueImmediateRenderToStream(); | ||
} | ||
break; | ||
case '\x1b\x5b\x42': // down | ||
if (this.attributes.multiline) { | ||
this.focusCursorAt[0] += 1; | ||
this.focusCursorAt[0] = Math.min( | ||
this.focusCursorAt[1], | ||
this.value.split('\n').length, | ||
); | ||
break; | ||
case '\x1b\x5b\x44': // left | ||
this.focusCursorAt[1] -= 1; | ||
currentLine = this.value.split('\n')[this.focusCursorAt[0]]; | ||
this.focusCursorAt[1] = Math.min( | ||
this.lastFocusCursorX, | ||
currentLine.length, | ||
); | ||
if (this.focusCursorAt[1] < 0) { | ||
this.focusCursorAt[0] -= 1; | ||
this.focusCursorAt[0] = Math.max(this.focusCursorAt[0], 0); | ||
currentLine = this.value.split('\n')[this.focusCursorAt[0]]; | ||
this.focusCursorAt[1] = currentLine.length; | ||
} | ||
this.lastFocusCursorX = this.focusCursorAt[1]; | ||
this.minitel.queueImmediateRenderToStream(); | ||
} | ||
break; | ||
case '\x1b\x5b\x43': // right | ||
this.focusCursorAt[1] += 1; | ||
currentLine = this.value.split('\n')[this.focusCursorAt[0]]; | ||
if (this.focusCursorAt[1] > currentLine.length) { | ||
this.focusCursorAt[0] += 1; | ||
this.focusCursorAt[0] = Math.min( | ||
this.focusCursorAt[0], | ||
this.value.split('\n').length, | ||
); | ||
this.focusCursorAt[1] = 0; | ||
} | ||
this.lastFocusCursorX = this.focusCursorAt[1]; | ||
this.minitel.queueImmediateRenderToStream(); | ||
break; | ||
case '\x1b\x5b\x44': // left | ||
this.focusCursorAt[1] -= 1; | ||
if (this.focusCursorAt[1] < 0) { | ||
this.focusCursorAt[0] -= 1; | ||
this.focusCursorAt[0] = Math.max(this.focusCursorAt[0], 0); | ||
currentLine = this.value.split('\n')[this.focusCursorAt[0]]; | ||
this.focusCursorAt[1] = currentLine.length; | ||
} | ||
this.lastFocusCursorX = this.focusCursorAt[1]; | ||
this.minitel.queueImmediateRenderToStream(); | ||
break; | ||
break; | ||
default: | ||
if (/^[a-zA-Z0-9,\.';\-\:?!"#$%&\(\)\[\]<>@+=*/ ]$/g.test(key)) { | ||
this.value += key; | ||
if (this.attributes.onChange) this.attributes.onChange(this.value); | ||
} else if (key === '\x13\x47') { | ||
this.value = this.value.slice(0, -1); | ||
if (this.attributes.onChange) this.attributes.onChange(this.value); | ||
} | ||
this.minitel.queueImmediateRenderToStream(); | ||
if (/^[a-zA-Z0-9,\.';\-\:?!"#$%&\(\)\[\]<>@+=*/ ]$/g.test(key)) { | ||
this.value += key; | ||
if (this.attributes.onChange) this.attributes.onChange(this); | ||
} else if (key === '\x13\x47') { | ||
this.value = this.value.slice(0, -1); | ||
if (this.attributes.onChange) this.attributes.onChange(this); | ||
} | ||
this.minitel.queueImmediateRenderToStream(); | ||
} | ||
@@ -132,3 +132,3 @@ } | ||
multiline: boolean; | ||
onChange: (value: string) => void; | ||
onChange: (value: Input) => void; | ||
} |
@@ -5,3 +5,3 @@ import { MinitelObject } from '../abstract/minitelobject.js'; | ||
import { MinitelObjectAttributes } from '../types.js'; | ||
import { alignInvrt, inheritedProps } from '../utils.js'; | ||
import { alignInvrt } from '../utils.js'; | ||
import { TextNode } from '../abstract/textnode.js'; | ||
@@ -8,0 +8,0 @@ import type { Minitel } from './minitel.js'; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
172029