+# Get the length of a string when shown on the terminal. The return code of the
+# function is the length in "cells". Note: Echo'ing the length to the terminal,
+# which looks cleaner at first, doesn't work: this command can't be called with
+# its stdin and/or stdout redirected, as it it must be able to interact with the
+# terminal (write to and read from it).
+function axzsh_get_displayed_length {
+ echo -ne "$*\033[6n"
+ read -s -d\[ garbage
+ read -s -d R pos
+ echo -ne "\033[1K\r"
+ return $((${pos#*;} - 1))
+}
+
+# Check if terminal correctly handles "wide" characters, which means, displays
+# them with the correct width (>1).