-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Define a strict public API #277
Comments
I am 👍 with this. IMO we should start with a strict public API as small as possible. This will let us maintain backwards compatibility of it, without losing flexibility when messing with the rest of the methods. We can then introduce new public methods on an as-needed basis afterwards. So my initial proposal for the public API are the following methods:
|
One thing that's always bugged me with refresh is if no args are specified it should refresh the whole viewport. |
Here are all the calls vscode uses currently: constructor()
open(HTMLelement)
write(string)
on('data', string => boolean)
attachCustomKeydownHandler(KeyboardEvent => boolean)
destroy()
focus()
scrollDisp(number)
clear()
refresh(number, number)
setOption(string, object)
resize(number, number)
// to check if cursorBlink is enabled, could be replaced with a getOption function
cursorBlink
// to attach focus/blur events to save state when the terminal in focused
// to explicitly set the width of the element
element
// to attach focus/blur events to save state when the terminal in focused
textarea |
Adopting an |
Something else that should be considered is #266. It might be worth rethinking and simplifying initialization as part of 2.0.0, Is there any reason for the |
I completely forgot the
I think that the best thing for now would be to just document the Public API clearly into a fresh
Not sure what you are talking about here. What is the Also would it make sense to merge |
Also we can JSDoc all private methods as Last, I propose replacing the following:
with:
which are more verbose, but at the same time more explicit and not editable (so consumers are less likely to mess things up) |
@parisk more intuitive init logic could be:
or
|
What should happen when |
@waywaaard probably throw and exception |
Maybe, a |
For completeness maybe, can't think of a use case for it though. |
What about making the attaching part of the construction (just like how CodeMirror handles this: http://codemirror.net/doc/manual.html#api_constructor)? |
🆗 I will leave the constructor as-is until we decide on something. I propose merging I will start documenting at |
@parisk on scroll, scrolling pages and the entire buffer would also be good to expose, this would be needed to allow consumers to customize keybindings, so something like: xterm.scroll(value[, type]);
xterm.SCROLL_TYPE = LINE | PAGE | BUFFER or xterm.scrollLines(value);
xterm.scrollPages(value);
xterm.scrollToTop();
xterm.scrollToBottom(); |
Let's leave additional functionality outside for now. The smallest the API is the easier is to maintain. Let's support more methods on an as-needed basis. The first version of the public API is documented at xtermjs/xtermjs.org#1 and exposes only a few methods of the It can be previewed at https://d8q3uus5.apps.lair.io/docs/api/Terminal/. |
@parisk I'm currently relying on |
Closing this as it got defined in xtermjs/xtermjs.org#1. |
Before going v2.0.0 we should lock down the API and explicitly state what is public and what is private. Right now many of the functions are included in the API doc site but are actually private, some examples:
blankLine
,bind*
,cursor*
, ...Not doing so makes it harder to know what you're meant to call in to as an embedder, harder to use, more likely to use private APIs what break across versions and it could slow the speed at which we develop as a result.
The text was updated successfully, but these errors were encountered: