Re: [Boa Constr] Boa's new handling of stdin in ShellEditor
Status: Beta
Brought to you by:
riaan
From: Riaan B. <riaan@e.co.za> - 2001-07-13 16:31:51
|
Hi Patrick, "Patrick K. O'Brien" wrote: > > Riaan, > > This is probably pretty nitpicky, Yes ;) > but I'm not crazy about the new way that > stdin works in the Shell for three reasons. First, the behavior isn't the > same as other IDEs, such as IDLE. Second, the additional prompt is a > distraction when most programs that use stdin already display a prompt. > Third, it is too easy to move the cursor back to a previous command and copy > that line down which displays the ps1 prompt instead of ps4, etc. You mean by moving the cursor up to a previous line and pressing enter? Why would you want to do this at a stdin prompt? It would still take the correct input even if the prompt is different. If you want to implement this, add the concept of a current prompt to the shell which is prepended to everything copied the the shell line > For > examples of what I mean you can type help() or license(). I tested development around help() and licence() so I know how they behave. > > Now, I tried to change this in Boa so that it was still "inline" as opposed > to a wxTextEntryDialog but then I ran into problems with the hardcoded > expectation of a 4 character prompt so I gave up. One alternative is to go > back to a wxTextEntryDialog and redefine both stdin and raw_input (at the > __builtin__ level, not locals, which was the problem with the previous code > I believe). No it's not an option to fall back on. Covering one function (raw_input) instead of ANY function (on stdin) is not a fallback option. Cool to know that replacing it on built-in level covers most of the common cases. I never tried it (silly me). > > For example: > > def readRaw(self, prompt='Please enter your response:'): > dialog = wxTextEntryDialog(None, prompt, \ > 'Input Dialog (Raw)', '') > try: > if dialog.ShowModal() == wxID_OK: > text = dialog.GetValue() > return text > finally: > dialog.Destroy() > return '' > > And then wherever appropriate add: > > import __builtin__ > __builtin__.raw_input = readRaw # Or the equivalent if readRaw > is passed as a parameter. > del __builtin__ > > To do this, though, would require more changes to Boa than I was comfortable > making. And I wasn't sure you would agree with these changes. No you have to work with stdin. > > It's not like anything is really broken, I'm just looking for a better > solution and wanted to jot this stuff down while it was fresh in my mind. > Feel free to disregard this message entirely. I just felt compelled to write > it. > > To me the best solution would be something inline that wasn't so fragile. It > shouldn't display a prompt but it must be aware of the prompt that might be > passed to raw_input(), or that was written directly to stdout (which is all > that raw_input does anyway). In a way I think it should be modal, which is > what you get with the dialog approach. There is also the issue of whether to > leave the prompt and response in the output stream, which looks pretty ugly > in the case of license(). My readRaw() method basically swallows the prompt > and response, which looks better when you call license() but might be > inappropriate in other circumstances where you want the prompt and response > logged. In most other circumstances yes :) > > As you can see, I'm still looking for a solution. For now I'm comfortable with my solution. Boa explitly goes into prompt mode. The type of request is very clear and the input format works easily with the rest of the code. If you really need to change this, you have to keep track of where the cursor was when stdin is first read, and the text from there. I'm currently (automatically) using the normal prompt read code. I must say that it's kind of a non issue for me as it's not functionally different (you type the responses) and I liked the explicit prompt. And a text entry dialog would be way different than IDLE :) > > --- > Patrick K. O'Brien > Orbtech > "I am, therefore I think." > > _______________________________________________ > Boa-constructor-users mailing list > Boa...@li... > http://lists.sourceforge.net/lists/listinfo/boa-constructor-users -- Riaan Booysen ___________________________________________________ Boa Constructor - RAD GUI building IDE for wxPython http://boa-constructor.sourceforge.net |