Screenplay View

The screenplay view takes input and translates it into screenplay commands (cursor movement, text editing, etc.) and draws the screenplay.

Drawing

Drawing the screenplay is very likely the most time consuming step in Shane’s program flow. Here is how it works:

  1. Get cursor position (line and column) in screenplay
  2. Calculate scrollbar slider position (using screenplay’s total line count)
  3. If required scroll view either up or down so that cursor’s in view
  4. Get paragraph the first visible line’s in and offset of that line from paragraph start
  5. Draw all paragraphs visible line by line starting with the first visible line
  6. Draw scrollbar
  7. Set cursor

Design Decisions

The scrollbar is not drawn as far down as it seemingly can be. It can’t. ncurses throws an error when drawing a character at the lower right. A solution would be to make the screenplay view window one column wider but the aesthetics wouldn’t make up for the “ugliness” in code and more importantly a whole new column to clear with every draw pass (without actually being drawn on anyway).

Source Code Docstrings

class shane.sp_view.ScreenplayView(screenplay: shane.screenplay.Screenplay)

View for screenplay editing.

static get_required_window_width()

Return minimum width needed for view.

redraw()

Completely redraw screen view.

run()

Run screenplay view’s mainloop.

class shane.sp_view.ScreenplayViewEvent

Enum for results from editing mainloop.