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


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


Re: [Lazarus] Linux GUI Application define CONSOLE

2013-04-13 Thread Sven Barth

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


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 
>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 
>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 Daniel Simoes de Ameida
Sorry for previous message... 

I really hate Yahoo Mail, I cant find a way to avoid top posting...

I found a way to share code between GUI and CONSOLE applications... On CONSOLE 
applications, I do not use Packages dependencies, instead I add all directories 
from required Packages on "Other Unit Files", but I also inform a "Unit Output 
directory", so all files are always recompiled, as CONSOLE mode, and .PPU saved 
on a different location...

 
[]s Daniel

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



>
> De: Sven Barth 
>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 wrote:

> 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