Skip to content

Commit

Permalink
[Protocol change] When a window has no internal size, mark it as hidd…
Browse files Browse the repository at this point in the history
…en to ensure it also has no padding
  • Loading branch information
curiousdannii committed Oct 19, 2024
1 parent 2e95273 commit c0f2a31
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/common/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The GlkOte protocol
===================
Copyright (c) 2023 Dannii Willis
Copyright (c) 2024 Dannii Willis
MIT licenced
https://github.com/curiousdannii/asyncglk
Expand Down Expand Up @@ -450,6 +450,8 @@ export interface WindowUpdate {
/** Grid width (chars) */
gridwidth?: number,
height: number,
/** Whether the window should be completely hidden, though could potentially still respond to character events */
hidden?: boolean,
/** Window ID */
id: number,
/** Left position */
Expand Down
10 changes: 5 additions & 5 deletions src/glkapi/glkapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1834,21 +1834,21 @@ export class AsyncGlk implements Interface.GlkApi {
switch (win.key!.type) {
case 'buffer':
if (win.vertical) {
split = win.size * metrics.buffercharwidth + metrics.buffermarginx
split = win.size ? (win.size * metrics.buffercharwidth + metrics.buffermarginx) : 0
}
else {
split = win.size * metrics.buffercharheight + metrics.buffermarginy
split = win.size ? (win.size * metrics.buffercharheight + metrics.buffermarginy) : 0
}
break
case 'graphics':
split = win.size + (win.vertical ? metrics.graphicsmarginx : metrics.graphicsmarginy)
split = win.size ? (win.size + (win.vertical ? metrics.graphicsmarginx : metrics.graphicsmarginy)) : 0
break
case 'grid':
if (win.vertical) {
split = win.size * metrics.gridcharwidth + metrics.gridmarginx
split = win.size ? (win.size * metrics.gridcharwidth + metrics.gridmarginx) : 0
}
else {
split = win.size * metrics.gridcharheight + metrics.gridmarginy
split = win.size ? (win.size * metrics.gridcharheight + metrics.gridmarginy) : 0
}
break
}
Expand Down
7 changes: 5 additions & 2 deletions src/glkapi/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,20 @@ abstract class WindowBase implements GlkWindow {
copy_prop(this.input, input_update, 'mouse')

const box = this.box
const height = box.bottom - box.top
const width = box.right - box.left
return {
content: null,
input: input_update,
size: {
height: box.bottom - box.top,
height,
hidden: height === 0 || width === 0,
id: this.disprock,
left: box.left,
rock: this.rock,
top: box.top,
type: this.type,
width: box.right - box.left,
width,
},
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/glkote/web/windows.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ https://github.com/curiousdannii/asyncglk
position: absolute;
}

.WindowFrame.hidden {
padding: 0;
}

.BufferWindow {
color: var(--glkote-buffer-fg);
font-family: var(--glkote-prop-family);
Expand Down
1 change: 1 addition & 0 deletions src/glkote/web/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@ export default class Windows extends Map<number, Window> {
top: update.top,
width: update.width,
})
.toggleClass('hidden', update.hidden)
if (win.type === 'buffer') {
win.scroll_to_bottom(true)
}
Expand Down

0 comments on commit c0f2a31

Please sign in to comment.