1. More Manual Typo/errors

Forked from Re: manual typo for public function gcd(atom p, atom q)

SDPringle said...

I made a ticket 941. It is for 4.0.

SD Pringle

In the manual discussion of maybe_any_key The Two examples given appear to have been copied from the previous entry for "any_key" without prepending "maybe_"

Also, the program "regexps.ex" in the demo folder uses "maybe_any_key" consequently the program does not pause as needed under Linux.

-- in the demo program regexps.ex change: 
-- maybe_any_key() 
-- to: 
ifdef UNIX  then 
any_key() 
elsifdef WINDOWS then 
maybe any_key() -- Requires Windows XP or later or Windows 2003 or later to work 
end ifdef 

Ken

new topic     » topic index » view message » categorize

2. Re: More Manual Typo/errors

Linux and Windows versions of Euphoria work very different from a user's perspective. On Windows, if you open a EUPHORIA program from the GUI. The program will create a console Window for you and do its STDIN and STDOUT in that Window. On Linux, the Euphoria programs cannot be opened from the GUI at all. But suppose we figure out how to do so then the Interpreter under Linux will not create such a Window and you will see nothing.

So for UNIX in general we assume console programs are run from the console. On Windows we don't need to assume because this can be determined in a program. Without a maybe_any_key() Windows would create the window, run the program and then close the window without user interaction. When run in an already created console the Window would not close until you close it manually or type in 'exit' to close the shell. So, in this case the program doesn't ask for you to press a key.

Why should the interpreter ask for a key press? Are you opening demos from a GUI in Linux?

new topic     » goto parent     » topic index » view message » categorize

3. Re: More Manual Typo/errors

SDPringle said...

On Linux, the Euphoria programs cannot be opened from the GUI at all. But suppose we figure out how to do so then the Interpreter under Linux will not create such a Window and you will see nothing.

"Suppose we can figure out how to do so.."?? Shawn, you have lost the plot completely. A number of LINUX editors have supported the use of a terminal for years. Even before terminal support was added to WEE I simply ran WEE from a command line in a terminal, loaded the console program I was editing in the editor and then, once I executed the console program, I switched back to the terminal window to see the console programs output. This worked fine because my console program required a key press to exit. The latest version of WEE supports execution of a console program in a terminal - which works for some console programs, but not for other console programs such as the demo, "regexps.ex" which only works as expected in a GUI's terminal, provided you ask for a key press in order to keep the program from terminating instantly.

SDPringle said...

So for UNIX, in general, we assume console programs are run from the console. On Windows, we don't need to assume because this can be determined in a program. Without a maybe_any_key() Windows would create the window, run the program and then close the window without user interaction. When run in an already created console the Window would not close until you close it manually or type in 'exit' to close the shell. So, in this case, the program doesn't ask for you to press a key.

Why should the interpreter ask for a key press? Are you opening demos from a GUI in Linux?

We should not assume that Unix console programs are run from the console - especially euphoria demo programs. GUI editors with terminal support are now ubiquitous. It is likely that a new user will use a GUI Editor to explore Euphoria's demo programs. Console demo programs can easily be easily adapted to run from a GUI editor at the cost of one command asking for a key press - which places no onerous burden on any user who executes the console demo directly from the console.

-- in the demo program "regexps.ex" 
-- replace line: 
-- maybe_any_key() -- This command is absolutely useless!!!! 
-- with: 
any_key("\nPress Any Key to Exit") 
new topic     » goto parent     » topic index » view message » categorize

4. No maybes. Replace maybe_any_key with any_key in demos

If one of the installer lets you run uncompiled EUPHORIA programs from the GUI, I have to agree with you.

SD Pringle

new topic     » goto parent     » topic index » view message » categorize

5. Re: More Manual Typo/errors

K_D_R said...

The latest version of WEE supports execution of a console program in a terminal - which works for some console programs, but not for other console programs such as the demo, "regexps.ex" which only works as expected in a GUI's terminal, provided you ask for a key press in order to keep the program from terminating instantly.

The difference is that the stupid operating system provides a concept of a console subsystem vs a GUI subsystem. Consoles simply work differently there, and it's relatively simple to determine if a Windoze console is in use or not. This is what maybe_any_key() uses.

On nix, it's not trivial to determine if a process is running directly inside an xterm or similar program, as opposed to running inside of an ssh or telnet or rlogin session, or in something like GNU screen.

I think the consensus is that, under nix, since the IDE is the one that knows if it started the child process inside of an xterm or not (unlike process itself), it should be the one responsible for keeing that xterm alive after the process ends.

K_D_R said...

