# Terminal control characters to xterm/mintty blocked on windows

**URL:** https://discourse.julialang.org/t/terminal-control-characters-to-xterm-mintty-blocked-on-windows/94006
**Category:** General Usage
**Tags:** repl, sixel
**Created:** [February 3, 2023, 6:13pm UTC](https://discourse.julialang.org/t/terminal-control-characters-to-xterm-mintty-blocked-on-windows/94006 "2023-02-03T18:13:31Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![devel-chm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/devel-chm/32/3572_2.png) [@devel-chm](https://discourse.julialang.org/u/devel-chm)
#### Post date: [February 3, 2023, 6:13pm UTC](https://discourse.julialang.org/t/terminal-control-characters-to-xterm-mintty-blocked-on-windows/94006/1 "2023-02-03T18:13:31Z")

</div>

For remote computing, I’ve been testing the use of [Sixel Graphics](https://github.com/JuliaIO/Sixel.jl) to  
conveniently see graphics in-line with a terminal session of some  
sort (e.g., xterm or vt340).

This worked well on unix systems but when I tried things out on my  
win10 PC I was not able to view the sixel images—instead I saw only  
the characters making up the sixel data. If I output the sixel data  
from the native command line and not from julia, the image is visible.

It appears that the problem is that julia on windows seems to set  
up the TTY interface via some sort of console rather than by using  
the standard terminal IO with control sequences. I can’t tell from  
my experiments where the problem might be.

I was unable to determine a fix for the `Sixel.is_sixel_supported()`  
routine but I did add my information to the github ticket  
[mintty supports sixel](https://github.com/JuliaIO/Sixel.jl/issues/15).

I haven’t tried WSL2 on my computer but it seems that the issue is  
[still present](https://discourse.julialang.org/t/wsltty-sixel-repl-visualization/74430) which may be because `Sys.iswindows()` is being used to  
special case terminal handling which ignores actual terminal  
capabilities.

---

<div class="post-metadata">

### Author: ![devel-chm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/devel-chm/32/3572_2.png) [@devel-chm](https://discourse.julialang.org/u/devel-chm)
#### Post date: [February 3, 2023, 11:47pm UTC](https://discourse.julialang.org/t/terminal-control-characters-to-xterm-mintty-blocked-on-windows/94006/2 "2023-02-03T23:47:41Z")

</div>

Here is some bash code that can be used to DA queries.  
I’ve hardwired in the DA1 and DA2 control sequences but  
you can substitute other sequences as desired.

```bash
#!/bin/bash
#
# This shows how to use bash to send ANSI terminal control
# sequences to the underlying TTY and read the response for
# queries such as Device Attributes (DA). If the primary
# DA includes the value 4 then sixel graphics is supported.

# Query DA 1
echo -e "\n\nQuerying primary Device Attribute for TTY"
IFS=";" read -a REPLY -s -t 1 -d "c" -p $'\e[c' >&2
echo "${#REPLY[@]}" # How many values were returned?
echo "${!REPLY[@]}" # What indices were set?
# Use printf with %q option to display printing and non-
# printing values returned.
for code in "${REPLY[@]}" ; do printf '%q\n' "$code" ; done

# Query DA 2
echo -e "\n\nQuerying secondary Device Attribute for TTY"
IFS=";" read -a REPLY -s -t 1 -d "c" -p $'\e[>c' >&2
echo "${#REPLY[@]}" # How many values were returned?
echo "${!REPLY[@]}" # What indices were set?
# Use printf with %q option to display printing and non-
# printing values returned.
for code in "${REPLY[@]}" ; do printf '%q\n' "$code" ; done

```

```bash
# Here is another way to output the values from the terminal
# that seems to work for a number of different shells. It seems
# to produce output good for shell input

bash> typeset -p REPLY
declare -a REPLY=([0]=$'\E[>19' [1]="370" [2]="0")

```
