Skip to content

Commit

Permalink
experimental --cols CSS variable
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Nov 17, 2024
1 parent d3a1160 commit d34629f
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
### Features
* add `id` option that allow to create same terminal using hot reload [#978](https://github.com/jcubic/jquery.terminal/issues/978)
* allow using Object URLs in links [#982](https://github.com/jcubic/jquery.terminal/issues/982)
* experimental `--cols` CSS variable
### Bugfix
* fix `terminal::login()` when user already authenticated [#980](https://github.com/jcubic/jquery.terminal/issues/980)
* improve mobile support
Expand Down
2 changes: 1 addition & 1 deletion css/emoji.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion css/jquery.terminal-src.css
Original file line number Diff line number Diff line change
Expand Up @@ -841,8 +841,13 @@ terminal .terminal-output > div {
--terminal-line: calc(var(--size, 1) * (16px / var(--pixel-density, 1)) + 1px / var(--pixel-density, 1));
--terminal-font-size: calc(var(--size, 1) * (12px / var(--pixel-density, 1)));
height: auto;
/* force size when user add --rows */
/* force size when user add --rows and --cols */
height: calc((var(--terminal-line) * var(--rows)) + (var(--padding, 10) * 2px));
/*
* there is a bug in Chromium https://issues.chromium.org/issues/379430924
* it give wrong number of characters per line (off by one), it works fine in Firefox and Epiphany
*/
width: calc((var(--cols) * 1ch) + (var(--padding, 10) * 2px) + (var(--terminal-scrollbar, 10) * 1px));
}
.terminal .terminal-output > :not(.raw) > div,
.cmd div,
Expand Down
9 changes: 7 additions & 2 deletions css/jquery.terminal.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Copyright (c) 2011-2024 Jakub T. Jankiewicz <https://jcubic.pl/me>
* Released under the MIT license
*
* Date: Thu, 14 Nov 2024 21:18:03 +0000
* Date: Sun, 17 Nov 2024 13:13:41 +0000
*/
.terminal .terminal-output .format, .cmd .format,
.cmd-prompt, .cmd-prompt div {
Expand Down Expand Up @@ -841,8 +841,13 @@ terminal .terminal-output > div {
--terminal-line: calc(var(--size, 1) * (16px / var(--pixel-density, 1)) + 1px / var(--pixel-density, 1));
--terminal-font-size: calc(var(--size, 1) * (12px / var(--pixel-density, 1)));
height: auto;
/* force size when user add --rows */
/* force size when user add --rows and --cols */
height: calc((var(--terminal-line) * var(--rows)) + (var(--padding, 10) * 2px));
/*
* there is a bug in Chromium https://issues.chromium.org/issues/379430924
* it give wrong number of characters per line (off by one), it works fine in Firefox and Epiphany
*/
width: calc((var(--cols) * 1ch) + (var(--padding, 10) * 2px) + (var(--terminal-scrollbar, 10) * 1px));
}
.terminal .terminal-output > :not(.raw) > div,
.cmd div,
Expand Down
4 changes: 2 additions & 2 deletions css/jquery.terminal.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/jquery.terminal.min.css.map

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions js/jquery.terminal-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -9681,6 +9681,13 @@
return parseInt(style.getPropertyValue(prop), 10) || 0;
}
// ---------------------------------------------------------------------
function get_scrollbar_width() {
var width = filler.width();
var container_width = self.width();
var padding = get_padding();
return container_width - width - (padding.left + padding.right);
}
// ---------------------------------------------------------------------
function get_padding() {
var style = window.getComputedStyle(filler[0]);
function padding(name) {
Expand Down Expand Up @@ -12050,6 +12057,9 @@
self.addClass('terminal');
var pixel_density = get_pixel_size();
var char_size = get_char_size(self);
css(self[0], {
'--terminal-scrollbar': get_scrollbar_width()
});
// this is needed when terminal have selector with --size that is not
// bare .terminal so fake terminal will not get the proper size #602
var need_char_size_recalculate = !terminal_ready(self);
Expand Down
14 changes: 12 additions & 2 deletions js/jquery.terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Fri, 15 Nov 2024 23:08:49 +0000
* Date: Sun, 17 Nov 2024 13:13:40 +0000
*/
/* global define, Map, BigInt */
/* eslint-disable */
Expand Down Expand Up @@ -5345,7 +5345,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Fri, 15 Nov 2024 23:08:49 +0000',
date: 'Sun, 17 Nov 2024 13:13:40 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -9681,6 +9681,13 @@
return parseInt(style.getPropertyValue(prop), 10) || 0;
}
// ---------------------------------------------------------------------
function get_scrollbar_width() {
var width = filler.width();
var container_width = self.width();
var padding = get_padding();
return container_width - width - (padding.left + padding.right);
}
// ---------------------------------------------------------------------
function get_padding() {
var style = window.getComputedStyle(filler[0]);
function padding(name) {
Expand Down Expand Up @@ -12050,6 +12057,9 @@
self.addClass('terminal');
var pixel_density = get_pixel_size();
var char_size = get_char_size(self);
css(self[0], {
'--terminal-scrollbar': get_scrollbar_width()
});
// this is needed when terminal have selector with --size that is not
// bare .terminal so fake terminal will not get the proper size #602
var need_char_size_recalculate = !terminal_ready(self);
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/jquery.terminal.min.js.map

Large diffs are not rendered by default.

0 comments on commit d34629f

Please sign in to comment.