1. gets behaviour question

Is there a better choice than gets for getting data from the console? On Windows there's no backspacing etc.

-Bruce

new topic     » topic index » view message » categorize

2. Re: gets behaviour question

https://openeuphoria.org/docs/std_console.html#_887_console

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

3. Re: gets behaviour question

Thank you!

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

4. Re: gets behaviour question

So if I want command line history and all that, I have to implement it myself? Or is the lack thereof an artefact of MS's various changes to the console?

-Bruce

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

5. Re: gets behaviour question

Not sure if this is what you need, but I've written a replacement for prompt_string that allows editing the input line (cursor left/right, home, end, backspace, delete) and also makes it possible to scroll through previous input lines, edit and re-enter them. Length of input line is limited to the current width of the console window.

I'm using it with Phix, but I suppose it works with Euphoria, too. Doesn't work with Linux, though.

I've put it up here: www.hypatia-rpn.net/stuff/prompt_string_ed.e

Input characters are limited to ASCII codes < 128 here, but that's easily changed. It would also be easy to allow, disallow, or convert particular characters, if needed. If you have any questions, please ask.

Robert

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

6. Re: gets behaviour question

RobertS said...

I'm using it with Phix, but I suppose it works with Euphoria, too. Doesn't work with Linux, though.

It actually doesn't work with Euphoria without a slight change in syntax, due to the following:

C:\Users\bugma\Dropbox\Source\task\prompt_string_ed.e:43 
<0132>:: Syntax error - expected to see possibly 'end', not '[' 
  in_max = video_config()[10] - length(prompt) - 1 
                         ^ 
Some Phix just doesn't translate.

After I fixed that, the following appeared:

c:\Users\bugma\Dropbox\Source\task>eui task.ex 
c:\Users\bugma\Dropbox\Source\task\prompt_string_ed.e:178 
<0074>:: Errors resolving the following references: 
    'edstack' (prompt_string_ed.e:46) has not been declared. 
    'edstack' (prompt_string_ed.e:47) has not been declared. 
    'edstack' (prompt_string_ed.e:48) has not been declared. 
    'edstack' (prompt_string_ed.e:53) has not been declared. 
    'wait_key' (prompt_string_ed.e:65) has not been declared. 
    'edstack' (prompt_string_ed.e:94) has not been declared. 
    'edstack' (prompt_string_ed.e:104) has not been declared. 
    'edstack' (prompt_string_ed.e:106) has not been declared. 
    'edstack' (prompt_string_ed.e:109) has not been declared. 
    'edstack' (prompt_string_ed.e:121) has not been declared. 
    'edstack' (prompt_string_ed.e:176) has not been declared. 
    'edstack' (prompt_string_ed.e:178) has not been declared. 
 
    edstack = edstack[2..$] 
            ^ 

Ahhh, just saw this comment:

-- *** Important *** 
-- needs global object edstack (stack of editor input lines) 

Hmm....

-Bruce

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

7. Re: gets behaviour question

axtens_bruce said...

Ahhh, just saw this comment:

-- *** Important *** 
-- needs global object edstack (stack of editor input lines) 

Hmm....

-Bruce

This lets the input routine remember previous input lines. You can scroll up through your previous input lines, and either just repeat one of them by pressing ENTER, or edit it, for instance to fix an error or to enter modified data. With the edstack object being global, the calling routine has access to the input routine's memory, can read it, and, if necessary, also manipulate it.

Hope this makes sense to you.
Robert

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

Search



Quick Links

User menu

Not signed in.

Misc Menu