Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
neofetch
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
neofetch
Commits
f847b05e
Commit
f847b05e
authored
Jun 05, 2018
by
Dylan Araps
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
image: Added method to get the terminal size using an escape sequence.
parent
b7ba7687
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
7 deletions
+20
-7
neofetch
neofetch
+20
-7
No files found.
neofetch
View file @
f847b05e
...
@@ -3361,7 +3361,7 @@ image_backend() {
...
@@ -3361,7 +3361,7 @@ image_backend() {
return
return
}
}
get_
term
_size
get_
window
_size
((term_width < 1)) && {
((term_width < 1)) && {
to_ascii "Image: Failed to find terminal window size."
to_ascii "Image: Failed to find terminal window size."
...
@@ -3530,11 +3530,11 @@ get_w3m_img_path() {
...
@@ -3530,11 +3530,11 @@ get_w3m_img_path() {
err "Image: w3m-img wasn't found on your system"
err "Image: w3m-img wasn't found on your system"
}
}
get_
term
_size() {
get_
window
_size() {
# This functions gets the current window size in
# This functions gets the current window size in
# pixels.
# pixels.
#
#
# We first try to use the escape sequence "\0
44
[14t"
# We first try to use the escape sequence "\0
33
[14t"
# to get the terminal window size in pixels. If this
# to get the terminal window size in pixels. If this
# fails we then fallback to using "xdotool" or other
# fails we then fallback to using "xdotool" or other
# programs.
# programs.
...
@@ -3606,14 +3606,27 @@ get_term_size() {
...
@@ -3606,14 +3606,27 @@ get_term_size() {
term_width="${term_width:-0}"
term_width="${term_width:-0}"
}
}
get_image_size() {
# This functions determines the size to make
get_term_size() {
# the thumbnail image.
# Get the terminal size in cells.
read -r lines columns <<< "$(stty size)"
printf '%b' '\e[18t'
IFS=';t' read -d t -t 0.05 -sra term_cells
lines="${term_cells[1]}"
columns="${term_cells[2]}"
# Fallback to stty if above sequence isn't supported.
[[ -z "$lines" || -z "$columns" ]] && \
read -r lines columns <<< "$(stty size)"
# Calculate font size.
# Calculate font size.
font_width="$((term_width / columns))"
font_width="$((term_width / columns))"
font_height="$((term_height / lines))"
font_height="$((term_height / lines))"
}
get_image_size() {
# This functions determines the size to make the thumbnail image.
get_term_size
case "$image_size" in
case "$image_size" in
"auto")
"auto")
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment