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

In Window User Input #60

Open
sunjay opened this issue Jan 16, 2018 · 0 comments
Open

In Window User Input #60

sunjay opened this issue Jan 16, 2018 · 0 comments

Comments

@sunjay
Copy link
Owner

sunjay commented Jan 16, 2018

This is dependent on #49 and will probably require us migrating to a more feature-rich/mature GUI library.


Turtle already provides several different ways for you to get input. Not only can you use things like io::stdin to read input from the terminal, you can also poll events from the window and respond to them as you see fit.

The problem with getting input from the terminal is that it requires you to switch between the application and the terminal whenever you want to do something. This is especially problematic in applications which work best when maximized or fullscreen. Trying to use events alone doesn't allow the user to see what they are inputting (especially since we don't support text rendering yet).

We want to support something that is slightly simpler than the utilities provided by Rust's io module. Our input method would be tightly integrated with our library and actually have its interface on screen within the window itself.

The Concept

turtle-input-concept

The overall concept is a sidebar chat window that pops up whenever a Turtle asks for input. The turtle's name (usually "Turtle" followed by a number if there is more than one turtle) is put before its messages. Your messages are right aligned.

New methods to be added to Turtle:

  • fn read_input(&mut self) -> String
    • Read an input message from the sidebar, this may be more than one line of input
    • If the input sidebar is not yet open, it will be opened and the text field will gain focus
  • fn say(&mut self, &str)
    • Write the given message to the sidebar, the message can be over multiple lines
    • If the sidebar is not yet open, it will be opened but focus will not change
  • say!(turtle, ...)
    • Similar behaviour and implementation to the write!() macro.

With this feature added, it would definitely be desirable to be able to get and set the name of each turtle. This is definitely not necessary for the implementation of this feature and can always be added later.

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

No branches or pull requests

1 participant