Re: [Lazarus] Linux GUI Application define CONSOLE

2013-04-14 Thread Daniel Simoes de Ameida
Hi Leledumbo,

Thanks for the explanation... I agree with this point of view...

I have some code shared between 2 applications, running on Text mode and GUI... 
And I used CONSOLE directive to distinguish some specific code for GUI 
application... 
I can fix my code, using another compiler directive on Build modes...
I was considering CONSOLE directive was equal on Linux and Windows...
 
[]s Daniel

Conheça o Projeto ACBr - Automaçao Comercial Brasil
DJSystem a Loja Patrocinadora do ACBr




 De: leledumbo leledumbo_c...@yahoo.co.id
Para: lazarus@lists.lazarus.freepascal.org 
Enviadas: Sábado, 13 de Abril de 2013 14:35
Assunto: Re: [Lazarus] Linux GUI Application define CONSOLE
 

 I´m confusing... I always find out that the CONSOLE directive exists only
for applications that does not require a GUI or in other words,
applications that does not require a X server

Linux applications are console, Linux doesn't have integrated GUI as a part
of the system like Windows (which is why replacing X server with something
else is quite easily possible). Everything (including X server) runs on top
of it. It's just a matter of showing the console or not. Launching Lazarus
from terminal will show output log during its execution without the need to
redirect to file via --debug-log option, which is mandatory on Windows.

 How can I distinguish applications in Text mode (CONSOLE) from Graphics
 Applications (GUI) ?

I don't think it's possible on Linux. Do you have any need for that?



--
View this message in context: 
http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-Linux-GUI-Application-define-CONSOLE-tp4030537p4030548.html
Sent from the Free Pascal - Lazarus mailing list archive at Nabble.com.

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


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


Re: [Lazarus] Linux GUI Application define CONSOLE

2013-04-14 Thread Daniel Simoes de Ameida


 
[]s Daniel

Conheça o Projeto ACBr - Automaçao Comercial Brasil
DJSystem a Loja Patrocinadora do ACBr




 De: Sven Barth pascaldra...@googlemail.com
Para: lazarus@lists.lazarus.freepascal.org 
Enviadas: Sábado, 13 de Abril de 2013 18:49
Assunto: Re: [Lazarus] Linux GUI Application define CONSOLE
 

On 13.04.2013 18:48, Daniel Simoes de Ameida wrote:
 I´m confusing... I always find out that the CONSOLE directive exists
 only for applications that does not require a GUI or in other words,
 applications that does not require a X server

 How can I distinguish applications in Text mode (CONSOLE) from Graphics
 Applications (GUI) ?

You can't as leledumbo wrote already. The compiler will even warn if you 
use $apptype ... in the main program file on Unix systems, because it 
is simply not supported there.

As a sidenote: checking for ifdef console or ifdef gui is 
problematic, because you will only be aware of a change if your units 
are completely recompiled. If you change the setting (e.g. by not using 
the IDE dialogs, but by manually adding apptype console to your 
program file) the compiler will only recompile the main program unit and 
your units won't detect a change.

Regards,
Sven

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

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


Re: [Lazarus] Linux GUI Application define CONSOLE

2013-04-14 Thread leledumbo
If your design is modular enough, you can use frontend-backend architecture.
Only the frontend should differ. This could be achieved by having 2 .lpi
referencing the same backend unit, with each own frontend (user interface).

Another way would be to use build mode, differing in -Fu paths. One will
refer to the console unit, while the other to the gui. This way requires you
to have both units having the same interface. To ease maintenance, you could
instead make one unit, but the implementation part is just an {$include}
directive. This time, -Fi (instead of -Fu) will decide the path where the
include file should be searched. So the layout is like:

Solution 1 (-Fu):
-backend.pas
-frontend/
--console/
---frontend.pas
--gui/
---frontend.pas

Solution 2 (-Fi):
-backend.pas
-frontend.pas
-include/
--console/
---frontend.inc
--gui/
---frontend.inc




--
View this message in context: 
http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-Linux-GUI-Application-define-CONSOLE-tp4030537p4030599.html
Sent from the Free Pascal - Lazarus mailing list archive at Nabble.com.

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


Re: [Lazarus] Linux GUI Application define CONSOLE

2013-04-14 Thread Kostas Michalopoulos
As a side note, in order to figure out if your program is running under X11
in Linux you can simply check  for the DISPLAY environment variable:

program test;
uses
  SysUtils;
begin
  if GetEnvironmentVariable('DISPLAY')  '' then
Writeln('Hello X11')
  else
Writeln('Hello Console');
end.

Obviously the program will detect X11 even if it is running under a
terminal emulator like xterm, konsole, gnome-terminal, etc.

This way you can detect if the user tries to run the program from a pure
console (like a virtual terminal from Ctrl+Alt+F1 to F6 in most Linux
machines or from a remote connection via SSH) or from under X11 and use the
appropriate user interface at launch time.



