import React, { CSSProperties } from 'react';
import ReactDOM from 'react-dom/client';
import { text } from 'stream/consumers';
import './[Link]';
class Caret {
protected INTERVAL_TIME_MS: number = 500;
protected rowIndex: number;
protected columnIndex: number;
protected x: number;
protected y: number;
protected isVisible: boolean;
protected timer: [Link] | null;
constructor() {
[Link] = -1;
[Link] = -1;
this.x = -1;
this.y = -1;
[Link] = false;
[Link] = null;
}
public setRowIndex(rowIndex: number): boolean {
let doUpdate: boolean = false;
const textDimensions = getTextDimensions("a", getCanvasFont());
if (([Link] != rowIndex) && (rowIndex >= 0)) {
[Link] = rowIndex;
this.y = [Link](rowIndex * ([Link] +
Number(getComputedStyle([Link]).getPropertyValue('--text-border-
size'))));
[Link]('--caret-y',
[Link]());
doUpdate = true;
}
return doUpdate;
}
public setColumnIndex(columnIndex: number): boolean {
let doUpdate: boolean = false;
const indexWidth: number =
Number(getComputedStyle([Link]).getPropertyValue('--text-index-
width'));
const textDimensions = getTextDimensions("a", getCanvasFont());
if (([Link] != columnIndex) && (columnIndex >= 0)) {
[Link] = columnIndex;
this.x = indexWidth + [Link](columnIndex * [Link]);
[Link]('--caret-x',
[Link]());
doUpdate = true;
}
return doUpdate;
}
public setIndexes(rowIndex: number, columnIndex: number): boolean {
let doUpdate: boolean = false;
const indexWidth: number =
Number(getComputedStyle([Link]).getPropertyValue('--text-index-
width'));
const textDimensions = getTextDimensions("a", getCanvasFont());
if (([Link] != rowIndex) && (rowIndex >= 0)) {
[Link] = rowIndex;
this.y = [Link](rowIndex * ([Link] +
Number(getComputedStyle([Link]).getPropertyValue('--text-border-
size'))));
[Link]('--caret-y',
[Link]());
doUpdate = true;
}
if (([Link] != columnIndex) && (columnIndex >= 0)) {
[Link] = columnIndex;
this.x = indexWidth + [Link](columnIndex * [Link]);
[Link]('--caret-x',
[Link]());
doUpdate = true;
}
// [Link]("i, j = (", [Link], ", ", [Link], ")");
// [Link]("x, y = (", this.x, ", ", this.y, ")");
return doUpdate;
}
public getRowIndex(): number {
return [Link];
}
public getColumnIndex(): number {
return [Link];
}
public getCoordinateX(): number {
return this.x;
}
public getCoordinateY(): number {
return this.y;
}
// TODO: Rework all of this to avoid using global CSS properties
public startBlinking() {
[Link] = true;
[Link]('--caret-display',
[Link] ? 'auto' : 'none');
if ([Link] !== null) {
clearInterval([Link]);
[Link] = null;
}
[Link] = setInterval(() => {
[Link] = ![Link];
[Link]('--caret-display',
[Link] ? 'auto' : 'none');
},
this.INTERVAL_TIME_MS);
}
public stopBlinking() {
if ([Link] !== null) {
clearInterval([Link]);
[Link] = null;
[Link] = false;
[Link]('--caret-display',
[Link] ? 'auto' : 'none');
}
}
}