[Lazarus] Startup environment: to Gui, or not to GUI?

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Tue Apr 11 20:44:30 CEST 2017


On 11/04/17 16:00, Henry Vermaak via Lazarus wrote:
> On Tue, Apr 11, 2017 at 01:34:35PM +0000, Mark Morgan Lloyd via Lazarus wrote:> Something like this does appear to work, tested on Linux only.> > function notGui(): boolean;> > var     i: integer;> > begin>   i := IsaTty(Input);> {$ifdef ISGUI }>   exit false;> {$endif ISGUI }> {$ifdef NOGUI }>   exit true;> {$endif NOGUI }>   result := i <> 0> end { notGui } ;> > The explicit overrides might be needed during debugging, since the> involvement of gdb forces the program to think it's being run from a shell> session.
> I'd recommend making the overrides command line parameters.  That wayyou do away with the ifdefs and a user can always override it if yourlogic somehow doesn't do the right thing.

I agree, --GUI and --TUI by choice (case-sensitive, no short form). But 
from the POV of getting a statement of what appeared to work and its 
limitations into the record I didn't want to introduce anything extraneous.

>> Looking back through older sources, I've had to jump through hoops-> reopening the input and using GetFileType() under Windows- to find out> whether stdin was piped. Fortunately I don't need that here.
> The experience on Windows is pretty awful and I've seen some interestingtricks to get a program to do the right thing based on where it waslaunched from.  For example, Visual Studio's devenv.com vs. devenv.exe,using the fact that .com takes preference over .exe in the terminal tohandle the command line parameters and sending output to the terminalthat it was called from.

Regrettably, investigating that sort of thing in too much depth can get 
one flagged as a malware writer. A few days ago I saw something very odd 
happen as a result of some search terms I used when reading up about a 
particular comms protocol.

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

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


More information about the Lazarus mailing list