On Sun, Apr 14, 2013 at 3:54 PM, leledumbo leledumbo_c...@yahoo.co.idwrote:

 If your design is modular enough, you can use frontend-backend
 architecture.
 Only the frontend should differ. This could be achieved by having 2 .lpi
 referencing the same backend unit, with each own frontend (user interface).

 Another way would be to use build mode, differing in -Fu paths. One will
 refer to the console unit, while the other to the gui. This way requires
 you
 to have both units having the same interface. To ease maintenance, you
 could
 instead make one unit, but the implementation part is just an {$include}
 directive. This time, -Fi (instead of -Fu) will decide the path where the
 include file should be searched. So the layout is like:

 Solution 1 (-Fu):
 -backend.pas
 -frontend/
 --console/
 ---frontend.pas
 --gui/
 ---frontend.pas

 Solution 2 (-Fi):
 -backend.pas
 -frontend.pas
 -include/
 --console/
 ---frontend.inc
 --gui/
 ---frontend.inc




 --
 View this message in context:
 http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-Linux-GUI-Application-define-CONSOLE-tp4030537p4030599.html
 Sent from the Free Pascal - Lazarus mailing list archive at Nabble.com.

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

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


Re: [Lazarus] Linux GUI Application define CONSOLE

2013-04-13 Thread Daniel Simoes de Ameida
Hi Mattias,

Thanks for answering...

I´m confusing... I always find out that the CONSOLE directive exists only for 
applications that does not require a GUI or in other words, applications 
that does not require a X server

How can I distinguish applications in Text mode (CONSOLE) from Graphics 
Applications (GUI) ?  


 
[]s Daniel

Conheça o Projeto ACBr - Automaçao Comercial Brasil
DJSystem a Loja Patrocinadora do ACBr




 De: Mattias Gaertner nc-gaert...@netcologne.de
Para: lazarus@lists.lazarus.freepascal.org 
Enviadas: Sexta-feira, 12 de Abril de 2013 12:12
Assunto: Re: [Lazarus] Linux GUI Application define CONSOLE
 

On Fri, 12 Apr 2013 08:01:14 -0700 (PDT)
Daniel Simoes de Ameida dopidan...@yahoo.com.br wrote:

 Hello All,
 
 I noticed that GUI Applications on Linux (gtk2) are always signed as CONSOLE 
 apptype by default... 

Yes, Linux GUI Applications have always a console.

Windows GUI Applications do not have a console.

Mattias

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


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


Re: [Lazarus] Linux GUI Application define CONSOLE

2013-04-13 Thread leledumbo
 I´m confusing... I always find out that the CONSOLE directive exists only
for applications that does not require a GUI or in other words,
applications that does not require a X server

Linux applications are console, Linux doesn't have integrated GUI as a part
of the system like Windows (which is why replacing X server with something
else is quite easily possible). Everything (including X server) runs on top
of it. It's just a matter of showing the console or not. Launching Lazarus
from terminal will show output log during its execution without the need to
redirect to file via --debug-log option, which is mandatory on Windows.

 How can I distinguish applications in Text mode (CONSOLE) from Graphics
 Applications (GUI) ?

I don't think it's possible on Linux. Do you have any need for that?



--
View this message in context: 
http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-Linux-GUI-Application-define-CONSOLE-tp4030537p4030548.html
Sent from the Free Pascal - Lazarus mailing list archive at Nabble.com.

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


[Lazarus] Linux GUI Application define CONSOLE

2013-04-12 Thread Daniel Simoes de Ameida
Hello All,

I noticed that GUI Applications on Linux (gtk2) are always signed as CONSOLE 
apptype by default... 

For instance, the code below generate a compiler Error on Linux, but works on 
Windows

Please see these images for a better comprehension
http://imagebin.org/253733

http://imagebin.org/253734


unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs;

{$IFDEF CONSOLE}
  ERROR   // -- unit1.pas(11,3) Fatal: Syntax error, IMPLEMENTATION expected 
but identifier ERROR found
{$ENDIF}

type
  TForm1 = class(TForm)
  private
    { private declarations }
  public
    { public declarations }
  end;
..


I am using Lazarus 1.1 from SVN (rev 40699M)

and FPC 2.7.1 also from SVN  Free Pascal Compiler version 2.7.1 [2013/04/02] 
for i386



Is there any extra configuration needed to be done on Project Options ? 



 
[]s Daniel

Conheça o Projeto ACBr - Automaçao Comercial Brasil
DJSystem a Loja Patrocinadora do ACBr
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Linux GUI Application define CONSOLE

2013-04-12 Thread Mattias Gaertner
On Fri, 12 Apr 2013 08:01:14 -0700 (PDT)
Daniel Simoes de Ameida dopidan...@yahoo.com.br wrote:

 Hello All,
 
 I noticed that GUI Applications on Linux (gtk2) are always signed as CONSOLE 
 apptype by default... 

Yes, Linux GUI Applications have always a console.

Windows GUI Applications do not have a console.

Mattias

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