chore: fix chrome

This commit is contained in:
2026-04-15 11:40:45 +02:00
parent ea968b8492
commit dc706d6262
10 changed files with 112 additions and 32 deletions

View File

@@ -1,12 +1,17 @@
import { SetCurrentTerminal } from '../app'
import type { Shell } from '../shell/Shell'
import sqs from '../utils/sqs'
import type { CursorPosition, CursorStyle } from './CursorProperties'
export class Terminal {
public static readonly Version = "0.1.1"
private terminal: HTMLElement
private cursor: HTMLElement
private cellHeight = 16
private cellWidth = 8
private cursorStyle: CursorStyle = 'bar'
private cellHeight = 0
private cellWidth = 0
private cursorPosition: CursorPosition = {
col: 0,
@@ -16,11 +21,11 @@ export class Terminal {
private shell?: Shell
constructor() {
SetCurrentTerminal(this)
this.terminal = sqs('#terminal')
this.cursor = sqs('#cursor')
this.ResetCellSize()
this.SetCursorStyle('bar')
this.NewPage()
}
@@ -30,7 +35,13 @@ export class Terminal {
this.shell.Init()
}
GetShell(): Shell | undefined {
return this.shell
}
NewPage() {
this.ResetCellSize()
this.terminal.innerHTML = ''
this.SetCursorPosition(0, 0)
}
@@ -127,8 +138,8 @@ export class Terminal {
this.terminal.appendChild(cell)
this.cellWidth = cell.scrollWidth
this.cellHeight = cell.scrollHeight
this.cellWidth = cell.offsetWidth
this.cellHeight = cell.offsetHeight
cell.remove()
}
@@ -142,6 +153,8 @@ export class Terminal {
}
UpdateCursor() {
this.SetCursorStyle(this.cursorStyle)
this.cursor.style.left = `${this.cursorPosition.col * this.cellWidth}px`
this.cursor.style.top = `${this.cursorPosition.row * this.cellHeight}px`
}