Skip to content

Commit dd33bb8

Browse files
committed
add terminal::lines() #966
1 parent 6d58346 commit dd33bb8

5 files changed

+28
-9
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* add `id` option that allow to create same terminal using hot reload [#978](https://github.com/jcubic/jquery.terminal/issues/978)
44
* allow using Object URLs in links [#982](https://github.com/jcubic/jquery.terminal/issues/982)
55
* experimental `--cols` CSS variable [#956](https://github.com/jcubic/jquery.terminal/issues/956)
6+
* add `terminal::lines()` [#966](https://github.com/jcubic/jquery.terminal/issues/966)
67
### Bugfix
78
* fix `terminal::login()` when user already authenticated [#980](https://github.com/jcubic/jquery.terminal/issues/980)
89
* improve mobile support

js/jquery.terminal-src.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -8567,14 +8567,14 @@
85678567
// :: Function limit output lines based on outputLimit option
85688568
// ---------------------------------------------------------------------
85698569
function limit_lines() {
8570+
var $lines = output.find('> div > div');
85708571
if (settings.outputLimit >= 0) {
85718572
var limit;
85728573
if (settings.outputLimit === 0) {
85738574
limit = self.rows();
85748575
} else {
85758576
limit = settings.outputLimit;
85768577
}
8577-
var $lines = output.find('> div > div');
85788578
if ($lines.length + 1 > limit) {
85798579
var max = $lines.length - limit + 1;
85808580
var for_remove = $lines.slice(0, max);
@@ -8592,8 +8592,10 @@
85928592
}
85938593
});
85948594
lines.limit_snapshot(max);
8595+
return max;
85958596
}
85968597
}
8598+
return $lines.length;
85978599
}
85988600
// ---------------------------------------------------------------------
85998601
// :: Display user greetings or terminal signature
@@ -10540,6 +10542,12 @@
1054010542
return '';
1054110543
},
1054210544
// -------------------------------------------------------------
10545+
// :: returns the number of rendered lines
10546+
// -------------------------------------------------------------
10547+
lines: function() {
10548+
return output_line_count;
10549+
},
10550+
// -------------------------------------------------------------
1054310551
// :: Return the version number
1054410552
// -------------------------------------------------------------
1054510553
version: function() {
@@ -10884,7 +10892,7 @@
1088410892
});
1088510893
command_line.__set_prompt_margin(len);
1088610894
}
10887-
limit_lines();
10895+
output_line_count = limit_lines();
1088810896
fire_event('onFlush');
1088910897
self.stopTime('flush').oneTime(10, 'flush', function() {
1089010898
var cmd_cursor = self.find('.cmd-cursor');
@@ -11971,6 +11979,7 @@
1197111979
var terminal_id = have_custom_id ? options.id : terminals.length();
1197211980
var force_awake = false; // flag used to don't pause when user return read() call
1197311981
var num_chars; // numer of chars in line
11982+
var output_line_count = 0;
1197411983
var num_rows; // number of lines that fit without scrollbar
1197511984
var command; // for tab completion
1197611985
var logins = new Stack(); // stack of logins

js/jquery.terminal.js

+13-4
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: Mon, 18 Nov 2024 23:03:37 +0000
44+
* Date: Thu, 21 Nov 2024 14:01:23 +0000
4545
*/
4646
/* global define, Map, BigInt */
4747
/* eslint-disable */
@@ -5345,7 +5345,7 @@
53455345
// -------------------------------------------------------------------------
53465346
$.terminal = {
53475347
version: 'DEV',
5348-
date: 'Mon, 18 Nov 2024 23:03:37 +0000',
5348+
date: 'Thu, 21 Nov 2024 14:01:23 +0000',
53495349
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
53505350
color_names: [
53515351
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
@@ -8567,14 +8567,14 @@
85678567
// :: Function limit output lines based on outputLimit option
85688568
// ---------------------------------------------------------------------
85698569
function limit_lines() {
8570+
var $lines = output.find('> div > div');
85708571
if (settings.outputLimit >= 0) {
85718572
var limit;
85728573
if (settings.outputLimit === 0) {
85738574
limit = self.rows();
85748575
} else {
85758576
limit = settings.outputLimit;
85768577
}
8577-
var $lines = output.find('> div > div');
85788578
if ($lines.length + 1 > limit) {
85798579
var max = $lines.length - limit + 1;
85808580
var for_remove = $lines.slice(0, max);
@@ -8592,8 +8592,10 @@
85928592
}
85938593
});
85948594
lines.limit_snapshot(max);
8595+
return max;
85958596
}
85968597
}
8598+
return $lines.length;
85978599
}
85988600
// ---------------------------------------------------------------------
85998601
// :: Display user greetings or terminal signature
@@ -10540,6 +10542,12 @@
1054010542
return '';
1054110543
},
1054210544
// -------------------------------------------------------------
10545+
// :: returns the number of rendered lines
10546+
// -------------------------------------------------------------
10547+
lines: function() {
10548+
return output_line_count;
10549+
},
10550+
// -------------------------------------------------------------
1054310551
// :: Return the version number
1054410552
// -------------------------------------------------------------
1054510553
version: function() {
@@ -10884,7 +10892,7 @@
1088410892
});
1088510893
command_line.__set_prompt_margin(len);
1088610894
}
10887-
limit_lines();
10895+
output_line_count = limit_lines();
1088810896
fire_event('onFlush');
1088910897
self.stopTime('flush').oneTime(10, 'flush', function() {
1089010898
var cmd_cursor = self.find('.cmd-cursor');
@@ -11971,6 +11979,7 @@
1197111979
var terminal_id = have_custom_id ? options.id : terminals.length();
1197211980
var force_awake = false; // flag used to don't pause when user return read() call
1197311981
var num_chars; // numer of chars in line
11982+
var output_line_count = 0;
1197411983
var num_rows; // number of lines that fit without scrollbar
1197511984
var command; // for tab completion
1197611985
var logins = new Stack(); // stack of logins

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)