Lazarus

Announcements => Third party => Topic started by: Edson on September 05, 2014, 09:01:43 pm

Title: UnTerminal, Unit for Console process control
Post by: Edson on September 05, 2014, 09:01:43 pm
'Unterminal' is a Unit for implementing Control of Console Process  in Lazarus with Prompt Detection.

This library, helps on control of the standard input/output of an process and  have the states of BUSY or READY.

https://github.com/t-edson/UnTerminal
Title: Re: UnTerminal, Unit for Console process control
Post by: exdatis on September 06, 2014, 10:09:21 am
Thank you very much for your effort and sharing
Title: Re: UnTerminal, Unit for Console process control
Post by: Edson on September 06, 2014, 06:29:01 pm
It's nothing. I use to create libraries, when develop some Apps. And some of then can be useful for other people, so I  share it.

This library was intended for use in Telnet/SSH clients. But I have used too for a SQL client.

For working with Telnet/SSH, it includes a VT100 emulator (in the unit termVT.pas), that support the basic escape sequences. I have successfully implemented a Telnet client with it.
Title: Re: UnTerminal, Unit for Console process control
Post by: Roland Chastain on September 06, 2014, 09:06:09 pm
Very interesting! I made a test with a chess engine using the UCI protocol (instead of cmd.exe) and it worked perfectly.

There was just one line to replace in your example project:

Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
begin
  //proc.Open('cmd','');
  proc.Open(txtProcess.Text, '');
end;

Congratulations for that unit.
Title: Re: UnTerminal, Unit for Console process control
Post by: BigChimp on September 06, 2014, 10:05:07 pm
Very interesting - shame it's GPL (instead of say modified LGPL like Lazarus LCL) though as it limits use to GPL programs, but of course that's your prerogative.
Title: Re: UnTerminal, Unit for Console process control
Post by: Edson on September 06, 2014, 11:31:55 pm
There was just one line to replace in your example project:

It is fixed.

Very interesting - shame it's GPL (instead of say modified LGPL like Lazarus LCL) though as it limits use to GPL programs, but of course that's your prerogative.

I haven't analized deeply the licensing. But I will consider to use a more permisive license on future releases.
Title: Re: UnTerminal, Unit for Console process control
Post by: BigChimp on September 07, 2014, 10:30:36 am
I haven't analized deeply the licensing. But I will consider to use a more permisive license on future releases.
Thanks!
Title: Re: UnTerminal, Unit for Console process control
Post by: BigChimp on September 08, 2014, 10:01:14 am
Oh, perhaps useful when working with unterminal.

I've got a sample SSH client using synapse that works on Linux and Windows
https://bitbucket.org/reiniero/smalltools/src
directory SSHClient
(not sure about license compatibility with UnTerminal though I normally license as MIT X11 which is fine when combining with GPL)

Had a quick look at Edson's repositories which also showed SSH integration but only mentioned PLink on Windows
Title: Re: UnTerminal, Unit for Console process control
Post by: Edson on September 08, 2014, 08:32:09 pm
Here is an example of using Unterminal for a Telnet/SSH Client:

https://github.com/t-edson/Tito-s-Terminal

But it use "plink.exe" for the connection, so FAIK it's onlly for Windows.

Sadly, I have not a Linux machine for test.
Title: Re: UnTerminal, Unit for Console process control
Post by: Roland Chastain on September 09, 2014, 10:00:22 am
I didn't really understand what is the usage of the AutoConfigPrompt procedure (the "Detect Prompt" button in the example project). Could someone be kind enough to explain?
Title: Re: UnTerminal, Unit for Console process control
Post by: Edson on September 09, 2014, 03:49:06 pm
It's for configuring automatically, the prompt detection of the unit. It takes the last line of the terminal and configure the unit for to detect that line like a prompt.

It's not mandatory, but if you want  that the unit knows when the process is "Ready" for to accept commands, you should configure the prompt detection.

UnTerminal have the ability for to detect when the prompt appear on the terminal, scanning line by line for to see if it matches with the Prompt configuration.

There are 3 ways for to configure the Prompt detection:

1. Setting manually, the parameters of the detection.
2. Using the method AutoConfigPrompt (like in the Example).
3. Using the event OnChkForPrompt, for to define a custom routine (like RegExp comparing).
Title: Re: UnTerminal, Unit for Console process control
Post by: Edson on September 09, 2014, 06:28:36 pm
Version 0.5 released:
https://github.com/t-edson/UnTerminal

News:
* Prompt detection improved.
* New event OnFirstReady()  implemented.
* New property for to change the scan frequency.
* Improved the translation of some names on the source.
Title: Re: UnTerminal, Unit for Console process control
Post by: Roland Chastain on September 09, 2014, 07:19:39 pm
Thank you for the useful explanation about prompt detection. Now I see.

I am making a demo of the UCI chess protocol with your unit. It works very well.

I will have a look at the latest version.

Title: Re: UnTerminal, Unit for Console process control
Post by: Roland Chastain on September 10, 2014, 08:04:58 pm
Hello! I finished my UCI demo (http://www.eschecs.fr/fichiers/LazUCIDemo.zip). Thanks again for your unit. Maybe one day (if God lends me life) I could make a chess GUI using UnTerminal.  :)
Title: Re: UnTerminal, Unit for Console process control
Post by: Edson on September 11, 2014, 12:01:08 am
It's good to know that it's useful for you. I see you're using the latest version.

I don't know about UCI, but it seems interesting. I hope you could make your chess GUI soon.
Title: Re: UnTerminal, Unit for Console process control
Post by: BigChimp on September 11, 2014, 09:18:16 am
Maybe one day (if God lends me life) I could make a chess GUI using UnTerminal.  :)
Well... you could have a look at http://wiki.lazarus.freepascal.org/Lazarus_Application_Gallery#Simple_Chess which is a GUI without engine so that sounds quite suitable...
Title: Re: UnTerminal, Unit for Console process control
Post by: Roland Chastain on September 11, 2014, 04:14:53 pm
@BigChimp

