Skip to content

Commit 6d58346

Browse files
committed
add --char-width and --char-height CSS variables
1 parent 473e835 commit 6d58346

8 files changed

+45
-11
lines changed

css/jquery.terminal-src.css

+7-1
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,8 @@ terminal .terminal-output > div {
845845
height: calc((var(--terminal-line) * var(--rows)) + (var(--padding, 10) * 2px));
846846
/*
847847
* there is a bug in Chromium https://issues.chromium.org/issues/379430924
848-
* it give wrong number of characters per line (off by one), it works fine in Firefox and Epiphany
848+
* it give wrong number of characters per line (off by one),
849+
* it works fine in Firefox and Epiphany
849850
*/
850851
width: calc((var(--cols) * 1ch) + (var(--padding, 10) * 2px) + (var(--terminal-scrollbar, 10) * 1px));
851852
}
@@ -989,6 +990,11 @@ terminal .terminal-output > div {
989990
inherits: true;
990991
initial-value: auto;
991992
}
993+
@property --cols {
994+
syntax: '<number> | auto';
995+
inherits: true;
996+
initial-value: auto;
997+
}
992998
@supports (-ms-ime-align:auto) {
993999
.terminal h1::selection,
9941000
.terminal h2::selection,

css/jquery.terminal.css

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Copyright (c) 2011-2024 Jakub T. Jankiewicz <https://jcubic.pl/me>
1313
* Released under the MIT license
1414
*
15-
* Date: Sun, 17 Nov 2024 13:13:41 +0000
15+
* Date: Mon, 18 Nov 2024 23:03:38 +0000
1616
*/
1717
.terminal .terminal-output .format, .cmd .format,
1818
.cmd-prompt, .cmd-prompt div {
@@ -845,7 +845,8 @@ terminal .terminal-output > div {
845845
height: calc((var(--terminal-line) * var(--rows)) + (var(--padding, 10) * 2px));
846846
/*
847847
* there is a bug in Chromium https://issues.chromium.org/issues/379430924
848-
* it give wrong number of characters per line (off by one), it works fine in Firefox and Epiphany
848+
* it give wrong number of characters per line (off by one),
849+
* it works fine in Firefox and Epiphany
849850
*/
850851
width: calc((var(--cols) * 1ch) + (var(--padding, 10) * 2px) + (var(--terminal-scrollbar, 10) * 1px));
851852
}
@@ -989,6 +990,11 @@ terminal .terminal-output > div {
989990
inherits: true;
990991
initial-value: auto;
991992
}
993+
@property --cols {
994+
syntax: '<number> | auto';
995+
inherits: true;
996+
initial-value: auto;
997+
}
992998
@supports (-ms-ime-align:auto) {
993999
.terminal h1::selection,
9941000
.terminal h2::selection,

css/jquery.terminal.min.css

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/jquery.terminal.min.css.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/jquery.terminal-src.js

+11
Original file line numberDiff line numberDiff line change
@@ -12057,6 +12057,8 @@
1205712057
var pixel_density = get_pixel_size();
1205812058
var char_size = get_char_size(self);
1205912059
css(self[0], {
12060+
'--char-width': char_size.width,
12061+
'--char-height': char_size.height,
1206012062
'--terminal-scrollbar': get_scrollbar_width()
1206112063
});
1206212064
// this is needed when terminal have selector with --size that is not
@@ -12580,9 +12582,18 @@
1258012582
});
1258112583
function calculate_char_size() {
1258212584
var width = char_size.width;
12585+
var height = char_size.height;
1258312586
char_size = get_char_size(self);
12587+
var css_vars = {};
1258412588
if (width !== char_size.width) {
1258512589
command_line.option('charWidth', char_size.width).refresh();
12590+
css_vars['--char-width'] = char_size.width;
12591+
}
12592+
if (height !== char_size.height) {
12593+
css_vars['--char-height'] = char_size.height;
12594+
}
12595+
if (Object.keys(css_vars).length) {
12596+
css(self[0], css_vars);
1258612597
}
1258712598
}
1258812599
resize();

js/jquery.terminal.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
*
4242
* broken image by Sophia Bai from the Noun Project (CC-BY)
4343
*
44-
* Date: Sun, 17 Nov 2024 13:32:31 +0000
44+
* Date: Mon, 18 Nov 2024 23:03:37 +0000
4545
*/
4646
/* global define, Map, BigInt */
4747
/* eslint-disable */
@@ -5345,7 +5345,7 @@
53455345
// -------------------------------------------------------------------------
53465346
$.terminal = {
53475347
version: 'DEV',
5348-
date: 'Sun, 17 Nov 2024 13:32:31 +0000',
5348+
date: 'Mon, 18 Nov 2024 23:03:37 +0000',
53495349
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
53505350
color_names: [
53515351
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
@@ -12057,6 +12057,8 @@
1205712057
var pixel_density = get_pixel_size();
1205812058
var char_size = get_char_size(self);
1205912059
css(self[0], {
12060+
'--char-width': char_size.width,
12061+
'--char-height': char_size.height,
1206012062
'--terminal-scrollbar': get_scrollbar_width()
1206112063
});
1206212064
// this is needed when terminal have selector with --size that is not
@@ -12580,9 +12582,18 @@
1258012582
});
1258112583
function calculate_char_size() {
1258212584
var width = char_size.width;
12585+
var height = char_size.height;
1258312586
char_size = get_char_size(self);
12587+
var css_vars = {};
1258412588
if (width !== char_size.width) {
1258512589
command_line.option('charWidth', char_size.width).refresh();
12590+
css_vars['--char-width'] = char_size.width;
12591+
}
12592+
if (height !== char_size.height) {
12593+
css_vars['--char-height'] = char_size.height;
12594+
}
12595+
if (Object.keys(css_vars).length) {
12596+
css(self[0], css_vars);
1258612597
}
1258712598
}
1258812599
resize();

js/jquery.terminal.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/jquery.terminal.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)