Re: [Lazarus] How to clear screen in console app

2016-04-23 Thread Bart
On 4/23/16, Bo Berglund  wrote:

> When I started my program in Lazarus nothing showed up at all so I had
> to google for it and then I was directed towards the menu
> "View/Debug Windows/Terminal Output" which displays a window titled
> "Console".
> This is the window I refer to and it does not behave like the real
> terminal...

Indeed it is not a terminal.
AFAIK it's a pseudoterminal based upon a TMemo or TSynEdit (too lazy
to look it up).
The code is in $(LazarusDir)/debugger/pseudoterminaldlg.pp

There is a bugreport already about it's behaviour (echoing control
characters) in http://bugs.freepascal.org/view.php?id=22349

Feel free to post enhencements.

Bart

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Fatal: Cannot find IdMappedPortTCP used by xxxx

2016-04-23 Thread Mattias Gaertner
On Sat, 23 Apr 2016 11:38:28 +0200
Bo Berglund  wrote:

>[...]
> >> I have googled and looked at old list messages but to no avail. The
> >> closest I got was someone telling me that Lazarus will handle this
> >> fine if only the lpk file is opened once. So I selected File/Open and
> >> navigated to the Indy10 installation dir and opened the IndyLaz.lpk
> >> file and then closed it. No difference at all! The used unit cannot be
> >> found
> >
> >Open it once, so the IDE knows how to resolve a package name (and
> >version) to the location on your disk.
> 
> Well, that was what I did to start with, but it did not help. Compile
> still complains.

Yes, as I explained, opening it once allows the IDE to resolve a package
name, e.g. "IndyLaz". After that you can use the package name in your
project, which is needed for compile.
The package knows the needed compiler flags including the search paths.

 
> So what I ended up doing was to go into the Project Options and in
> Paths added into "Compiler Options/Paths/Other unit files" the
> following:
> ../../dev/indy10/Core;../../dev/indy10/Protocols;../../dev/indy10/System
> 
> Now the project builds but with this warning:
> Warning: other unit files search path (aka unit path) of "MapPort"
> contains "/home/pi/dev/indy10/Core", which belongs to package
> "indylaz"

Either add the package, or add flags manually. Don't do both.

 
> So it seems like for some reason Lazarus now thinks there are two ways
> to the Indy10 files...

There are.


> So I removed the entry in the project options shown above and then I
> compiled again. Now working without me understanding the logic behind
> it all.

Maybe it is not your fault. AFAIK the IndyLaz package is notorious for
fail to compile, because the compiler has sometimes trouble resolving
its unit dependencies. I will try to get a copy.

Mattias

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Fatal: Cannot find IdMappedPortTCP used by xxxx

2016-04-23 Thread Bo Berglund
This message seems not to have made it to Gmane, so trying again...

On Sat, 23 Apr 2016 11:01:38 +0200, Mattias Gaertner
 wrote:

>On Sat, 23 Apr 2016 10:12:33 +0200
>Bo Berglund  wrote:
>
>>[...]
>> I have googled and looked at old list messages but to no avail. The
>> closest I got was someone telling me that Lazarus will handle this
>> fine if only the lpk file is opened once. So I selected File/Open and
>> navigated to the Indy10 installation dir and opened the IndyLaz.lpk
>> file and then closed it. No difference at all! The used unit cannot be
>> found
>
>Open it once, so the IDE knows how to resolve a package name (and
>version) to the location on your disk.

Well, that was what I did to start with, but it did not help. Compile
still complains.

So what I ended up doing was to go into the Project Options and in
Paths added into "Compiler Options/Paths/Other unit files" the
following:
../../dev/indy10/Core;../../dev/indy10/Protocols;../../dev/indy10/System

Now the project builds but with this warning:
Warning: other unit files search path (aka unit path) of "MapPort"
contains "/home/pi/dev/indy10/Core", which belongs to package
"indylaz"

So it seems like for some reason Lazarus now thinks there are two ways
to the Indy10 files...

So I removed the entry in the project options shown above and then I
compiled again. Now working without me understanding the logic behind
it all.



-- 
Bo Berglund
Developer in Sweden


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to clear screen in console app

2016-04-23 Thread Michael Van Canneyt



On Sat, 23 Apr 2016, Bo Berglund wrote:


On Sat, 23 Apr 2016 08:10:09 +, Mark Morgan Lloyd
 wrote:


I don't know whether the ClrScr procedure refers to libtinfo, or what
properties libtinfo thinks the debug window has. It could probably be
argued that the debug window should set TERM to indicate that it doesn't
obey commands, but I'd suggest that if the program does a ClrScr then
the programmer wants notification of this and it should probably /not/
wipe earlier debug output. After all, the debug window is there for
debugging, not for normal interaction.



I am comparing to how it works in Delphi (7)...
When I program a console program in Delphi and run it from within the
IDE it creates the console window and the interactions are shown
there.
All Writeln() output shows up as is and the program stops for input on
ReadLn() commands etc.

When I started my program in Lazarus nothing showed up at all so I had
to google for it and then I was directed towards the menu
"View/Debug Windows/Terminal Output" which displays a window titled
"Console".
This is the window I refer to and it does not behave like the real
terminal...


No, it does not. Because it is not a real terminal and does not obey the
ANSI codes to control the terminal.

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Fatal: Cannot find IdMappedPortTCP used by xxxx

2016-04-23 Thread Bo Berglund
On Sat, 23 Apr 2016 11:01:38 +0200, Mattias Gaertner
 wrote:

>On Sat, 23 Apr 2016 10:12:33 +0200
>Bo Berglund  wrote:
>
>>[...]
>> I have googled and looked at old list messages but to no avail. The
>> closest I got was someone telling me that Lazarus will handle this
>> fine if only the lpk file is opened once. So I selected File/Open and
>> navigated to the Indy10 installation dir and opened the IndyLaz.lpk
>> file and then closed it. No difference at all! The used unit cannot be
>> found
>
>Open it once, so the IDE knows how to resolve a package name (and
>version) to the location on your disk.

Well, that was what I did to start with, but it did not help. Compile
still complains.

So what I ended up doing was to go into the Project Options and in
Paths added into "Compiler Options/Paths/Other unit files" the
following:
../../dev/indy10/Core;../../dev/indy10/Protocols;../../dev/indy10/System

Now the project builds but with this warning:
Warning: other unit files search path (aka unit path) of "MapPort"
contains "/home/pi/dev/indy10/Core", which belongs to package
"indylaz"

So it seems like for some reason Lazarus now thinks there are two ways
to the Indy10 files...

So I removed the entry in the project options shown above and then I
compiled again. Now working without me understanding the logic behind
it all.



-- 
Bo Berglund
Developer in Sweden


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Fatal: Cannot find IdMappedPortTCP used by xxxx

2016-04-23 Thread Mattias Gaertner
On Sat, 23 Apr 2016 10:12:33 +0200
Bo Berglund  wrote:

>[...]
> I have googled and looked at old list messages but to no avail. The
> closest I got was someone telling me that Lazarus will handle this
> fine if only the lpk file is opened once. So I selected File/Open and
> navigated to the Indy10 installation dir and opened the IndyLaz.lpk
> file and then closed it. No difference at all! The used unit cannot be
> found

Open it once, so the IDE knows how to resolve a package name (and
version) to the location on your disk.

The IDE does not add every known package to every project. Every
project has its own list of package requirements. Open the package and
click on "Use / Add to project". Or use the Project Inspector to edit
the package list.

> So it seems like if one creates a non-GUI application in Lazarus then
> the packages installed in Lazarus are not available anymore. :(

When you drop a component onto a designer form, the IDE automatically
adds the package to the project's package list. In a non-GUI project
you have to do this step yourself.

> Note:
> the Indy10 components are all non-GUI in the first place and I usually
> always create them in code.
> 
> How to solve this?

Mattias

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to clear screen in console app

2016-04-23 Thread Bo Berglund
On Sat, 23 Apr 2016 08:10:09 +, Mark Morgan Lloyd
 wrote:

>I don't know whether the ClrScr procedure refers to libtinfo, or what 
>properties libtinfo thinks the debug window has. It could probably be 
>argued that the debug window should set TERM to indicate that it doesn't 
>obey commands, but I'd suggest that if the program does a ClrScr then 
>the programmer wants notification of this and it should probably /not/ 
>wipe earlier debug output. After all, the debug window is there for 
>debugging, not for normal interaction.
>

I am comparing to how it works in Delphi (7)...
When I program a console program in Delphi and run it from within the
IDE it creates the console window and the interactions are shown
there.
All Writeln() output shows up as is and the program stops for input on
ReadLn() commands etc.

When I started my program in Lazarus nothing showed up at all so I had
to google for it and then I was directed towards the menu
"View/Debug Windows/Terminal Output" which displays a window titled
"Console".
This is the window I refer to and it does not behave like the real
terminal...

If OTOH I open a terminal window and navigate to the project dir and
start the executable produced by Lazarus, then it behaves as expected.

I am working to transfer my GUI test program into a terminal program
with no GUI output so it can be started via the console to map my TCP
interactions.
Then I don't have to access any GUI at all to get the port forwarding
to work. The target RPi is located in Texas behind a slow Internet
connection while I am in Sweden close to Stockholm. A long ways away..

I access the site via VPN but bringing up a TightVNC GUI is no fun due
to the latencies caused by the slow Internet speed.
SSH via PuTTY works much better and I plan on using screen to run the
mapper program while I can continue to work in the terminal base.


-- 
Bo Berglund
Developer in Sweden


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to clear screen in console app

2016-04-23 Thread Michael Van Canneyt



On Sat, 23 Apr 2016, Mark Morgan Lloyd wrote:


Michael Van Canneyt wrote:

On Sat, 23 Apr 2016, Bo Berglund wrote:


On Sat, 23 Apr 2016 07:32:55 +0200, Bo Berglund
 wrote:


I need to make a console app that can run on Linux.
It would be a simple thing I believed, but no...

I cannot get the ClrScr command working, it just puts strange
characters on the screen instead of clearing it.

...

But the console debug window just shows a bunch of control characters
(square with 001B inside) plus [6n [H [m [H [2JEnter command:
And every command I enter results in a new line being displayed rather
than staying on the same line and erasing the previous output.


UPDATE:
It seems to be caused by the Lazarus debug console window!
If I go to the dir where the program resides in my terminal (both
local and via SSH) and execute ~/tmp/project1 then it looks OK.

So my question now changes to:
Why does the debug window show different output than the actual
terminal console?

I am using Lazarus 1.6 release and fpc 3.0.0 both built from svn
sources on a Raspberry Pi3 with Raspbian Jessie if that matters.


The console respects the special terminal control characters.
The debug window does not respect these characters, and just prints them 
out

to screen. I am not sure this can be properly handled. Maybe there is an
option that can be given to xterm to respect the characters.

If you are debugging using SSH, then you probably need to add the -t 
option.


The console window in which the shell and app run might have different 
commands, depending on what's actually being used (i.e. xterm, an SSH session 
from a remote system and so on). The console window will have an associated 
$TERM shell description, and strictly speaking the program that wants to 
clear the screen should refer to this possibly using curses or libtinto.


I don't know whether the ClrScr procedure refers to libtinfo,


No. It just uses ansi escape characters.

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Fatal: Cannot find IdMappedPortTCP used by xxxx

2016-04-23 Thread Bo Berglund
I am again very confused about how Lazarus works.
First I created a GUI program to test TCP port forwarding using the
Indy10 component TIdMappedPortTCP. Indy 10 is installed in my Lazarus.

I created a class to encapsulate the functionality and this class uses
the IdMappedPortTCP file from Indy.
All went well and now I am trying to move this over to a non-GUI
program, so I created a new "Program" in Lazarus and saved it to the
same directory as my earlier GUI test.
I also entered the tcpmapper into the program uses clause and
proceeded to define a variable of the class in tcpmapper to handle the
processing. Lazarus does find tcpmapper, and parses its code.

But now it all breaks down! I can for the life of me not get tcpmapper
to pass the compiler even though it did when used from the GUI
application!
It complains about not finding IdMappedPortTCP.

I have googled and looked at old list messages but to no avail. The
closest I got was someone telling me that Lazarus will handle this
fine if only the lpk file is opened once. So I selected File/Open and
navigated to the Indy10 installation dir and opened the IndyLaz.lpk
file and then closed it. No difference at all! The used unit cannot be
found

So it seems like if one creates a non-GUI application in Lazarus then
the packages installed in Lazarus are not available anymore. :(
Note:
the Indy10 components are all non-GUI in the first place and I usually
always create them in code.

How to solve this?


-- 
Bo Berglund
Developer in Sweden


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to clear screen in console app

2016-04-23 Thread Mark Morgan Lloyd

Michael Van Canneyt wrote:

On Sat, 23 Apr 2016, Bo Berglund wrote:


On Sat, 23 Apr 2016 07:32:55 +0200, Bo Berglund
 wrote:


I need to make a console app that can run on Linux.
It would be a simple thing I believed, but no...

I cannot get the ClrScr command working, it just puts strange
characters on the screen instead of clearing it.

...

But the console debug window just shows a bunch of control characters
(square with 001B inside) plus [6n [H [m [H [2JEnter command:
And every command I enter results in a new line being displayed rather
than staying on the same line and erasing the previous output.


UPDATE:
It seems to be caused by the Lazarus debug console window!
If I go to the dir where the program resides in my terminal (both
local and via SSH) and execute ~/tmp/project1 then it looks OK.

So my question now changes to:
Why does the debug window show different output than the actual
terminal console?

I am using Lazarus 1.6 release and fpc 3.0.0 both built from svn
sources on a Raspberry Pi3 with Raspbian Jessie if that matters.


The console respects the special terminal control characters.
The debug window does not respect these characters, and just prints them 
out

to screen. I am not sure this can be properly handled. Maybe there is an
option that can be given to xterm to respect the characters.

If you are debugging using SSH, then you probably need to add the -t 
option.


The console window in which the shell and app run might have different 
commands, depending on what's actually being used (i.e. xterm, an SSH 
session from a remote system and so on). The console window will have an 
associated $TERM shell description, and strictly speaking the program 
that wants to clear the screen should refer to this possibly using 
curses or libtinto.


I don't know whether the ClrScr procedure refers to libtinfo, or what 
properties libtinfo thinks the debug window has. It could probably be 
argued that the debug window should set TERM to indicate that it doesn't 
obey commands, but I'd suggest that if the program does a ClrScr then 
the programmer wants notification of this and it should probably /not/ 
wipe earlier debug output. After all, the debug window is there for 
debugging, not for normal interaction.


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to clear screen in console app

2016-04-23 Thread Michael Van Canneyt



On Sat, 23 Apr 2016, Bo Berglund wrote:


On Sat, 23 Apr 2016 07:32:55 +0200, Bo Berglund
 wrote:


I need to make a console app that can run on Linux.
It would be a simple thing I believed, but no...

I cannot get the ClrScr command working, it just puts strange
characters on the screen instead of clearing it.

...

But the console debug window just shows a bunch of control characters
(square with 001B inside) plus [6n [H [m [H [2JEnter command:
And every command I enter results in a new line being displayed rather
than staying on the same line and erasing the previous output.


UPDATE:
It seems to be caused by the Lazarus debug console window!
If I go to the dir where the program resides in my terminal (both
local and via SSH) and execute ~/tmp/project1 then it looks OK.

So my question now changes to:
Why does the debug window show different output than the actual
terminal console?

I am using Lazarus 1.6 release and fpc 3.0.0 both built from svn
sources on a Raspberry Pi3 with Raspbian Jessie if that matters.


The console respects the special terminal control characters.
The debug window does not respect these characters, and just prints them out
to screen. I am not sure this can be properly handled. Maybe there is an
option that can be given to xterm to respect the characters.

If you are debugging using SSH, then you probably need to add the -t option.

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus