nerves-hub / nerves_hub_link

Connect devices to NervesHub via a Phoenix channel
https://hex.pm/packages/nerves_hub_link
Apache License 2.0
36 stars 18 forks source link

Handle :window_size message (#46) #48

Closed honsq90 closed 3 years ago

honsq90 commented 4 years ago

I'm having issues running the tests locally at the moment.

I was hoping of doing an assert via. Any ideas?

assert_receive {:tty_data, "\e[33m\e[36mSome message about changing window size\e[0m\e[33m\e[0m\r\n"}
mobileoverlord commented 4 years ago

Thanks for submitting this, its looking great. I am going to try to give things a spin locally.

jjcarstens commented 4 years ago

When you change the window size, it will attempt to adjust any current line in the buffer and move the cursor back where it should go. With an empty line waiting for input, it would look something like this:

iex(1)> {:ok, iex_pid} = ExTTY.start_link(handler: self(), type: :elixir)                              
{:ok, #PID<0.449.0>}

# Increase width 10 columns
iex(2)> ExTTY.window_change(iex_pid, 90, 80)
:ok

iex(3)> flush
{:tty_data, "\e[8Diex(1)>                     \e[20D"}

Also, if the width is the same, it returns the empty buffer:

iex(4)> ExTTY.window_change(iex_pid, 90, 80)
:ok
iex(5)> flush
{:tty_data, ""}
fhunleth commented 3 years ago

@jjcarstens Can this be merged?