Measure terminal from fullscreen container

This commit is contained in:
jocayn
2026-06-13 12:50:39 +08:00
parent b5307baca5
commit 51b6f9ecfd
2 changed files with 25 additions and 8 deletions
+10 -4
View File
@@ -282,13 +282,19 @@ input[type="file"].form-control {
min-height: 0; min-height: 0;
} }
#terminal .xterm.fullscreen { #terminal.terminal-fullscreen {
bottom: var(--terminal-safe-bottom); position: fixed;
height: auto; inset: 0 0 var(--terminal-safe-bottom) 0;
padding-bottom: 0; z-index: 255;
overflow: hidden;
background: #0f1720; background: #0f1720;
} }
#terminal.terminal-fullscreen .xterm {
width: 100%;
height: 100%;
}
#waiter { #waiter {
position: fixed; position: fixed;
inset: 0; inset: 0;
+15 -4
View File
@@ -296,8 +296,9 @@ jQuery(function($){
function toggle_fullscreen(term) { function toggle_fullscreen(term) {
$('#terminal .terminal').toggleClass('fullscreen'); $('#terminal').toggleClass('terminal-fullscreen');
term.fitAddon.fit(); term.fitAddon.fit();
resize_terminal(term);
} }
function terminal_safe_bottom() { function terminal_safe_bottom() {
@@ -309,6 +310,16 @@ jQuery(function($){
} }
function terminal_size() {
var terminal = document.getElementById('terminal'),
rect = terminal.getBoundingClientRect(),
width = rect.width || window.innerWidth,
height = rect.height || (window.innerHeight - terminal_safe_bottom());
return {'width': width, 'height': height};
}
function current_geometry(term) { function current_geometry(term) {
if (!style.width || !style.height) { if (!style.width || !style.height) {
try { try {
@@ -318,9 +329,9 @@ jQuery(function($){
} }
} }
var height = window.innerHeight - terminal_safe_bottom(), var size = terminal_size(),
cols = Math.max(2, parseInt(window.innerWidth / style.width, 10) - 1), cols = Math.max(2, parseInt(size.width / style.width, 10) - 1),
rows = Math.max(1, parseInt(height / style.height, 10)); rows = Math.max(1, parseInt(size.height / style.height, 10) - 1);
return {'cols': cols, 'rows': rows}; return {'cols': cols, 'rows': rows};
} }