We should not assume that Unix console programs are run from the console - especially euphoria demo programs. GUI editors with terminal support are now ubiquitous.

Then these GUI editors should support an option like "Run via xterm - keep xterm alive after process ends" or a similar setting.

If you are fond of a particular editor that does not support this sort of setting, there are also workarounds you can use. E.g. http://stackoverflow.com/questions/3512055/avoid-gnome-terminal-close-after-script-execution

Alternatively, we could come up with an euiw for nix, where the only difference from eui is that the nix euiw simply always returns 0 for has_console(). Then set up the editor to run code with euiw instead of eui.

K_D_R said...

It is likely that a new user will use a GUI Editor to explore Euphoria's demo programs. Console demo programs can easily be easily adapted to run from a GUI editor at the cost of one command asking for a key press - which places no onerous burden on any user who executes the console demo directly from the console.

-- in the demo program "regexps.ex" 
-- replace line: 
-- maybe_any_key() -- This command is absolutely useless!!!! 
-- with: 
any_key("\nPress Any Key to Exit") 

Right, but if someone is running it from the command line directly, via a getty session (outside of X), then pausing here is probably the wrong thing to do - it's unnecessary since you won't lose output after the key press. Ditto if I'm running the program directly on the command line.

SDPringle said...

Why should the interpreter ask for a key press? Are you opening demos from a GUI in Linux?

That said, if someone has a patch or some code that can, under Linux/GNU, determine if a process is running under an xterm or something, I'm not necessarily opposed to reviewing it and including it. It's just not a very easy thing to do.

new topic     » goto parent     » topic index » view message » categorize

6. Re: More Manual Typo/errors

Not all Linux distributions come with xterm. Mint comes with 'gnome-terminal' already installed but not xterm. You could install xterm however. The demo directory has always been meant to be run via the command line. The only good solution is if someone could make maybe_any_key behave as in Windows on Linux. Arguably maybe it is better to default to asking for a key when you cannot detect one way or another.

SD Pringle

new topic     » goto parent     » topic index » view message » categorize

7. Re: More Manual Typo/errors

A switch could be added to the std/console.e to make this kind of thing work the way it should

ifdef NO_CONSOLE then 
    public function has_console() 
        return 0 
    end function 
elsedef 
    public function has_console() 
        -- stuff that is there now 
    end function 
end ifdef 

Then in the GUI settings you put:

gnome-terminal -command 'eui -D NO_CONSOLE $filename' 

new topic     » goto parent     » topic index » view message » categorize

8. Re: More Manual Typo/errors

jimcbrown said...

Then these GUI editors should support an option like "Run via xterm - keep xterm alive after process ends" or a similar setting.

If you are fond of a particular editor that does not support this sort of setting, there are also workarounds you can use. E.g. http://stackoverflow.com/questions/3512055/avoid-gnome-terminal-close-after-script-execution

SDPringle said...

Not all Linux distributions come with xterm. Mint comes with 'gnome-terminal' already installed but not xterm.

Generally, there should be a symbolic link called x-terminal-emulator that points to the installed binary, whether it's gnome-terminal, xterm, urxvt, konsole, or something else. Most editors that support this option should also enable you to configure which terminal emulator to use anyways.

The workaround link I provided is explicitly for gnome-terminal, not xterm, though it's generic enough to work with either.

SDPringle said...

The only good solution is if someone could make maybe_any_key behave as in Windows on Linux.

Please explain why asking the IDE to add a pause is not a good solution.

SDPringle said...

A switch could be added to the std/console.e to make this kind of thing work the way it should

ifdef NO_CONSOLE then 
    public function has_console() 
        return 0 
    end function 
elsedef 
    public function has_console() 
        -- stuff that is there now 
    end function 
end ifdef 

Then in the GUI settings you put:

gnome-terminal -command 'eui -D NO_CONSOLE $filename' 

I think if someone wants to go this route, it's better to make the change in maybe_any_key() only.

SDPringle said...

Arguably maybe it is better to default to asking for a key when you cannot detect one way or another.

I have no problems with this in principle.

new topic     » goto parent     » topic index » view message » categorize

9. Re: More Manual Typo/errors

Can someone make this into a ticket please...

new topic     » goto parent     » topic index » view message » categorize

10. Re: More Manual Typo/errors

SDPringle said...

Can someone make this into a ticket please...

For wee?

new topic     » goto parent     » topic index » view message » categorize

11. Re: More Manual Typo/errors

jimcbrown said...
SDPringle said...

Can someone make this into a ticket please...

For wee?

While some workarounds that could be implemented in euphoria were discussed, I think the undisputed and correct solution remains to fix the IDE to add the required prompt, instead of changing how maybe_any_key() works.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu