From cbb6b4d2d1fe13562bd9503d209a617894cb8d66 Mon Sep 17 00:00:00 2001 From: Jason Reeves Date: Thu, 18 Dec 2025 13:28:35 -0600 Subject: [PATCH] Add terminal size check and fix viu system call --- lib/stringformat.rb | 2 +- rp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/stringformat.rb b/lib/stringformat.rb index ea10d39..e011431 100644 --- a/lib/stringformat.rb +++ b/lib/stringformat.rb @@ -53,7 +53,7 @@ def iterm2? system("convert -density 130 #{pdf_file} #{png_file} >/dev/null 2>&1") if File.exist?(png_file) width = (cols * 0.75).to_i - if system("viu -w #{width} #{png_file} >/dev/null 2>&1") + if system("viu -w #{width} #{png_file}") == true # Clean up tmp_file.unlink File.unlink(pdf_file) diff --git a/rp b/rp index 291fd6f..f60b39e 100755 --- a/rp +++ b/rp @@ -18,6 +18,14 @@ end load "#{DATA_DIR}/lib/stringformat.rb" load "#{DATA_DIR}/lib/sayings.rb" +# Check terminal size +cols = `tput cols`.to_i +lines = `tput lines`.to_i +if cols < 135 || lines < 40 + puts "Terminal must be at least 135 columns x 40 rows. Current: #{cols}x#{lines}".red + exit 1 +end + def print_header(header) puts "" figlet = RubyFiglet::Figlet.new(header, 'standard')