jtdaugherty / vty

A high-level ncurses alternative written in Haskell
BSD 3-Clause "New" or "Revised" License
320 stars 57 forks source link

Support placed (but hidden) cursor #86

Closed jtdaugherty closed 6 years ago

jtdaugherty commented 9 years ago

I received a request from a brick user asking about the possibility of supporting blind users via Braille terminals. The request was to support always placing a cursor on the currently-focused UI element, with the understanding that this might not be visually appealing if the cursor is visible. Instead the user proposed the cursor be placed but invisible:

I understand that the visual cursor is not very beautiful when it's blinking
in every list box, but there is a solution at least in Linux. The cursor can
be moved even when it is hidden. This makes it possible to make Brick
accessible without changing its visual appearance at all. SOme interface
change would probably be needed tough, perhaps something like placeCursor in
addition to showCursor in Brick.Widgets.Core where placeCursor would request
placing the cursor in a certain location, but still keeping it invisible.

It seems like I'd need support from vty to do this in brick, possibly by adding a new Cursor constructor so as to get

data Cursor =
    NoCursor     
  | Cursor Int Int
  | HiddenCursor Int Int

or perhaps

data Cursor =
    NoCursor     
  | Cursor Int Int Bool

What do you think?

coreyoconnor commented 9 years ago

I agree with the motivation. The change is compatible with existing usage. The Win32 console functions support equivalent functionality. I see no blockers to the implementation.

LGTM :+1:

jtdaugherty commented 9 years ago

I don't know how to implement it. I don't know when I'll get time to do it, but can you provide any guidance?

coreyoconnor commented 8 years ago

Note: I prefer the first interface. Only due to compatibility with existing usage.

The cursor placement is the last part of building the Write that corresponds to the bytes output to the terminal device.

There are three paths:

  1. The terminal does not support cursor manipulation. No consideration of requested cursor state is done.
  2. No cursor is requested. As the cursor is always hidden prior to output of the Picture this means nothing is required to keep the cursor hidden.
  3. A cursor placed at a specific position is requested. The input position is in character row, column. This is first translated to row, display column positions. Then output required to show the cursor and place the cursor is appended to the Write.

I suspect this would require the same procedure as 3. Except without the writeShowCursor.

jtdaugherty commented 6 years ago

Realistically speaking, I am not going to get around to this so I'm closing it to avoid staleness. If someone becomes interested in contributing this, we can re-open.