Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Mixing ConPTY and Regular TCC Sessions in TCMD

Jun
1,092
48
The "Whats New" says: Take Command now supports Windows 10 / 11 pseudoconsoles (also known as ConPTY). You can define tabs that use conhost (i.e., v35 and earlier) as well as the v36 pseudoconsoles in the same Take Command session.

I launched TCMD with ConPTY=No. Then I launched a TCC window with ConPTY=Yes. When I try to attach that TCC session to TCMD, it is not listed in the tasks available for attaching. Then I launched TCMD with ConPTY=Yes, and I still did not see the TCC session.

A more general question: How does one create new TCMD tabs with a specific type of console? The "New Tab" menu item does not allow one to specify the kind of console for the new tab.

I seem to have a lot of trouble with sessions running in the new console. Here's a new one: When I press ESC after scrolling the buffer, I am not taken back to the command line. This is with the TCC session in TCMD. In a standalone TCC session, the ESC key behaves as expected.

Plus I'm still seeing the problem that the Insert key, while toggling the insert mode is not changing the appearance of the cursor. That happens with standalone TCC as well as TCC in TCMD.
 
How can one tell what kind of console a given TCC session is running in?

I have launched TCC windows with the following commands (from a TCMD session with ConPTY=No):
  • start /pgm "C:\Program Files\JPSoft\TCMD36\tcc.exe"
  • start /pgm "C:\Program Files\JPSoft\TCMD36\tcc.exe" //ConPTY=No
In both cases, they seem to be using a ConPTY console, because the ANSI sequences for underlining text work (that's how I've been determining whether I'm in a ConPTY console). The same thing happens if I run "C:\Program Files\JPSoft\TCMD36\tcc.exe" directly from the Windows Run.
 
With a little help from AI (from my browser; it stopped working again in TCC) I was able to launch TCC in a Windows Console Host instead of Windows Terminal.

%SystemRoot%\System32\conhost.exe "C:\Program Files\JPSoft\TCMD36\tcc.exe"

That session did appear in the list of possible windows to attach to TCMD.

The ANSI sequence for turning on underlining of text works in the Windows Console Host (conhost) window when it is standalone. Once I attach it to TCMD (launched with ConPTY=Yes), the ANSI sequence no longer works. It does work in the original TCC tab that was opened when TCMD started.

P.S. I just figured out why the AI command stopped working. The updater changed the OpenAI URL to https://jpsoft.com/downloads/v36/tcmd.exe!!! Fixed that, and the AI command is working again.
 
OK, but then what did you mean by "You can define tabs that use conhost (i.e., v35 and earlier) as well as the v36 pseudoconsoles in the same Take Command session." How does one "define" them?
 
I launched TCMD with ConPTY=No. Then I launched a TCC window with ConPTY=Yes. When I try to attach that TCC session to TCMD, it is not listed in the tasks available for attaching. Then I launched TCMD with ConPTY=Yes, and I still did not see the TCC session.

WAD - see my previous message.

A more general question: How does one create new TCMD tabs with a specific type of console? The "New Tab" menu item does not allow one to specify the kind of console for the new tab.

Right click on the Tab bar and select "Run", and select "Start in ConPTY".

"I seem to have a lot of trouble with sessions running in the new console. Here's a new one: When I press ESC after scrolling the buffer, I am not taken back to the command line. This is with the TCC session in TCMD. In a standalone TCC session, the ESC key behaves as expected.

WAD. You are only taken back to the current insertion point if there is any output on the line. An Esc (assuming you didn't enter anything before pressing Esc) doesn't output anything.

Plus I'm still seeing the problem that the Insert key, while toggling the insert mode is not changing the appearance of the cursor. That happens with standalone TCC as well as TCC in TCMD.

The cursor in stand-alone TCC is drawn by Windows. The cursor shape in a TCMD tab window is determined by the ANSI cursor shape sequences. (I.e., whether you want a block, line, underline, blink, etc.)
 
How can one tell what kind of console a given TCC session is running in?

There isn't any obvious "flag", because (ideally) it shouldn't be necessary. But if the window supports underlining, strikethrough, italics, 16-million colors, etc. then it has to be a ConPTY session.

I have launched TCC windows with the following commands (from a TCMD session with ConPTY=No):
  • start /pgm "C:\Program Files\JPSoft\TCMD36\tcc.exe"
  • start /pgm "C:\Program Files\JPSoft\TCMD36\tcc.exe" //ConPTY=No
In both cases, they seem to be using a ConPTY console, because the ANSI sequences for underlining text work (that's how I've been determining whether I'm in a ConPTY console). The same thing happens if I run "C:\Program Files\JPSoft\TCMD36\tcc.exe" directly from the Windows Run.

Your system is defaulting to ConPTY sessions. If you go to Options / Take Command / Advanced, you'll see a "Pseudoconsoles (ConPTY) option checked. That options sets the default for all sessions that aren't overridden by the Run dialog or the startup tabs option.
 
P.S. I just figured out why the AI command stopped working. The updater changed the OpenAI URL to https://jpsoft.com/downloads/v36/tcmd.exe!!! Fixed that, and the AI command is working again.

I have no idea what you mean by that -- you're saying the updater changed your TCMD.INI file settings? That would be extremely unexpected (and not reproducible here).
 
WAD. You are only taken back to the current insertion point if there is any output on the line. An Esc (assuming you didn't enter anything before pressing Esc) doesn't output anything.
Rex, this behavior has changed in V36 verses V35. Fill the screen until it scrolls, do shift-page up, press esc. In V35 you are returned to the prompt while in V36 you are not the scroll up remains. The esc key is a nice way to quickly scroll back to the bottom without having to type anything.
 
Well, I did not, to my knowledge, make any change to the AI configuration after I set it up initially and confirmed that the AI command now worked. It was after one of the updates that AI stopped working, so I assumed that it was something that happened during the update. It's hard for me to imagine how I would have make that change, but I suppose it's possible. I'll watch out for it.

The cursor in stand-alone TCC is drawn by Windows. The cursor shape in a TCMD tab window is determined by the ANSI cursor shape sequences. (I.e., whether you want a block, line, underline, blink, etc.)

As you can perhaps tell, I almost never use a standalone TCC, so I had not noticed that the cursor never changed between insert and overtype mode.

I am confused by what you wrote about the cursor in a TCMD tab. For a non-ConPTY session, the cursor does change in accordance with the "Option" configuration stored in the INI file, but that does not happen with a ConPTY session.

If the cursor does not change shape, how can one tell which mode one is in before starting to type?

Your system is defaulting to ConPTY sessions. If you go to Options / Take Command / Advanced, you'll see a "Pseudoconsoles (ConPTY) option checked.

Now I see that when I launch TCMD with the command-line option //ConPTY=Yes, that is the default for that instance of TCMD, even though the INI file is not updated and still has ConPTY=No.

There isn't any obvious "flag", because (ideally) it shouldn't be necessary.

If one has several TCC tabs in TCMD, one might want the prompt to show the value on ConPTY. Is there no way to have a system variable such as _ConPTY that would show the state? I suppose that for the prompt, one might be able to include the ANSI codes. Then the prompt might be underlined or not, for example. (Just tried that, and it works.)
 
Rex, this behavior has changed in V36 verses V35. Fill the screen until it scrolls, do shift-page up, press esc. In V35 you are returned to the prompt while in V36 you are not the scroll up remains. The esc key is a nice way to quickly scroll back to the bottom without having to type anything.

Yes, and it's WAD. V36 is a massive architectural overhaul, and there was never any intention to maintain 100% compatibility with v35. Which is impossible anyway, as ConPTY has nothing in common with the previous hidden console approach.
 
I am confused by what you wrote about the cursor in a TCMD tab. For a non-ConPTY session, the cursor does change in accordance with the "Option" configuration stored in the INI file, but that does not happen with a ConPTY session.

ConPTY sessions cannot track the cursor shape the way the hidden console sessions can, because Microsoft (deliberately) broke the relevant console API for pseudoconsoles. (It doesn't work in Windows Terminal either.)

So TCMD can find where the cursor is in a ConPTY session, but it cannot determine the cursor shape.
 
If one has several TCC tabs in TCMD, one might want the prompt to show the value on ConPTY. Is there no way to have a system variable such as _ConPTY that would show the state? I suppose that for the prompt, one might be able to include the ANSI codes. Then the prompt might be underlined or not, for example. (Just tried that, and it works.)

I think the question here is why you would want to have a mix of ConPTY and non-ConPTY sessions. The only advantage the non-ConPTY sessions have is the ability to detach & reattach, but I doubt that is something used by a significant number of users. (It's also something that you can't do in Windows Terminal, for the same reason -- architecturally impossible for pseudoconsoles.)

TCC knows whether it is running in a TCMD ConPTY or a Windows Terminal ConPTY, but I am not convinced that providing an internal variable would be of value. And if you were running CMD, Powershell, or bash you still wouldn't have any way to know. Which is Microsoft's plan anyway; the old console APIs are either deprecated, changed, or in a few cases just plain broken. Microsoft is doing everything it can to kill non-ConPTY sessions.
 
I'm probably over-simplifying or missing a bigger picture, but couldn't TCMD have an InitialCursorShape directive and toggle the shape with each press of Insert? It would be the user's responsibility to insure that InitialCursorShape and TCC's cursor options provided the desired result.

I mentioned elsewhere that %@winapi[user32,GetClassName,%@winapi[kernel32,GetConsoleWindow],buffer,100] will let you determine ConPty or not.
 
Yes, and it's WAD. V36 is a massive architectural overhaul, and there was never any intention to maintain 100% compatibility with v35. Which is impossible anyway, as ConPTY has nothing in common with the previous hidden console approach.
So is there a way to scroll to either the top or bottom of the buffer with a keystroke? Do you recommend compty consoles going forward? How does their performance compare to the old console/?
 
I'm finding many things so annoying about how ConPTY sessions work that I do not want to use them. The enhanced colors and ANSI controls are nice, but the change in the way ESC works, the inability to tell whether I'm in insert or overtype move, and especially the problems with tabbed toolbar items really impair my ability to get work done.

My new prompt solved the problem of being able to see at a glance what kind of TCC session is in the tab. However (thank you, Vince), I also created an alias to display the console type.
 
I'm probably over-simplifying or missing a bigger picture, but couldn't TCMD have an InitialCursorShape directive and toggle the shape with each press of Insert? It would be the user's responsibility to insure that InitialCursorShape and TCC's cursor options provided the desired result.

You're oversimplifying things. TCMD would also have to know:
  • The desired shape of the new cursor
  • The initial state (insert or overwrite)
  • What app was running in the session (your plan could only possibly work with TCC)
  • Whether a screen reader is in use (your scheme would break that completely)
TCMD would also have to ignore all the ANSI sequences to change the cursor shape or color or blinking. Which would result in you complaining that TCMD was ignoring the ANSI sequences ...

It would also make TCMD incompatible with Windows Terminal, which never changes its cursor shape for insert / overwrite. Since you've said you primarily use WT, implementing this couldn't benefit you.
 
So is there a way to scroll to either the top or bottom of the buffer with a keystroke? Do you recommend compty consoles going forward? How does their performance compare to the old console/?
Mine are Alt+Home/End/PgUp/PgDn but I couldn't find a UI for setting them.

As for performance, I've done a few comparisons. The bottom line is how do you measure performance?
 
I'm finding many things so annoying about how ConPTY sessions work that I do not want to use them. The enhanced colors and ANSI controls are nice, but the change in the way ESC works, the inability to tell whether I'm in insert or overtype move, and especially the problems with tabbed toolbar items really impair my ability to get work done.

My new prompt solved the problem of being able to see at a glance what kind of TCC session is in the tab. However (thank you, Vince), I also created an alias to display the console type.

This is reminding me of the switch from 4DOS to 4NT. I had a lot of users who were very upset at the idea of asynchronous pipes and refused to move from 4DOS until I provided "DOS pipes" (which weren't pipes at all, just multiple redirections). And now nobody uses DOS pipes.

I've added a kludge to build 19 to look for an Esc and re-scroll the display if it had been moved.

I made a fix for build 19 to save / restore the tabbed toolbar position. I still cannot understand or reproduce your other issue with tabbed toolbar items disappearing (which has nothing to do with ConPTY). Can you provide a detailed example of what you're doing?
 
My new prompt solved the problem of being able to see at a glance what kind of TCC session is in the tab. However (thank you, Vince), I also created an alias to display the console type.

Using the same strategy you could set _ConPty in TCSTART.BTM. Thay way you could more easily use in in IF statements (and still use it in your prompt).
 
So is there a way to scroll to either the top or bottom of the buffer with a keystroke? Do you recommend compty consoles going forward? How does their performance compare to the old console/?

Scrolling from the keyboard is done the same way as with non-ConPTY sessions.

Performance is tricky. Pseudoconsoles are theoretically faster than the old approach of periodically polling the hidden console and looking for changes. However, Microsoft's implementation is remarkably verbose - sometimes you'll see 50 - 100 characters (including ANSI sequences) being sent in order to print one character.

That said, my tests show the two approaches being roughly comparable in speed. Differences are usually lost in the noise of other Windows activity.

As for what you should use going forward -- Microsoft has already dictated that by dropping support for most of the old console APIs and telling developers to use ANSI sequences instead.
 
I still cannot understand or reproduce your other issue with tabbed toolbar items disappearing (which has nothing to do with ConPTY). Can you provide a detailed example of what you're doing?
  1. I load the tabbed toolbar and move it to the bottom where I want it.
  2. I open the options for TCMD, check the box for locking the toolbar, and click OK. Now the toolbar is gone!!!
  3. I reload the toolbar. It is now back at the top!! And locked there!!
I can go back and unlock the bar. When I click OK in the options dialog, the toolbar again disappears. I'm trapped in a loop.
 
I'm probably over-simplifying or missing a bigger picture, but couldn't TCMD have an InitialCursorShape directive and toggle the shape with each press of Insert? It would be the user's responsibility to insure that InitialCursorShape and TCC's cursor options provided the desired result.

I think the only way to handle this (which will only work in TCC) is to have TCC send the appropriate ANSI sequence to TCMD to change the cursor shape for insert / overwrite.
 
One test I've done is to compare TCMD/ConPty, TCMD/NoConPty, and WT in comparably-sized windows for sheer output speed. In that order, the times needed for the same output are roughly proportional to 15, 13, 13.
 
One test I've done is to compare TCMD/ConPty, TCMD/NoConPty, and WT in comparably-sized windows for sheer output speed. In that order, the times needed for the same output are roughly proportional to 15, 13, 13.

That sounds about right. TCMD is doing a lot more than WT (like TCC is doing a lot more than CMD) so it might be slightly slower in raw output speed. Though probably not perceptible visually.
 
I think the only way to handle this (which will only work in TCC) is to have TCC send the appropriate ANSI sequence to TCMD to change the cursor shape for insert / overwrite.

Having it for TCC would be all I need, but
 
Back
Top