Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use singleton object for Float x/ycursor #183

Closed
wants to merge 1 commit into from

Conversation

Carreau
Copy link
Contributor

@Carreau Carreau commented Nov 4, 2015

Attempt to start implementing #182

I'm not familiar with the codebase so it might not be he right way to do that,
I suppose the all logic here could be simplified and keep backward compat with (x|y)cursor

Screenshot with this as a completer:

Float(left=cursor+7,
       top=cursor-1,
                      ...))

screen shot 2015-11-03 at 20 48 48

(note, my goal is to have a completer like Fish which is a cursor.y+1 but the all width of terminal in the end, but not really a hsplit)

@jonathanslenders
Copy link
Member

Hi @Carreau,

Thanks a lot for the issue and the work on the pull request!

My thoughts:

  • In general, I very much like the idea of the Cursor singleton and the __add__/__sub__ overload.
  • However, this is still not going to be flexible enough. The current algorithm will position the content of the float above the cursor when the input spans multiple lines. In that case, saying top=cursor-1 is incorrect.

Possibly a better approach is to rewrite the FloatContainer.write_to_screen function and use a more powerful interface for plugging in other float positioning algorithms.
Ptpython for instance, also uses the BufferControl.menu_position to display the function signature at the start of the function call. (https://github.com/jonathanslenders/python-prompt-toolkit/blob/master/prompt_toolkit/layout/controls.py#L457) I would like to get rid of that, if we find a better, more generic approach.

For this, I also don't mind to be backwards-incompatible (it's mostly used internally), but I prefer to do it correctly.

Currently I'm still abroad for work with few spare time, but I will think about this. It's definitely interesting!

Jonathan

@Carreau
Copy link
Contributor Author

Carreau commented Nov 4, 2015

In that case, saying top=cursor-1 is incorrect.

Yeah, that was just an example to see that minus was working definitively not good for UI.

For this, I also don't mind to be backwards-incompatible (it's mostly used internally), but I prefer to do it correctly.

I'm still wrapping my head around the different case here. Especially xcusrsor and ycursor are hints for positioning. I'm trying to find the correct abstraction. To simplify the interface.

I'm also pretty busy with IPython these days, I was mostly trying to change my mind a bit, but will try to work a bit on that and understand more of the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants