Skip to content

Commit

Permalink
fix split layout
Browse files Browse the repository at this point in the history
  • Loading branch information
goldbuick committed Dec 24, 2024
1 parent 23bdc89 commit cfed1d9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
4 changes: 2 additions & 2 deletions zss/device/tape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ createdevice('tape', [], (message) => {
}
if (!editor.open) {
switch (nextlayout as TAPE_DISPLAY) {
case TAPE_DISPLAY.SPLIT_X:
case TAPE_DISPLAY.SPLIT_X_ALT:
case TAPE_DISPLAY.SPLIT_Y:
case TAPE_DISPLAY.SPLIT_Y_ALT:
// skip over these to right
nextlayout = TAPE_DISPLAY.TOP
break
Expand Down
4 changes: 2 additions & 2 deletions zss/gadget/data/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export enum TAPE_DISPLAY {
TOP,
BOTTOM,
FULL,
SPLIT_X,
SPLIT_X_ALT,
SPLIT_Y,
SPLIT_Y_ALT,
MAX,
}

Expand Down
9 changes: 8 additions & 1 deletion zss/gadget/editor/editorinput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import {
tape_editor_close,
tape_terminal_close,
tape_terminal_inclayout,
vm_cli,
} from 'zss/device/api'
import { MODEM_SHARED_STRING } from 'zss/device/modem'
import { useTapeEditor } from 'zss/gadget/data/state'
import { useTape, useTapeEditor } from 'zss/gadget/data/state'
import { clamp } from 'zss/mapping/number'
import { MAYBE, ispresent } from 'zss/mapping/types'
import { applystrtoindex, textformatreadedges } from 'zss/words/textformat'
import { NAME, PT } from 'zss/words/types'
import { writetext } from 'zss/words/writeui'

import { useBlink, useWriteText } from '../hooks'
import { Scrollable } from '../scrollable'
Expand Down Expand Up @@ -39,6 +41,7 @@ export function EditorInput({
const blinkdelta = useRef<PT>()
const tapeeditor = useTapeEditor()
const edge = textformatreadedges(context)
const player = useTape((state) => state.editor.player)

// split by line
const value = sharedtosynced(codepage)
Expand Down Expand Up @@ -277,6 +280,10 @@ export function EditorInput({
resettoend()
}
break
case 'p':
vm_cli('editor', strvalueselected, player)
writetext('editor', `running: ${strvalueselected}`)
break
}
} else if (mods.alt) {
// no-op ?? - could this shove text around when you have selection ??
Expand Down
26 changes: 13 additions & 13 deletions zss/gadget/tape/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,31 @@ export function TapeLayout({ context }: TapeLayoutProps) {
const right = context.width - 1
const bottom = context.height - 1
const edge = textformatreadedges(context)
const xstep = Math.floor(edge.width * 0.5)
const ystep = Math.floor(edge.height * 0.5)

const xleft = useMemo(
() => forkonedge(0, 0, xstep - 1, bottom, context),
[xstep, bottom, context],
const ytop = useMemo(
() => forkonedge(0, 0, right, ystep - 1, context),
[ystep, right, context],
)
const xright = useMemo(
() => forkonedge(xstep, 0, right, bottom, context),
[xstep, right, bottom, context],
const ybottom = useMemo(
() => forkonedge(0, ystep, right, bottom, context),
[ystep, right, bottom, context],
)

if (editoropen) {
let first: MAYBE<WRITE_TEXT_CONTEXT>
let second: MAYBE<WRITE_TEXT_CONTEXT>
switch (layout) {
case TAPE_DISPLAY.SPLIT_X:
case TAPE_DISPLAY.SPLIT_X_ALT:
first = xleft
second = xright
case TAPE_DISPLAY.SPLIT_Y:
case TAPE_DISPLAY.SPLIT_Y_ALT:
first = ytop
second = ybottom
break
}

if (ispresent(first) && ispresent(second)) {
switch (layout) {
case TAPE_DISPLAY.SPLIT_X:
case TAPE_DISPLAY.SPLIT_Y:
return (
<>
<WriteTextContext.Provider value={first}>
Expand All @@ -83,7 +83,7 @@ export function TapeLayout({ context }: TapeLayoutProps) {
</WriteTextContext.Provider>
</>
)
case TAPE_DISPLAY.SPLIT_X_ALT:
case TAPE_DISPLAY.SPLIT_Y_ALT:
return (
<>
<WriteTextContext.Provider value={first}>
Expand Down

0 comments on commit cfed1d9

Please sign in to comment.