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

Buffered versus direct drawing #46

Open
peterbrittain opened this issue Sep 25, 2016 · 7 comments
Open

Buffered versus direct drawing #46

peterbrittain opened this issue Sep 25, 2016 · 7 comments
Milestone

Comments

@peterbrittain
Copy link
Owner

peterbrittain commented Sep 25, 2016

At the lowest level, the Screen class enforces a refresh() before it will draw anything. This is irritating for people who just want to do some simple drawing. Consider providing 2 modes of operation for the class:

  1. Buffered - bascially the current mode, but fully enforcing double buffering.
  2. Direct - which will draw directly and so have no refresh required.

Some interesting decisions need to be made in both cases:

  1. Whether to clear the screen or not at start up? Possibly direct mode should leave that up to the user?
  2. Whether to expose the current cursor position or not? Makes less sense in buffered mode.
  3. Whether to allow screen character look-ups? Doesn't makemuch sense if the screen isn't reset to a known state (i.e. cleared) at start-up.

It feels like these may behighly related, but ultimately different class implentations...

@peterbrittain peterbrittain added this to the V2.0 milestone Sep 25, 2016
@peterbrittain
Copy link
Owner Author

Requires new API that is being proposed for v2.0

@peterbrittain
Copy link
Owner Author

Might need current cursor position. Looks like this uses u6-7. See http://unix.stackexchange.com/questions/239271/parse-terminfo-u6-string

@peterbrittain
Copy link
Owner Author

@peterbrittain
Copy link
Owner Author

Also need to think about relative movement inthis environment - e.g. start of line, up/down one line, etc. That may be possible with a print method instead of print_at. But if I do that, can I still support renderers using paint? Maybe the correct API is to provide no print_at for direct mode and to make paint work from the current cursor pos?

@peterbrittain
Copy link
Owner Author

peterbrittain commented Nov 28, 2016

It appears that I can only really use setupterm() in curses and so have to limit available function (e.g. no input at all). That means an API like:

  • print_at
  • centre
  • palette
  • paint
  • highlight
  • dimensions (using "cols" and "lines" from terminfo)
  • is_visible

Plus some other methods that might now make sense if I can break out the classes neatly enough:

  • save/restore cursor position (using "sc"/"rc")
  • hide cursor (using "civis"/"cnorm")
  • fullscreen (using "smcup"/"rmcup")
  • clear (using "clear")
  • get_current_pos (using "u6"/"u7") - though it's not obvious this is supported on all terminals.

Longer term it might be possible to do the following (but they will be messy to fit into the current APIs):

  • print (with relative positions [see cup, hpa and vpa] and colours?)
  • cursor movement (with relative motion? - see cub1, cuf1, cuu1, cud1)
  • Possibly print_renderer to simplify use of such things...

@peterbrittain
Copy link
Owner Author

A little more research on how dialog simply overrides stuff inside ncurses leads me to believe that I might be able to use the rmcup sequence on curses systems to allow full interaction with the normal screen. Feels a bit hacky, but could be a way forwards.

@peterbrittain
Copy link
Owner Author

Need to look at resizing and extracting state of screen before the app starts a little more closely, but a quick trial script looks like this could give full cursor control and keyboard input, thus giving access to the full existing API.

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