Thank you for the link. I will look at that project.

Title: Re: UnTerminal, Unit for Console process control
Post by: Edson on September 13, 2014, 05:56:14 pm
@Roland

Probably this library could help: https://github.com/t-edson/ogEditGraf
It's a graphical editor engine, for managing visual objects.
Title: Re: UnTerminal, Unit for Console process control
Post by: Edson on September 13, 2014, 06:29:08 pm
Version 0.6 released:
https://github.com/t-edson/UnTerminal

News:
* New events OnReadData() and OnLineCompleted(), implemented.
* Event OnInitLines() replaced by OnInitScreen().
* New Property 'ClearOnOpen'.
* Fixed Prompt detection when using "prmAtEnd".
Title: Re: UnTerminal, Unit for Console process control
Post by: Roland Chastain on September 14, 2014, 05:43:05 pm
@Edson

Thank you for the link to the graphical library. I downloaded it.

Congratulations for the new version of UnTerminal.
Title: Re: UnTerminal, Unit for Console process control
Post by: Roland Chastain on September 17, 2014, 07:38:51 am
Hello Edson!

It seems that you forgot to update the example in your latest release: I don't manage to compile it.

Quote
E:\Atelier\Lazarus\UnTerminal\UnTerminal.pas(809,8) Error: identifier idents no member "OnScrollLines"
E:\Atelier\Lazarus\UnTerminal\UnTerminal.pas(810,8) Error: identifier idents no member "OnLineCompleted"

Title: Re: UnTerminal, Unit for Console process control
Post by: Edson on September 17, 2014, 05:15:39 pm
I have verified, and it doesn't compile like you said.

But, the example is correct. And, if you can see the properties OnScrollLines and OnLineCompleted, exist and are public.  %)

In my local copy, it compiles OK.

I'll try to find the problem.
Title: Re: UnTerminal, Unit for Console process control
Post by: Edson on September 17, 2014, 05:26:35 pm
It's solved.

It is my fault. There was an old copy of TermVT on the example folder.

Thanks for checking.
Title: Re: UnTerminal, Unit for Console process control
Post by: Roland Chastain on September 17, 2014, 06:39:58 pm
Yes, it works now. Thank you!

Title: Re: UnTerminal, Unit for Console process control
Post by: Edson on November 08, 2014, 04:10:51 pm
UnTerminal 0.7 is released.

https://github.com/t-edson/UnTerminal

News: Some events have been changed and It has been defined several ways (documented) for to capture the output of the processes.
Title: Re: UnTerminal, Unit for Console process control
Post by: Edson on November 16, 2016, 02:49:47 am
UnTerminal 0.9 released.

https://github.com/t-edson/UnTerminal

'Unterminal' is a library for implementing Control of Console Process  in Lazarus, with Prompt Detection.

Some News:
New methods created, to use the process in a Loop.
Capability for changing the properties of the process, before to Run.
Included 3 types of Line Delimiters to Send, and 4 types of Line Delimiters to receive.
Tested in Linux.
Title: Re: UnTerminal, Unit for Console process control
Post by: RolandC on November 16, 2016, 06:53:30 am
Hello! Thank you for that new version. Tested successfully under Windows.  :)

I had to comment out a line in the second demo project:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   proc:= TConsoleProc.Create(nil);
  4.   //proc.LineDelim := TTL_CRLF;

I could compile also my UCI protocol demo, with one modification:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   proc := TConsoleProc.Create(nil);
  4.   //proc.sendCRLF := true;

http://www.eschecs.fr/fichiers/LazUCIDemo.zip
Title: Re: UnTerminal, Unit for Console process control
Post by: Edson on November 16, 2016, 04:18:26 pm
I had to comment out a line in the second demo project:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   proc:= TConsoleProc.Create(nil);
  4.   //proc.LineDelim := TTL_CRLF;


Sorry. I forgot to update this code. It's updated now.

The correct line is:

Code: Pascal  [Select][+][-]
  1.   proc.LineDelimSend := LDS_CRLF;
  2.  

It's because now UnTerminal have 3 ways to send line ending to the process (before, there was 2):
   LDS_CRLF -> Send CRLF
   LDS_CR -> Send only CR
   LDS_LF -> Send Only LF

Now the equivalent for:
Code: Pascal  [Select][+][-]
  1.   proc.sendCRLF := true;

Is
Code: Pascal  [Select][+][-]
  1.   proc.LineDelimSend := LDS_CRLF;
Title: Re: UnTerminal, Unit for Console process control
Post by: RolandC on November 16, 2016, 07:49:59 pm
@Edson

Thank you.
Title: Re: UnTerminal, Unit for Console process control
Post by: Edson on October 03, 2020, 06:58:56 pm
UnTerminal has been updated: https://github.com/t-edson/UnTerminal

- A new simplified way to execute external programs.
- Tested in Linux and Windows.
- Sample projects are updated.
- English translation is advanced.
TinyPortal © 2005-2018