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

Consider adding a component API #808

Closed
Tyriar opened this issue Jul 21, 2017 · 5 comments
Closed

Consider adding a component API #808

Tyriar opened this issue Jul 21, 2017 · 5 comments
Labels
type/proposal A proposal that needs some discussion before proceeding

Comments

@Tyriar
Copy link
Member

Tyriar commented Jul 21, 2017

Initially discussed in #807 (comment)

This would involve adding some interface like this that would make implementing addons much easier:

interface IComponent {
  onRefresh(rows: CircularList, startIndex: number, endIndex: number): void
  onDraw(group: RenderGroup, element: HTMLElement): void
  onMousedown(evt: MouseEvent): void
  onMouseup(evt: MouseEvent): void
  onInput(evt: KeyboardEvent): void
  onFocus(): void
  onBlur(): void
  onScroll(): void
  onOpen(term: ITerminal): void
  onResize(rows: number, cols: number)
  // ...
}

Candidates for turning into components:

  • CompositionHelper
  • SelectionManager
  • Search
  • Linkifier

/cc @mofux

@Tyriar Tyriar added the type/proposal A proposal that needs some discussion before proceeding label Jul 21, 2017
@Tyriar Tyriar mentioned this issue Sep 4, 2017
22 tasks
@Tyriar
Copy link
Member Author

Tyriar commented Oct 2, 2017

The internal IRenderLayer interface is pretty close to what I imagine the component API to look like:

export interface IRenderLayer {
  /**
   * Called when the terminal loses focus.
   */
  onBlur(terminal: ITerminal): void;

  /**
   * * Called when the terminal gets focus.
   */
  onFocus(terminal: ITerminal): void;

  /**
   * Called when the cursor is moved.
   */
  onCursorMove(terminal: ITerminal): void;

  /**
   * Called when options change.
   */
  onOptionsChanged(terminal: ITerminal): void;

  /**
   * Called when the theme changes.
   */
  onThemeChanged(terminal: ITerminal, colorSet: IColorSet): void;

  /**
   * Called when the data in the grid has changed (or needs to be rendered
   * again).
   */
  onGridChanged(terminal: ITerminal, startRow: number, endRow: number): void;

  /**
   * Calls when the selection changes.
   */
  onSelectionChanged(terminal: ITerminal, start: [number, number], end: [number, number]): void;

  /**
   * Resize the render layer.
   */
  resize(terminal: ITerminal, dim: IRenderDimensions, charSizeChanged: boolean): void;

  /**
   * Clear the state of the render layer.
   */
  reset(terminal: ITerminal): void;
}

Plus exposing the convenience methods on BaseRenderLayer to allow the easy creation of custom canvases

@parisk
Copy link
Contributor

parisk commented Oct 6, 2017

Looks neat.

Called when the data in the grid has changed (or needs to be rendered again).

Would it make sense to separate grind changing and the need for re-rendering, or are they the same thing?

@Tyriar
Copy link
Member Author

Tyriar commented Oct 6, 2017

RIght now they're the same thing, need to re-render is only fired on an animation frame. If we enabled third party addons we may need to reconsider.

This was referenced Nov 18, 2017
@feamsr00
Copy link

Hi!
I'd have to say that I do like the direction where this is going as 1) Having a well-defined interface for internal and external components is a really good idea. 2) Specifically, I think I'm interested in adding a new render layer as well.

(Time and effort permitting) It might be wise to begin refactoring internal objects to follow a similar model so that more of XT is composable. While I admit it might mean a bit of a re-arch if you're already planning on making changes soon, doing this now might pay down a lot of technical (architectural) debt.

@Tyriar
Copy link
Member Author

Tyriar commented Jun 3, 2018

Closing in favor of #1128 (comment) which is the first step

@Tyriar Tyriar closed this as completed Jun 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/proposal A proposal that needs some discussion before proceeding
Projects
None yet
Development

No branches or pull requests

3 participants