Depends on D1841
Maybe file a bug in GTK.
The console can be used to access an app, window, or anything through the provided namespace. It works by redirecting...
some more ' to be replaced with ". Please Ctrl+F
Makes sense, but the names can be confusing. We should see how to reorganize/rename them.
remove empty line at start of method
I meant here the "i" variable should be "end_iter". The name of the method was fine, and the new name does not even make sense.
I tried to remove "if not event_state: buf.place_cursor(inp)" and it works fine, so let's remove this, and then we can rename the method to __is_cursor_at_start """Returns whether the prompt is exactly after the prompt.""". Maybe rename "input" to "after-prompt". And maybe inp to ..after_prompt?
*inp/*cur, to be consistent with the other methods.
Add _tag suffix for these fields
cur -> end ?
You could catch "SyntaxError: unexpected EOF while parsing" and then also self.prompt = ConsoleWidget.PROMPT_INDENT...
>>> a( Traceback (most recent call last): File "/home/aleb/dev/pitivi-cfoch/pitivi/plugins/console/widgets.py", line 507, in __run eval_result = eval(command, global_namespace, local_namespace) File "<string>", line 1 a( ^ SyntaxError: unexpected EOF while parsing
Why? I am not sure what to change here and why to do the change.
"It works by redirecting." ?
I don't understand why you ask that.
I suggested this but "the prompt is exactly after the prompt" sounds confusing. Maybe "cursor" ?
I'm just thinking that the inp name for the local variable does not make sense. If you change it, see maybe it makes sense to do the same rename in other places. If you don't like after-prompt, let's find some other name. command_line_start ?
Look for buf.get_iter_at_mark(buf.get_mark("input")) and maybe use the same variable name to store the result.
wrap in a try/finally, to make sure sys.stdout is reverted if an exception is raised
You don't need to swap them, only set sys.stdout.
Read the whole paragraph, you should remove the entire text I quoted.
You can use sys.ps1 and sys.ps2 instead of these!
I think we can get rid of ctrl+return with this change!
This is a private method, no need to document it like this. Instead, I would add a comment in the code, to make it clear what's happening.
You can return directly, no need to use res
I think we should not have to call runcode. See how https://docs.python.org/3/library/code.html#code.InteractiveConsole.push works. It tries to run the buffered lines whenever you push, and if it succeeds it resets the buffer!
That's because the Python console only accept lines. That bothers me TBH. If you want to use push with more than one line you will get an error.
This is not useful info for the user of this widget. Please remove.
Why is this needed? Remove?
We don't load any settings here.
Remove this check, make namespace mandatory, since we'll always use it, and explain it in the "Args:" section in the class pydoc.
Same for __is_cursor_at_start
Maybe line_start_mark is more clear?
I imagine it might be useful when editing multi-line commands, but this is too complex. I vote for removing it. The standard Python console does not do anything fancy, for example.
Let's remove this and don't bother about spaces at the end?
Why is this necessary? Why isn't the fact that we return True not enough? Add a comment or remove the line. See also above same thing.
Move this call into history_up, same for history_down?