chore: fix chrome
This commit is contained in:
@@ -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`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user