1. gets behaviour question
- Posted by axtens_bruce in March
- 627 views
Is there a better choice than gets for getting data from the console? On Windows there's no backspacing etc.
-Bruce
4. Re: gets behaviour question
- Posted by axtens_bruce in March
- 575 views
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
5. Re: gets behaviour question
- Posted by RobertS in March
- 578 views
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
6. Re: gets behaviour question
- Posted by axtens_bruce in March
- 531 views
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
7. Re: gets behaviour question
- Posted by RobertS in March
- 517 views
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