Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does Dream.run clobber terminal line wrapping setting, and depend on TERM=xterm-256color? #93

Closed
2 tasks
aantron opened this issue Jul 3, 2021 · 2 comments

Comments

@aantron
Copy link
Owner

aantron commented Jul 3, 2021

Dream.run, if not called with adjust_terminal:false, sets some terminal settings, and then tries to restore them on exit (code below).

  • We have switched to Ctrl+C for exit. Are the settings being restored during exit by Ctrl+C? This can be checked by inserting a print_endline into the restore_terminal function, and just making sure the print occurs.
  • @thangngoc89 reported Dream messing with the terminal somehow inside tmux, where TERM wasn't originally xterm-256color. Is the way Dream is changing the settings portable across terminal emulation modes?

In the future, either the log will be terminal width-aware, or we will probably just use dumb line wrapping, and always behave as if adjust_terminal:false at the Dream.run level.

dream/src/http/http.ml

Lines 818 to 838 in b8a46f4

let adjust_terminal =
adjust_terminal && Sys.os_type <> "Win32" && Unix.(isatty stderr) in
let restore_terminal =
if adjust_terminal then begin
(* The mystery terminal escape sequence is $(tput rmam). Prefer this,
hopefully it is portable enough. Calling tput seems like a security
risk, and I am not aware of an API for doing this programmatically. *)
prerr_string "\x1b[?7l";
flush stderr;
let attributes = Unix.(tcgetattr stderr) in
attributes.c_echo <- false;
Unix.(tcsetattr stderr TCSANOW) attributes;
fun () ->
(* The escape sequence is $(tput smam). *)
prerr_string "\x1b[?7h";
flush stderr
end
else
ignore
in

@aantron aantron added this to the alpha3 milestone Jul 4, 2021
@outkine
Copy link
Contributor

outkine commented Aug 3, 2021

restore_terminal was not being called on Ctrl+C, but it does with this PR.

@aantron
Copy link
Owner Author

aantron commented Apr 27, 2023

I think the first part of this issue was fixed in #151. I'm not observing any issues with tmux at the moment.

@aantron aantron closed this as completed Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants