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] 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] 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


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


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

2016-04-22 Thread Bo Berglund
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.

-- 
Bo Berglund
Developer in Sweden


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


[Lazarus] How to clear screen in console app

2016-04-22 Thread Bo Berglund
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.
I started with a Console app in Lazarus and just added this piece of
code:
  { add your program here }
  repeat
ClrScr;  //Needs Crt in uses
Write('Enter command: ');
Readln(FCheck);
  until FCheck = 'q';

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.

What am I doing wrong?

-- 
Bo Berglund
Developer in Sweden


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