U++ framework
Do not panic. Ask here before giving up.

Home » Developing U++ » UppHub » A terminal emulator widget for U++
Re: A terminal emulator widget for U++ [message #56243 is a reply to message #56242] Fri, 12 February 2021 23:14 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Hello Klugier,

Thanks for the info.

That's what I've suspected, and that's why I asked for you the check it against xterm.

The bash config. sets the ink color to white. (SGR 37). That color is meant to be changed by the user, If the background (which can be overridden by the theme) is the same color, then it'll be unreadble. (unless you explicitly set the color white or the paper color to something else on TerminalCtrl.)


I reproduced it with xterm, GNOME terminal, VTE and kitty. Smile
We can call it a bash config/theme clash and a false alarm.

Best regards,

Oblivion


[Updated on: Fri, 12 February 2021 23:18]

Report message to a moderator

Re: A terminal emulator widget for U++ [message #56348 is a reply to message #51415] Tue, 23 February 2021 22:57 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
A small tip:

TerminalCtrl can display PowerLine fonts and glyphs
By default, however, if you install and try to use PowerLine fonts, you will notice that some glyphs are missing. This is because U++ handles its fallback fonts through a compile-time list.
In order to utilize powerline fonts, all you need to do is add the following line to the end of fallback fonts lists [sFontReplacements array], in Draw/FontCR.cpp:

{ "PowerlineSymbols", 0x00000000, 0x08000008 },


This method can be applied to other fonts as well. Just use uppbox/FontCover app to calculate the font range for your desired font.

If you recompile U++, set up powerline fonts support and configure apps, say vim, you should get a display similar to the below screenshot(taken via stock TerminalLayoutExample):

index.php?t=getfile&id=6382&private=0


Best regards,
Oblivion


[Updated on: Tue, 23 February 2021 23:13]

Report message to a moderator

Re: A terminal emulator widget for U++ [message #56368 is a reply to message #51415] Sat, 27 February 2021 22:07 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Hello,

tldlr:

In the following weeks TerminalCtrl will finally gain winpty support.
This means that it will be able to run as a local terminal ("natively") on Windows XP/Vista/7/8/10, without requiring Cygwin, Msys2 or Win10 pseudoconsole api. Smile

This idea was brewing for some time as I was investigating the possibility of embedding native windows console support in PtyProcess class.

As it turned out, it was suprisingly trivial, thanks to winpty.

Pros:

1. TerminalCtrl does not require any specific hack or intervention to run on Windows as a local (=not remote) console, thanks to its design and WinPty.

2. Cygwin or MSYS2 are not required. Only the libwinpty (winpty.lib or winpty.dll) and winpty-agent is required and they compile on native CLANG compiler and Windows environment.

3. WinPty's API seamlessly integrates with PtyProcess class and it api. As a result, the existing terminal examples or code using PtyProcess class do not require any modification. A simple compiler flag (flagWINPTY) will be enough to switch it on.

4. This means it is possible run cmd.exe, bash.exe, powershell.exe, or any Windows-native console application (such as FAR file manager - see screenshot below) directly on TerminalCtrl/PtyProcess.

5. This also means that TerminalCtrl can be set to run in CygWin and Msys2 environments, and it can easily replace Mintty, which is, AFAIK, bound to Cygwin or Msys2 subsystem.

6. winpty has MIT license. You can freely supply the winpty.lib and winpty-agent with your application.


Cons:

- Nothing much at the moment, really. Winpty has some small quirks but they arent specific to our terminal emulator widget.


Below screenshot is from the Far file manager. It is running natively on the stock TerminalExample, on Windows 7.

index.php?t=getfile&id=6385&private=0


If you have any questions, bug reports, suggestions criticism, etc. let me know.


Best regards,
Oblivion



[Updated on: Sat, 27 February 2021 22:23]

Report message to a moderator

Re: A terminal emulator widget for U++ [message #56383 is a reply to message #51415] Mon, 01 March 2021 23:49 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Hi,

TerminalCtrl now officially supports winpty on Windows platform.

This effectively eliminates one of the major "show-stoppers" we've had up until now with TerminalCtrl: Native console support on Windows XP/Vista/7/8. (ıt can also be used on Win10, but we already have PTY support for that version of windows)

You have two choice here should you select the WINPTY backend:

1) You can compile winpty-agent, winpty.dll and winpty.lib. These files can be easily created, It is not a complicated process.
2) You can use the existing files in your system (for example you can get them from MSYS2 installation or from the GIT Windows client). Just put the agent and dll in the same directory as your terminal app and link your app against winpty.lib (by activating WINPTY flag).

 


In the process, I made a so-called "course-correction" which unfortunately slightly breaks the existing TerminalCtrl installations: I have removed the PtyProcess code from TerminalCtrl source tree and made it into a separate pacakge.
Thus you will need to explicitly add PtyProcess package and its heeader file to your apllications if you want to use it.

E.g.
#include <PtyProcess/PtyProcess.h>


I apologize for this break, but hopefully this will allow easier maintenance and better separation of code.


Best regards,
Oblivion


[Updated on: Mon, 01 March 2021 23:54]

Report message to a moderator

Re: A terminal emulator widget for U++ [message #56393 is a reply to message #51415] Wed, 03 March 2021 20:45 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Hi a small update,

I have already managed to compile and statically link winpty library with stock Upp and the bundled clang compiler with very little wrestling.
Not to mention that winpty has MIT license.. This means we can simply provide the library with the PtyProcess package, and preferably making it the default backend, for easy maintenance and development. This and testing shouldn't take more than a week or so.
Later I can wrestle with MSC. Smile


Best regards,
Oblivion




[Updated on: Wed, 03 March 2021 20:45]

Report message to a moderator

Re: A terminal emulator widget for U++ [message #56404 is a reply to message #51415] Sun, 07 March 2021 14:42 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Hello,


- PtyProcess package now contains a patched and statically linked version of libwinpty.

- winpty is from now on the default pty backend on Windows platform. No WINPTY flag is required to activate it.

- Since winpty requires an agent executable, I have also added PtyAgent to both TerminalCtrl nest on UppHub and to upp-components/Core.

- After building the PtyAgent, just move the resulting exacutable (PtyAgent.exe) to your apps executables directory.

- Package is tested with CLANG. MSC will follow...


This means that effectively Terminal package -as a local pty- and its examples are now able to run and work on various versions of Windows.



If you have any questions or suggestions, let me know.

Best regards,
Oblivion



[Updated on: Sun, 07 March 2021 14:44]

Report message to a moderator

Re: A terminal emulator widget for U++ [message #56929 is a reply to message #51415] Sat, 01 May 2021 14:17 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Hi,

Terminal package is updated. This update is somewhat big, as the 2021.1 release is imminent.
Consider the below changes as a summary of 2021.1 milestone (v0.5) changes/highlights:

Changes:

* Cell padding (horizontal/vertical) is implemented.
* Missing tester methods are implemented.
+ Display renderer is refactored and optimized.
+ Parser (VTInstream) is optimized, using chunking in addition to traditional state machine. It is ~82% faster on average.on a reference machine.
+ Sixel renderer is refactored and optimized. The renderer's raw performance is almost doubled. From 14 to 27 MB/s on a reference machine. 
+ An out-of-bounds crash with dynamic colors feature is fixed.
+ Dynamic colors feature is improved. It can now set/reset multiple colors in a single command.
+ Display refreshing strategy is improved.
+ Local echo now correctly calls the display refreshing methods.
+ A crash when selecting wrapped text lines is fixed.
+ Parser now allows OSC sequences to have UTF-8 payload on  UTF-8 parsing mode.
+ SGR mouse tracking mode gained a pixel-level tracking variant. 
+ UTf-8 titles (xterm extension) are now correctly displayed and reported.
+ On Windows Vista, 7, 8, 10 PtyProcess now allows native console applications via WinPty.
+ On windows, PtyProcess now defaults to statically linked WinPty backend. (Win10 api stays as the recommended option on Windows ver. >= 10)
+ On windows native console (Via WinPty), TerminalCtrl now correctly refreshes the page size after a window size change.
+ Deprecated "Terminal" alias is now removed. 



Only a few more compliance tests and cosmetic changes remain. After that, I'll mark this as 2021.1


Suggestions, bug reports, etc .are welcome.

Best regards,
Oblivion


[Updated on: Sat, 01 May 2021 14:58]

Report message to a moderator

Re: A terminal emulator widget for U++ [message #57100 is a reply to message #51415] Tue, 25 May 2021 13:00 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Hi,

TerminalCtrl will be marked as v0.5 (2021.1) next week. This release will have a lot of improvements.

TerminalLayoutExample (the GUI building example) will include some more tricks such as unicode input method (demonstrating the way to use popup windows with TerminalCtrl.)

A preview (gif):

https://i.imgur.com/e5h3vjz.gif


Smile

This will be available next week.

Best regards,

Oblivion


[Updated on: Fri, 28 May 2021 11:36]

Report message to a moderator

Re: A terminal emulator widget for U++ [message #57126 is a reply to message #51415] Thu, 27 May 2021 20:39 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
I usually don't add screenshots or gifs from Windows, but here it is:

TerminalLayoutExample, running on Windows 7 (Winpty/cmd.exe), demonstrating the improved unicode codepoint insertion popup and a simple banner, using echo parser. (will be available next week)

https://i.imgur.com/JjUa46b.gif


Best regards,
Oblivion


[Updated on: Thu, 27 May 2021 21:15]

Report message to a moderator

Re: A terminal emulator widget for U++ [message #57136 is a reply to message #51415] Sat, 29 May 2021 18:08 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Hello,

Terminal package is tagged as 2021.1 and officially released/updated. It is available via Upphub and upp-components repo.
This version brings many improvements (such as Windows 7/8/10, winpty support) and bug fixes. See my previous posts and git logs. for details.


Best regards,
Oblivion


[Updated on: Sat, 29 May 2021 19:59]

Report message to a moderator

Re: A terminal emulator widget for U++ [message #57242 is a reply to message #57136] Tue, 15 June 2021 16:41 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1431
Registered: December 2006
Ultimate Contributor
Compilation problem on Mac while compiling TerminalInWebBrowserExample:
/Users/ssg/worker0/m-upphub-TerminalCtrl/build/TerminalCtrl/Terminal/Keys.cpp:312:89: error: use of undeclared identifier 'K_OPTION_KEY'; did you mean 'K_OPTION'?
        if(findarg(key & ~(K_CTRL|K_ALT|K_SHIFT|K_OPTION), K_CTRL_KEY, K_ALT_KEY, K_SHIFT_KEY, K_OPTION_KEY) >= 0)
                                                                                               ^~~~~~~~~~~~
                                                                                               K_OPTION
/Users/ssg/dvlp/cpp/code/upp/git/uppsrc/CtrlCore/CtrlCore.h:103:2: note: 'K_OPTION' declared here
        K_OPTION       = 0x4000000,
        ^

MacOS can be easily installed in a VM (check for such projects on github).


Regards,
Novo
Re: A terminal emulator widget for U++ [message #57702 is a reply to message #57242] Fri, 26 November 2021 23:19 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1118
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello Oblivion,

I just read the article about 10 Cool Command Line Application on OMG Ubuntu, how many of theme are compatible with TerminalCtrl? I think these applications give good testing environment. You could try it by yourself!

Klugier


U++ - one framework to rule them all.
Re: A terminal emulator widget for U++ [message #57703 is a reply to message #57702] Sat, 27 November 2021 07:51 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Hello Klugier,

(I've been changing my job, so I was away for several month. And I am almost back to developing U++ stuff... Nice to see you all. Smile )

All of those mentioned applications AFAIK are compatiable with TerminalCtrl. We even have a video demonstrating the mapscii on TerminalCtrl's earlier versions. (I've tested them all except the twitter app) If you find any problems. let me know.

Even the highly experimental next-gen terminal stuff (notcurses demos, vtm, etc.) are compatible wihh TerminalCtrl. And the new wchar32 will make things even better on the unicode side. (I am going to test it soon)

ATM, TerminalCtrl passes 425 unit tests, and fails on 86 tests when passed as 'xterm'. This is AFAIK one of the highest scores for non-xterm-based VTEs. (results are taken from esctest terminal unit testing suite).
Where Gnome Terminal can pass only 136 tests when disguised as 'xterm' (Not that Gnome terminal is bad, it just does not implement some legacy stuff for old apps and other features)


Not to mention that even Far Manager (a CLI-based TUI file manager on Windows) works on TerminalCtrl. Cool


A side note: I use vim and emacs, htop, ranger on TerminalCtrl regularly.


Best regards,
Oblivion



[Updated on: Sat, 27 November 2021 08:05]

Report message to a moderator

Re: A terminal emulator widget for U++ [message #57705 is a reply to message #57702] Sat, 27 November 2021 10:47 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Klugier wrote on Sat, 27 November 2021 01:19
Hello Oblivion,

I just read the article about 10 Cool Command Line Application on OMG Ubuntu, how many of theme are compatible with TerminalCtrl? I think these applications give good testing environment. You could try it by yourself!

Klugier


A screenshot of btop:

index.php?t=getfile&id=6524&private=0

Smile

Best regards,
Oblivion


Re: A terminal emulator widget for U++ [message #57841 is a reply to message #51415] Tue, 21 December 2021 07:39 Go to previous messageGo to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
a lazy man's questions:

1. (I did RTFM - so this question goes away)

2. Can the ctrl be used to run as a login shell? (not just as an emulator)
(This is for applications that require use of .profile and not just .bashrc)

[Updated on: Tue, 21 December 2021 07:44]

Report message to a moderator

Re: A terminal emulator widget for U++ [message #57846 is a reply to message #57841] Tue, 21 December 2021 09:40 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Hello slashupp,


Quote:
2. Can the ctrl be used to run as a login shell? (not just as an emulator)
(This is for applications that require use of .profile and not just .bashrc)


Yes you can. TerminalCtrl, being a ctrl, simply interprets a string input which may contain terminal escape commands and characters. You feed it with any source of string.
It, however, comes with an optional/default PtyProcess class, which can runs system processes, including login shells. (If it doesn't suit your needs you can simply replace the pty with any other source)


Best regards,
Oblivion


Re: A terminal emulator widget for U++ [message #58093 is a reply to message #51415] Sat, 12 February 2022 19:16 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Hi,

Terminal package will receive a big update in March 2022.

In the meantime, however, I am happy to announce that you can enjoy the brand new enhanced unicode support of U++ (wchar32) in TerminalCtrl, which means the terminal can now display virtually all of the emojis correctly.
The required changes were minor, and already pushed to the both upp-components and Upphub repos, as TerminalCtrl was already designed to work with up ot 32 bit characters from the beginning.

A screenshot taken with vtm, a modern text user interface and terminal multiplexer (running on TerminalLayoutExample)

https://i.imgur.com/LrTCEYH.png

You can access the free demo of vtm to test TerminalCtrl, using the following command via the stock TerminaCtrl examples:

#ssh vtm@netxs.online



Best regards,
Oblivion


Re: A terminal emulator widget for U++ [message #58436 is a reply to message #51415] Fri, 20 May 2022 11:48 Go to previous messageGo to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 227
Registered: June 2011
Experienced Member
Very nice control but it also needs a ton of optimization work. If I run find . * in my home directory it takes 7.4 seconds in Konsole, ~12 seconds in lxterm and xterm and 1 minute 44 seconds in TerminalCtrl.
Re: A terminal emulator widget for U++ [message #58437 is a reply to message #51415] Fri, 20 May 2022 13:53 Go to previous messageGo to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 227
Registered: June 2011
Experienced Member
Just to make sure I tried it again with

tr -dc '[:graph:]' < /dev/urandom | tr -d \''\\'\` | head -c 1G > test.txt


and

time cat test.txt


For Konsole I got:

real    1m4.362s
user    0m0.017s
sys     0m6.407s


and for TerminalCtrl I got

real    18m33.085s
user    0m0.024s
sys     0m10.896s


rxvt appears to be the fastest I've tested at

real    0m17.997s
user    0m0.004s
sys     0m4.674s

[Updated on: Fri, 20 May 2022 16:53]

Report message to a moderator

Re: A terminal emulator widget for U++ [message #58440 is a reply to message #58436] Fri, 20 May 2022 23:24 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Hi!

Quote:
y nice control but it also needs a ton of optimization work. If I run find . * in my home directory it takes 7.4 seconds in Konsole, ~12 seconds in lxterm and xterm and 1 minute 44 seconds in TerminalCtrl.


Thank you very much for the feedback!

My guess is that you've probably tested it on TerminalExample (which isn't meant to test the real-life performance of TerminalCtrl.
If so, could you re-test it on TerminalLayoutExample, which uses a proper high performance (high throughput) loop?

Best regards,
Oblivion


Re: A terminal emulator widget for U++ [message #58441 is a reply to message #58440] Fri, 20 May 2022 23:33 Go to previous messageGo to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 227
Registered: June 2011
Experienced Member
Oblivion,

Your guess was correct, I tried the layout example as instructed:

real    0m50.865s
user    0m0.015s
sys     0m6.776s


The performance was better than Konsole. Very nice!
Re: A terminal emulator widget for U++ [message #58442 is a reply to message #58441] Sat, 21 May 2022 00:00 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Hello jacksonRIAB,

Just to give you some idea as to where TerminalCtrl stands:

This is somewhat old, but results (ratio) still hold and --in fact lot better--(I will update the results ASAP, after I merge the new optimizations...)

CPU:        AMD FX 6100 - Black Edition (Six-core processor)
Memory:     8 GiB, DDR-3 1800 Mhz
Storage:    128 Gib SSD, 1Tib HDD
Graphics:   AMD Radeon R7 240, 2GiB
Monitor:    LCD, HD (1080p)
OS/Kernel:  Arch/Linux 5.9 (x86_64)
Desktop:    GNOME 3.36 (X11)
Framework:  Ultimate++ 2020.1 (alpha)
Flags:      GUI
Compilers:  GCC 10.0.1 CLANG 10.0.0
Application: TerminalExample (with a high througput loop).

Disclaimer: The benchmarks below do not represent any competition.  
            they don't represent any weak spots of the used terminals.
            The sole purpose of these benchmarks is to give an idea as to where
            the Terminal ctrl's "engine" performance stands ATM.

Note: All benchmarks are repeated 50 times, automatically.
      The performance difference between GCC/CLANG builds is negligeable.
      The latest stable versions of these terminals are used (as of May-June 2020).

Results of command: "time find /usr", Total files: 415897, page size: 237 x 55, Monospace Font)

Terminal Emulator                  real         user        sys        Notes
-----------------                 ----------   ----------   ---------- ----------
Alacritty                         0m3,776s     0m1,134s     0m2,637s   Scrollback buffer size: 64k
Terminal ctrl                     0m4,126s     0m1,202s     0m2,466s   Scrollback buffer size: 64k
Kitty                             0m5,608s     0m1,224s     0m2,763s   Scrollback buffer size: 64k
Gnome Terminal                    0m6,785s     0m1,243s     0m3,015s   Scrollback buffer size: 64k
xterm                             0m24,368s    0m1,661s     0m3,766s   Scrollback buffer size: 64k

Terminal Emulator                  real         user        sys         Notes
-----------------                 ----------   ----------   ----------  ----------
Simple terminal (0.8)             0m3,791s     0m1,162s     0m2,533s    Has no scrollback buffer.
Terminal ctrl   (0.3)             0m3,971s     0m1,120s     0m2,472s    Scrollback disabled.

Terminal Emulator                  real         user        sys         Notes
-----------------                 ----------   ----------   ----------  ----------
Terminal ctrl   (0.3)             0m4,380s     0m1,479s     0m2,536s    localhost, Scrollback buffer size: 2000 lines, no compression, (SshTerminalExample is used)
PuTTY (0.73)                      0m40,828s    0m1,354s     0m3,071s    localhost, Scrollback buffer size: 2000 lines, no compression

// Vte-bench, benchmark 1: scrolling. page size: 237 x 55, Monospace Font.

Terminal Emulator                  real         user        sys        Notes
-----------------                 ----------   ----------   ---------- ----------
Alacritty                         0m1,936s     0m0,001s     0m0,946s
Kitty                             0m2,985s     0m0,000s     0m0,567s
Gnome Terminal                    0m3,758s     0m0,001s     0m0,940s
Terminal ctrl                     0m4,064s     0m0,000s     0m0,859s
Simple terminal (0.8)             0m4,623s     0m0,000s     0m1,105s 
xterm                             0m47,249s    0m0,000s     0m0,567s

// Vte-bench, benchmark 2: alt-screen-random-write, page size: 237 x 55, Monospace Font.

Terminal Emulator                  real         user        sys        Notes
-----------------                 ----------   ----------   ---------- ----------
Alacritty                         0m1,520s     0m0,000s     0m0,554snear-real-life,
Kitty                             0m2,750s     0m0,000s     0m0,408s
Gnome Terminal                    0m3,153s     0m0,004s     0m0,726s
Terminal ctrl                     0m3,790s     0m0,000s     0m0,474s
Simple terminal (0.8)             0m7,097s     0m0,001s     0m0,825s 
xterm                             0m19,797s    0m0,001s     0m0,993s

// Vte-bench, benchmark 3: scrolling-in-region, page size: 237 x 55, Monospace Font.

Terminal Emulator                  real         user        sys        Notes
-----------------                 ----------   ----------   ---------- ----------
Alacritty                         0m3,337s     0m0,001s     0m3,297s
Gnome Terminal                    0m5,280s     0m0,001s     0m3,254s
Kitty                             0m6,326s     0m0,001s     0m6,034s
Terminal ctrl                     0m6,739s     0m0,001s     0m4,033s
Simple terminal (0.8)             0m7,844s     0m0,001s     0m7,348s
xterm                             3m36,599s    0m0,001s     0m11,011s



If you need help with TerminalCtrl, or have any questions, please let me know.


Best regards,
Oblivion


[Updated on: Sat, 21 May 2022 00:15]

Report message to a moderator

Re: A terminal emulator widget for U++ [message #58443 is a reply to message #58442] Sat, 21 May 2022 06:23 Go to previous messageGo to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 227
Registered: June 2011
Experienced Member
Thanks for the data, Oblivion. Impressive work!
Compile problem on WIN10 [message #58812 is a reply to message #51415] Tue, 13 September 2022 15:15 Go to previous messageGo to next message
peterh is currently offline  peterh
Messages: 108
Registered: November 2018
Location: Germany
Experienced Member
Hi, I tried TerminalLayoutExample and some other Examples.

These show a compilation error on WIN 10. It doesnt matter if I use CLang or MSVC.

HANDLE WinPtyCreateProcess(const char *cmdptr, const char *envptr, const char *cd, winpty_t* hConsole)
{
	Buffer<wchar> cmd, env;
	sCmdToUnicode(cmd, cmdptr);
	sEnvToUnicode(env, envptr);

	auto hSpawnConfig = winpty_spawn_config_new(
		WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN,
		cmd,                          //error here
		nullptr,
		cd ? ~WString(cd) : nullptr,  //error here
		env,                          //error here
		nullptr);

C:\upp\UppHub\TerminalCtrl\PtyProcess\Win32Pty.cpp (104): error: no matching function for call to 'winpty_spawn_config_new'
 (): auto hSpawnConfig = winpty_spawn_config_new(
C:\upp\UppHub\TerminalCtrl\PtyProcess/lib/include/winpty.h (170): note: candidate function not viable: no known conversion from 'Buffer<Upp::wchar>' (aka 'Buffer<unsigned long>') to 'LPCWSTR' (aka 'const wchar_t *') for 2nd argument
 (): winpty_spawn_config_new(UINT64 spawnFlags,
 (): 1 error generated.


It cannot convert from Buffer<wchar> to LPCWSTR.
I tried to fix it, but no sucess.

My C++ and Upp knowledge is very limited, C knowledge is pretty good.
It happens with Build 16324 and with the stable Build.
Edit:
I can compile it by this modification:
	auto hSpawnConfig = winpty_spawn_config_new(
		WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN,
		(wchar_t *) ~cmd,
		nullptr,
		(wchar_t *) (cd ? ~WString(cd) : nullptr),
		(wchar_t *) ~env,
		nullptr);

Then it compiles and runs, it opens a window, and closes it immediately without any error message.
I dont think this is the intended behaviour.

[Updated on: Tue, 13 September 2022 18:39]

Report message to a moderator

Re: Compile problem on WIN10 [message #58814 is a reply to message #58812] Tue, 13 September 2022 21:39 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Hello peterh,

Thank you for reporting this problem. This is a known problem due to the U++'s transition to 16 bit wchar to 32 bit wchar. There is already a fix in the pipeline and the change will be pushed to the repo this weekend.
It requires a slightly more modification than just type casting (The culprit is env variables structure...)

Best regards,
Oblivion


[Updated on: Tue, 13 September 2022 21:45]

Report message to a moderator

Re: Compile problem on WIN10 [message #58816 is a reply to message #58814] Wed, 14 September 2022 03:48 Go to previous messageGo to next message
peterh is currently offline  peterh
Messages: 108
Registered: November 2018
Location: Germany
Experienced Member
Thank you.
My typecasting was a quickn dirty attempt and only for experimentation to get something running in the debugger for further investigation.
I cant fix it myself, that is clear now.
Thanks for your work!

[Updated on: Wed, 14 September 2022 03:57]

Report message to a moderator

Re: Compile problem on WIN10 [message #58819 is a reply to message #58816] Thu, 15 September 2022 00:31 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Hello peterh,

I've fixed the winpty backend wchar issue (hopefully) and pushed the changes. Please check.

By the way, if you are on Win10 you can also use the native pseudoconsole api of Win10, if it is installed (recommended).
To do that you need to compile U++ with WIN10 flag (flagWIN10)

Best regards,
Oblivion


[Updated on: Thu, 15 September 2022 00:32]

Report message to a moderator

Re: Compile problem on WIN10 [message #58820 is a reply to message #58819] Thu, 15 September 2022 06:54 Go to previous messageGo to next message
peterh is currently offline  peterh
Messages: 108
Registered: November 2018
Location: Germany
Experienced Member
Thank you.

I tried two examples: TabbedTerminalExample and TerminalLayoutExample.
Both show similar behavior:
With "GUI" they compile without warnings. When started, they open a window and immediately close it and terminate without error.

With "GUI WIN10" there is the same compilation error in both:

C:/upp/out/UppHub/PtyProcess/CLANGx64.Debug.Debug_Full.Gui.Win10\PtyProcess$blitz.cpp (13): In file included from C:/upp/out/UppHub/PtyProcess/CLANGx64.Debug.Debug_Full.Gui.Win10\PtyProcess$blitz.cpp:13:
C:\upp\UppHub\TerminalCtrl\PtyProcess\Win32Pty.cpp (80): error: expected ')'
C:\upp\UppHub\TerminalCtrl\PtyProcess\Win32Pty.cpp (88): error: extraneous ')' before ';'
C:\upp\UppHub\TerminalCtrl\PtyProcess\Win32Pty.cpp (81): warning: left operand of comma operator has no effect [-Wunused-value]
C:\upp\UppHub\TerminalCtrl\PtyProcess\Win32Pty.cpp (82): warning: left operand of comma operator has no effect [-Wunused-value]
 (): nullptr,
C:\upp\UppHub\TerminalCtrl\PtyProcess\Win32Pty.cpp (84): warning: left operand of comma operator has no effect [-Wunused-value]
C:\upp\UppHub\TerminalCtrl\PtyProcess\Win32Pty.cpp (87): warning: left operand of comma operator has no effect [-Wunused-value]
C:\upp\UppHub\TerminalCtrl\PtyProcess\Win32Pty.cpp (88): warning: expression result unused [-Wunused-value]


On Win10 64 Bit, compiled with Clang 64 bit and MSVC 64 bit.
Upp is version 16324. I tried Stable built of Upp too, this did not solve it.

[Updated on: Thu, 15 September 2022 06:58]

Report message to a moderator

Re: Compile problem on WIN10 [message #58821 is a reply to message #58820] Thu, 15 September 2022 07:14 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Quote:
I tried two examples: TabbedTerminalExample and TerminalLayoutExample.
Both show similar behavior:
With "GUI" they compile without warnings. When started, they open a window and immediately close it and terminate without error.


Hmm..

For winpty backend:

Have you also compiled the PtyAgent package (It is in the UppHub/TerminalCtrl folder)?
You also need to compile the PtyAgent package and move the resulting PtyAgent.exe into the same folder of your main executable. It is an agent (daemon) that winpty backend talks to.


For Win10:

I will look into the problem tonight, and try to fix the issue.

Also, you can enable the Log in the relevant ptyprocess file by uncommenting the LLOG

Thank you for your patience.

Best regards,
Oblivion



[Updated on: Thu, 15 September 2022 07:18]

Report message to a moderator

Re: A terminal emulator widget for U++ [message #58822 is a reply to message #51415] Thu, 15 September 2022 07:25 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
OK,
I've fixed the typo with WIN10 backend. (but don't have time to test now. If you encounter any problems let me know, I'll fix it ASAP)

Best regards,
Oblivion


Re: A terminal emulator widget for U++ [message #58823 is a reply to message #58822] Thu, 15 September 2022 07:58 Go to previous messageGo to next message
peterh is currently offline  peterh
Messages: 108
Registered: November 2018
Location: Germany
Experienced Member
Yes, now both compile without warnings, both with "GUI" and "GUI WIN10".

To achieve this, it was not enough to reinstall, I deleted the "TerminalCtrl" directory and installed fresh.

Both now open a window and close it immediately.
I am not in a hurry; I am just trying this stuff and do not know how this will work, I am just trying.

I am not sure if I am doing something wrong or if I need something additional.
I had the idea to embed a terminal control into my own app, but as said, I am not in a hurry and if I can help or test something I am happy to do so.
Re: A terminal emulator widget for U++ [message #58825 is a reply to message #58823] Thu, 15 September 2022 09:03 Go to previous messageGo to next message
peterh is currently offline  peterh
Messages: 108
Registered: November 2018
Location: Germany
Experienced Member
I think I found a problem in TabbedTerminalExample main() Run()

		while(IsOpen() && !tabs.IsEmpty()) {
			ProcessEvents();
			for(int i = 0; i < tabs.GetCount(); i++) {
				TerminalTab& tt = tabs[i];
/* Error here? --->*/		if(!tt.Do()) {
					tabbar.RemoveCtrl(tt);
					tabs.Remove(i);
					i--;
				}
			}
			Sleep(10);
		}


If I replace the marked line by
if(i && !tt.Do()) {

Then it opens a tabbed window.
I dont fully understand the code and why the loop counter is decremented inside the loop, however this seems to be a problem, because "i" becomes negative, when it was zero before.

Edit: I do now think after some research, the program is ok, and I simply dont have the interface required.
I know terminals and emulators from my job (I am retired now), these start up, then you can select the interface, but this program apparently has no selection and I do not know which interface or port it needs.

[Updated on: Thu, 15 September 2022 12:15]

Report message to a moderator

Re: A terminal emulator widget for U++ [message #58830 is a reply to message #58823] Thu, 15 September 2022 19:09 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Hello peterh,

peterh wrote on Thu, 15 September 2022 08:58
Yes, now both compile without warnings, both with "GUI" and "GUI WIN10".

To achieve this, it was not enough to reinstall, I deleted the "TerminalCtrl" directory and installed fresh.

Both now open a window and close it immediately.
I am not in a hurry; I am just trying this stuff and do not know how this will work, I am just trying.

I am not sure if I am doing something wrong or if I need something additional.
I had the idea to embed a terminal control into my own app, but as said, I am not in a hurry and if I can help or test something I am happy to do so.


Thank you for your reports and patience.

For winpty backend:

I assume that you've moved the PtyAgent.exe into the same directory as TerminalLayoutExample.exe,

Then "normally" there are only a few things that can cause the terminal window to open and close immediately (pty failure):

1) The variables passed to PtyProcess (env, cd, cmd) have some error. E.g., the examples use "ComSpec" env variable to locate the command line interface executable (cmd.exe or powershell.exe, etc.) This can be checked by manually providing the full path of cmd.exe or powershell.exe to the PtyProcess.

2) Execution of or access to PtyAgent executable is blocked by Windows. (insufficient permissions)


Either case, I'd be grateful if you could post the log file (uncommenting the LLOG() macro in Win32Pty.cpp before running the example)


Still, I am going to improve the error handling/diagnostics in PtyProcess this weekend.

Best regards,
Oblivion


[Updated on: Thu, 15 September 2022 19:55]

Report message to a moderator

Re: A terminal emulator widget for U++ [message #58833 is a reply to message #58830] Fri, 16 September 2022 06:10 Go to previous messageGo to next message
peterh is currently offline  peterh
Messages: 108
Registered: November 2018
Location: Germany
Experienced Member
Quote:
I assume that you've moved the PtyAgent.exe into the same directory as TerminalLayoutExample.exe,


I did not know about PtyAgent.exe and searched my whole upp folder for it, no such file exists.
I searched also for PtyAgent and discovered a package with this name.
I tried to compile it, but got errors:
I do yet not know the reason, I must dig deeper in this, in the moment I do not know enough to ask qualified questions about it....
Re: A terminal emulator widget for U++ [message #58834 is a reply to message #58830] Fri, 16 September 2022 07:41 Go to previous messageGo to next message
peterh is currently offline  peterh
Messages: 108
Registered: November 2018
Location: Germany
Experienced Member
Ok, now I compiled PtyAgent.exe and it runs in mode "GUI", but not in mode "GUI WIN10".
In this later case the logfile is:

* C:\upp\out\UppHub\CLANGx64.Debug.Debug_Full.Gui.Win10\TerminalLayoutExample.exe 16.09.2022 07:37:46, user: peter

PtyProcess [WIN32]: Win32CreateProcess() failed.
PtyProcess [WIN32]: Couldn't set pty size!
Re: A terminal emulator widget for U++ [message #58852 is a reply to message #58834] Sat, 17 September 2022 18:40 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Hello peterh,

I've tried to fix WIN10 issue. Please check.

The lack of documentation is my fault (laziness/). I will add some doc to clarify the usage and setup of PtyProcess.
In the meantime, here's a short summary that can make basic things clear.

1) PtyProcess can use two backends on Windows (for console process):

   a) winpty: This backend can be compiled and run on Win >= Vista.
              Requires the PtyAgent.exe to be present. This agent is a daemon that handles the win32 console stuff.
              The PtyAgent executable must be put into the same directory as the application using the PtyProces.
              PtyAgent can be found in TerminalCtrl/PtyAgent folder. It has to be separately compiled.
              This backend does not require U++ to be compiled with WIN10 flag.

   b) win10:  This backend uses the window 10 native pseudoconsole api. This api and relevant subsystem is added to
              windows with the later revisions of windows 10. Does not use or require winpty or Ptyagent.exe
              This backend requires U++ to be compiled with WIN10 flag.
 
2) Either of these backends can be used on windows version >= 10. Only winpty can be used on Windows version < 10

3) TerminalCtrl does not require PtyProcess. You can write your own. TerminalCtrl only expects data input.
   The source of the input is up to the user/developer. PtyPRocess is only a reference implementation,
   and provided with the Terminal packages as a default option.

4) To better test TerminalCtrl and PtyProcess in Windows, recommended demo case would be to install 
   the good old Far Manager (a text mode file manager you can find on the net). 




If you have more questions or need any help embedding TerminalCtrl/PtyProcess into your app, let me know.

Best regards,
Oblivion




[Updated on: Sat, 17 September 2022 18:44]

Report message to a moderator

Re: A terminal emulator widget for U++ [message #58853 is a reply to message #58852] Sat, 17 September 2022 20:58 Go to previous messageGo to next message
peterh is currently offline  peterh
Messages: 108
Registered: November 2018
Location: Germany
Experienced Member
Thank you very much.
It is now functional in both modes "GUI" and "GUI WIN10".
Also your description made it clear enough to find my way.
Re: A terminal emulator widget for U++ [message #59193 is a reply to message #51415] Sun, 20 November 2022 21:11 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Hi,
Next week I will push the latest changes to Terminal package.
On of the major highlights of this version will be the performance optimizations.
I have heavily refactored the sequence parser and have been testing the hell out of it for around 6 months.
The results are: 3-5 times higher throughput.(In certain demanding scenarios the jump is from 120 MB/secs, to 600 MB secs, which is almost the limits of the testing machine (specs will be available with the update too)

But for now I have used the very demanding notcurses demos to whet your appetite (A video):

https://videoapi-muybridge.vimeocdn.com/animated-thumbnails/image/97a5df98-5f21-47be-8a23-8e0517b6be7b.gif?ClientID=vimeo-core-prod&Date=1668975001&Signature=0184fb8765bd75b5c5829a2e9004cb4a2cf70683

Notice that, the application (notcurses demo) in not simply bombarding the terminal display with a bunch of unicode characters to sample a video. As you can see on the top-right corner, there is actually a sixel "camera" view of the same lift-off video, in sync. The raw "horse-power" of the optimized parser and sixel renderer is enough for us to both write unicode (notascci) art image and and direct pixels on the terminal display at the same time. And this happends synchronously, no MT is used.

Link to the full video (taken on TerminalLayoutExample): https://vimeo.com/773086733


Best regards,
Oblviion


[Updated on: Sun, 20 November 2022 21:55]

Report message to a moderator

Re: A terminal emulator widget for U++ [message #59459 is a reply to message #51415] Sat, 31 December 2022 11:19 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Hi,

Parser and sixel optimization has landed in TerminalCtrl.

And the age old question finally has an answer: But, can it run DOOM?

Yes, yes, it can!..

https://bit.ly/3GwUC2I

Cool

More on: https://vimeo.com/manage/videos/785369882

Happy new year to all U++ users.

Best regards,
Oblivion


[Updated on: Sat, 31 December 2022 11:38]

Report message to a moderator

Re: A terminal emulator widget for U++ [message #59889 is a reply to message #51415] Sat, 20 May 2023 17:15 Go to previous messageGo to previous message
Oblivion is currently offline  Oblivion
Messages: 1266
Registered: August 2007
Senior Contributor
Hi,

Terminal package has seen some improvements and fixes.

- Terminal lines are no longer truncated on window/terminal resize (when the new size is smaller than the old size).
- Size hint now has round edges.
- Programmable colors (reset) wrong index variable fixed.


Best regards,
Oblivion


[Updated on: Sat, 20 May 2023 17:16]

Report message to a moderator

Previous Topic: SerialPort & SerialPortListener class
Next Topic: Added NetCDF library
Goto Forum:
  


Current Time: Tue May 26 06:40:32 GMT+2 2026

Total time taken to generate the page: 0.01414 seconds