From 4d6a4fb4256d00aa9a2a8693c6ac8f0fa67057f5 Mon Sep 17 00:00:00 2001
From: Dylan Araps <dylan.araps@gmail.com>
Date: Tue, 8 Jan 2019 10:57:33 +0200
Subject: [PATCH] cursor: Fix issues in urxvt with padding

---
 neofetch | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/neofetch b/neofetch
index 95da6417..8dab5305 100755
--- a/neofetch
+++ b/neofetch
@@ -3367,7 +3367,7 @@ get_cols() {
         cols="${cols//nl/\\n\\e[${text_padding}C${zws}}"
 
         # Add block height to info height.
-        ((info_height+=block_height+2))
+        ((info_height+=block_height+1))
 
         printf '\n\e[%bC%b\n' "$text_padding" "${zws}${cols}"
     fi
@@ -4166,9 +4166,23 @@ kde_config_dir() {
     kde_config_dir="${kde_config_dir/$'/:'*}"
 }
 
+term_padding() {
+    # Get terminal padding to properly align cursor.
+    [[ -z $term ]] && get_term
+
+    case "$term" in
+        urxvt*|"rxvt-unicode")
+            [[ -z "$xrdb" ]] && xrdb="$(xrdb -query)"
+            padding="${xrdb/*.internalBorder:}"
+            ((padding=${padding/$'\n'*}*2))
+        ;;
+    esac
+}
+
 dynamic_prompt() {
     [[ "$image_backend" == "off" ]]   && { printf '\n'; return; }
-    [[ "$image_backend" != "ascii" ]] && lines="$(((height + yoffset) / font_height + 1))"
+    [[ "$image_backend" != "ascii" ]] && {
+        term_padding; lines="$(((height + yoffset + padding) / font_height + 1))"; }
 
     # If the ascii art is taller than the info.
     ((lines=lines>info_height?lines-info_height+1:1))