Skip to content

Instantly share code, notes, and snippets.

@heimskr
Last active September 28, 2019 23:24
Show Gist options
  • Save heimskr/a5143b62934aaee10ced425f682ff35e to your computer and use it in GitHub Desktop.
Save heimskr/a5143b62934aaee10ced425f682ff35e to your computer and use it in GitHub Desktop.
Tests whether DECSLRM works properly.
#!/bin/bash
enable_hmargins() { echo -ne "\x1b[?69h"; }
disable_hmargins() { echo -ne "\x1b[?69l"; }
hmargins() { echo -ne "\x1b[$1;$2s"; } # left, right
vmargins() { echo -ne "\x1b[$1;$2r"; } # top, bottom
origin_on() { echo -ne "\x1b[?6h"; }
origin_off() { echo -ne "\x1b[?6l"; }
scroll_up() { echo -ne "\x1b[$1S"; }
scroll_down() { echo -ne "\x1b[$1T"; }
blank() { scroll_up 999; }
bg() { echo -ne "\x1b[4$1m"; }
rows() { tput lines; }
cols() { tput cols; }
enable_hmargins
hmargins 1 $((`cols`/2))
vmargins 1 $((`rows`/2))
origin_on
bg 1
blank
hmargins $((`cols`/2)) `cols`
bg 2
blank
hmargins 1 $((`cols`/2))
vmargins $((`rows`/2)) `rows`
bg 4
blank
hmargins $((`cols`/2)) `cols`
bg 3
blank
bg 1
echo -n "Press enter to escape this mess."
read
disable_hmargins
origin_off
clear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment