diff --git a/frontend/src/lib/components/grid/grid.svelte b/frontend/src/lib/components/grid/grid.svelte index 98b27df..463746f 100644 --- a/frontend/src/lib/components/grid/grid.svelte +++ b/frontend/src/lib/components/grid/grid.svelte @@ -3,7 +3,14 @@ import Cell from '$lib/components/grid/cell.svelte'; import { onDestroy, onMount } from 'svelte'; import CellHeader from './cell-header.svelte'; - import { fromGridRef, toColLetter, toGridRef, type CellData, type CellValue } from './utils'; + import { + fromGridRef, + splitErrorString, + toColLetter, + toGridRef, + type CellData, + type CellValue + } from './utils'; let { socket @@ -11,27 +18,6 @@ socket: WebSocket; } = $props(); - function splitErrorString(errorString: string) { - // Remove the "ERR " prefix. - const content = errorString.substring(4); - - // Find the index of the first colon. - const colonIndex = content.indexOf(':'); - - // If no colon is found, return the whole content as the first element. - if (colonIndex === -1) { - return [content.trim(), '']; - } - - // Extract the part before the colon (the error type). - const errorType = content.substring(0, colonIndex).trim(); - - // Extract the part after the colon (the error message). - const errorMessage = content.substring(colonIndex + 1).trim(); - - return [errorType, errorMessage]; - } - socket.onmessage = (msg: MessageEvent) => { const input = msg.data.toString().trim(); @@ -87,8 +73,8 @@ } }; - let rows = 50; - let cols = 50; + let rows = 100; + let cols = 60; let default_row_height = '30px'; let default_col_width = '60px'; diff --git a/frontend/src/lib/components/grid/utils.ts b/frontend/src/lib/components/grid/utils.ts index 143bd67..64fc8d8 100644 --- a/frontend/src/lib/components/grid/utils.ts +++ b/frontend/src/lib/components/grid/utils.ts @@ -1,3 +1,10 @@ +export type CellValue = number | string | undefined; + +export interface CellData { + raw_val: string; + val: CellValue; +} + export function fromGridRef(ref: string): [number, number] { const match = ref.match(/^([A-Z]+)([0-9]+)$/i); if (!match) throw new Error('Invalid reference'); @@ -31,9 +38,23 @@ export function toGridRef(row: number, col: number): string { return toColLetter(col) + row.toString(); } -export type CellValue = number | string | undefined; +export function splitErrorString(errorString: string) { + // Remove the "ERR " prefix. + const content = errorString.substring(4); -export interface CellData { - raw_val: string; - val: CellValue; + // Find the index of the first colon. + const colonIndex = content.indexOf(':'); + + // If no colon is found, return the whole content as the first element. + if (colonIndex === -1) { + return [content.trim(), '']; + } + + // Extract the part before the colon (the error type). + const errorType = content.substring(0, colonIndex).trim(); + + // Extract the part after the colon (the error message). + const errorMessage = content.substring(colonIndex + 1).trim(); + + return [errorType, errorMessage]; }