Commit 6519a94
committed
fix(demo): improve terminal resizing to fit container
- Add overflow: hidden and position: relative to #terminal container
so the container constrains the canvas size rather than expanding
to fit it
- Call fitAddon.observeResize() for automatic resize on container changes
- Use term.onResize event to notify PTY of dimension changes
(works with both observeResize and manual fit calls)
- Keep window resize handler for browsers that don't trigger
ResizeObserver on window resize
This ensures the terminal properly sizes itself to fill the container
on initial load and responds to container/window size changes.
fix: expose renderer publicly for FitAddon to access
FitAddon.proposeDimensions() was returning undefined because it couldn't
access the terminal's renderer to get font metrics. The renderer was
private, so FitAddon couldn't calculate the correct terminal dimensions.
Changes:
- Make Terminal.renderer public so FitAddon can access getMetrics()
- Add observeResize() call to demo/index.html
- Make initTerminal async and await term.open() in demo/index.html
- Update demo/bin/demo.js CSS to use absolute positioning for #terminal
The root cause was that FitAddon needs renderer.getMetrics() to calculate
how many cols/rows fit in the container, but the renderer field was private.1 parent d3c37df commit 6519a94
4 files changed
Lines changed: 22 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| 163 | + | |
163 | 164 | | |
164 | 165 | | |
165 | 166 | | |
166 | | - | |
167 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
168 | 173 | | |
169 | 174 | | |
170 | 175 | | |
| |||
203 | 208 | | |
204 | 209 | | |
205 | 210 | | |
| 211 | + | |
206 | 212 | | |
207 | 213 | | |
208 | 214 | | |
| |||
249 | 255 | | |
250 | 256 | | |
251 | 257 | | |
252 | | - | |
253 | | - | |
254 | | - | |
| 258 | + | |
| 259 | + | |
255 | 260 | | |
256 | | - | |
| 261 | + | |
257 | 262 | | |
258 | 263 | | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
259 | 269 | | |
260 | 270 | | |
261 | 271 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
| 141 | + | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
| 156 | + | |
157 | 157 | | |
| 158 | + | |
158 | 159 | | |
159 | | - | |
| 160 | + | |
160 | 161 | | |
161 | 162 | | |
162 | 163 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| |||
0 commit comments