rheostat2718 / conemu-maximus5

Automatically exported from code.google.com/p/conemu-maximus5
7 stars 1 forks source link

Can't set tab title from nodejs #1842

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Required information!
OS version: Win8.1 x64
ConEmu version: 140114a

Trying to set the tab title from a node.js process doesn't work.  Running 
RenameTab manually does work, and the stdout of both are identical.

process.stdout.write('\x1b]9;3;"abc"\x1b\x5c\x0d\x0a');

Causes the correct bytes to be written to stdout:

1B 5D 39 3B 33 3B 22 61 62 63 22 1B 5C 0D 0A

Original issue reported on code.google.com by josh3...@gmail.com on 18 Dec 2014 at 1:12

GoogleCodeExporter commented 8 years ago
OldBuild

Original comment by ConEmu.Maximus5 on 18 Dec 2014 at 6:38

GoogleCodeExporter commented 8 years ago
Same behavior in 141217

Original comment by josh3...@gmail.com on 18 Dec 2014 at 7:31

GoogleCodeExporter commented 8 years ago
The answer is easy. nodejs does NOT write these codes to stdout. Here is dump

AnsiDump #57: \r\n
AnsiDump #58: \r\n
AnsiDump #59: true
AnsiDump #60: \r\n
AnsiDump #61: > 

Call nodejs authors to make that working.
Or you may call GuiMacro

Original comment by ConEmu.Maximus5 on 18 Dec 2014 at 10:41

GoogleCodeExporter commented 8 years ago

Original comment by ConEmu.Maximus5 on 18 Dec 2014 at 10:41

GoogleCodeExporter commented 8 years ago
Ah - I have discovered the cause of this behavior.

When node's stdout is connected to a non-interactive sink (ie piped or 
redirected to a file), bytes written to process.stdout are written as-is.  
Thus, running `node test > out.txt` produces expected results.

However, when node is connected to an interactive terminal in Windows, it (via 
libuv) actually parses all ANSI escape codes so that it can transparently 
emulate a unix TTY terminal using Windows APIs.  Unknown and unsupported 
sequences are silently ignored.  (See 
https://github.com/libuv/libuv/blob/v1.x/src/win/tty.c)

As a consequence, the OSC commands are discarded between JS calling 
process.stdout.write() and the call to WriteConsoleW().

This can be worked around from user code by opening a raw filesystem stream on 
fd 1.

    var rawStdout = new fs.SyncWriteStream(1, { autoClose: false });

Writing ANSI escape sequences to rawStdout will be emitted properly, and ConEmu 
will rename the tab.

    rawStdout.write('\x1b]9;3;"abc"\x1b\x5c');

Original comment by josh3...@gmail.com on 20 Dec 2014 at 12:41

GoogleCodeExporter commented 8 years ago
http://stackoverflow.com/a/27575930/1405560

Original comment by ConEmu.Maximus5 on 20 Dec 2014 at 8:25

GoogleCodeExporter commented 8 years ago

Original comment by ConEmu.Maximus5 on 20 Dec 2014 at 8:25