-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Render using canvas #938
Merged
Merged
Render using canvas #938
Changes from 106 commits
Commits
Show all changes
108 commits
Select commit
Hold shift + click to select a range
c6d4c73
Initial prototype
Tyriar 640cd18
Support bold, underline, fix colors
Tyriar e98794a
progress
Tyriar 5ce39d3
GPU ascii rendering
Tyriar 137847e
Linkify all rows at once to prevent multiple timeout restarts
Tyriar 0db42e2
Pull bg rendering into an IRenderLayer
Tyriar 5961bdb
[email protected] for ImageBitmap interface
Tyriar 2cb6593
Move fg rendering into IRenderLayer
Tyriar 18e1134
Tidy up
Tyriar 129633a
Only draw background when needed
Tyriar d93a803
Draw unicode characters
Tyriar 6a0b9bd
Only render fg cells if there are changes
Tyriar 1291dc5
Support inverse
Tyriar a224ed7
Move canvas Renderer into folder
Tyriar 7aff45c
Remove additional frame skipping as rendering is so fast now
Tyriar 5953bba
Start SelectionRenderLayer
Tyriar 3d1bb2c
Support selection
Tyriar d601f0a
Hang on to selection state to avoid redrawing
Tyriar dff3d16
Support 256 color
Tyriar d3650d9
Draw selection underneath foreground
Tyriar fd18f7c
Support basic cursor
Tyriar a91380a
Pull common parts into BaseRenderLayer
Tyriar fe7b424
Move char atlas into BaseRenderLayer
Tyriar 1998675
Move char drawing to base and use in cursor layer
Tyriar c888241
Simplify color generation code
Tyriar 15c73ef
Add fontSize and fontFamily options
Tyriar 6588e9e
Fix cursor which cursor character is rendered
Tyriar 9323833
Move scaledCharWidth/Height into base render layer
Tyriar 5109403
Provide convenience draw methods that deal with cells
Tyriar 42e5b34
Don't clear fg char if it's null or ' '
Tyriar 81d93b8
Ensure CharMeasure exposes integers
Tyriar 848c85c
Fix more cases where ' ' doesn't have code
Tyriar 882d7e4
Add basic support for cursor blinking
Tyriar 3fc500b
Pull cursor animation state management into a helper class
Tyriar 076156b
Properly support blinking cursors
Tyriar 62fea4d
Add theme support
Tyriar bc3bdac
Add a char atlas cache to allow different styles+reuse across terminals
Tyriar de4fcb9
Merge render layer interface types
Tyriar 2c9dbc6
Add some jsdoc
Tyriar bf95333
Fix the fit addon
Tyriar 1f444b1
Support invisible attr
Tyriar 70764a7
Use the proper bg/fg colors for inverse attr
Tyriar b0653fe
Support underline
Tyriar 5cd189e
Fix demo pty size
Tyriar 6ee8e91
Remove some old dead code
Tyriar b57b94a
Improve focus/blur state, fire only once
Tyriar dc1e727
Support blurred cursor
Tyriar 4919c40
Add cursor to ITheme
Tyriar f8ece10
Rerender cursor if state changes
Tyriar 06b5458
Fix cursor render when after focusing underline/bar
Tyriar cf7237d
Fix remaining cursor animation state issues
Tyriar 36a723c
Fix 256 FG chars
Tyriar 6dd6d03
Add cell spacing to char atlas
Tyriar ae72e1c
Fix uncached chars bleeding into other cells
Tyriar 32a3c98
Support wide character drawing and cursors
Tyriar b8732a2
Support Safari
Tyriar ee4b71c
Remove Terminal.options.colors
Tyriar 9cabb93
Organize temporary color handling code
Tyriar c92a2f9
Support lineHeight
Tyriar 66d41fe
Expose setTheme through .d.ts
Tyriar 24a98f2
Remove rowContainer and children, disable Linkifier
Tyriar 8039fd3
Remove unused CSS, selectionElement
Tyriar 4f81cdf
Make the terminal background theme aware
Tyriar c5a6d96
Remove padding from terminal, not support atm
Tyriar 7ccac09
Fix the composition element's position
Tyriar c94e874
Fix CharMeasure getting taller on successive calls
Tyriar 7973b26
Include new options in ITerminalOptions
Tyriar 8427f74
Clear state when resizing as canvases get cleared
Tyriar fd4e9d8
Fix graphical glitch wide chars would leave behind
Tyriar 5a48516
Prevent updating of invalid terminal row ranges
Tyriar deb47e2
Fix canvas resizing with non-1 lineHeight
Tyriar a3297b0
Fix viewport/background size after char size changed
Tyriar bc3470c
Fix default bold text
Tyriar 48b3745
Ensure char measure's line height isn't influenced by outside
Tyriar 2d1a1bf
Fix inconsistency with lineHeight
Tyriar 5619abe
Basic link support using mouse zone manager
Tyriar 923ea72
Get links working on proper coords
Tyriar b30cb58
Support hover callback in links
Tyriar 17731c3
Support multiple links in a line, fix Linkifier tests
Tyriar e518ea0
Get tests reporting failures again
Tyriar 3677818
Fix tests
Tyriar e123dd1
Null check if clicking on scroll bar
Tyriar 7934e05
jsdoc Linkifier
Tyriar e77f1a9
Use default colors if not defined in a theme
Tyriar 29a7ee3
Fix lint
Tyriar 0bfdff0
Theme unfocused cursor using cursor color
Tyriar ff31f34
Add selection to ITheme
Tyriar a179502
Support emoji
Tyriar 1c3028c
Work around an emoji bug
Tyriar a35cf02
Add GridCache tests
Tyriar 6f6f17f
Add tests for ColorManager
Tyriar 1f38c2f
Remove unused file
Tyriar 9506c01
Add tests for utils/Mouse
Tyriar da1e3b4
Don't use ImageBitmap on Firefox
Tyriar 8e07af0
Drop support for IE/Opera and indicate latest
Tyriar 0dc24cf
Move theme setting into setOption API
Tyriar 46b0857
Resolve TODOs
Tyriar 1e728d4
Add new API to typings test
Tyriar 5c2d5dc
Document methods of BaseRenderLayer
Tyriar 7b199ac
Some more documentation
Tyriar b69ff5d
Redraw terminal when devicePixelRatio changes
Tyriar fb90c98
Fix blurry text by supporting floating pt devicePixelRatios
Tyriar 66c891d
Fix resize adding right padding on demo
Tyriar e960a0a
Add ILinkMatcherOptions.hoverEndCallback
Tyriar 67962a5
[email protected]
Tyriar ea8dbbd
Underline links on hover
Tyriar 75b91c6
Update license text
Tyriar 0c19bc9
Fix tests
Tyriar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,7 @@ export class CompositionHelper { | |
* @param {CompositionEvent} ev The event. | ||
*/ | ||
public compositionupdate(ev: CompositionEvent): void { | ||
console.log('compositionupdate'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Left a logger here I think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch 😅 #983 |
||
this.compositionView.textContent = ev.data; | ||
this.updateCompositionElements(); | ||
setTimeout(() => { | ||
|
@@ -193,26 +194,26 @@ export class CompositionHelper { | |
if (!this.isComposing) { | ||
return; | ||
} | ||
const cursor = <HTMLElement>this.terminal.element.querySelector('.terminal-cursor'); | ||
if (cursor) { | ||
// Take .xterm-rows offsetTop into account as well in case it's positioned absolutely within | ||
// the .xterm element. | ||
const xtermRows = <HTMLElement>this.terminal.element.querySelector('.xterm-rows'); | ||
const cursorTop = xtermRows.offsetTop + cursor.offsetTop; | ||
|
||
this.compositionView.style.left = cursor.offsetLeft + 'px'; | ||
|
||
if (this.terminal.buffer.isCursorInViewport) { | ||
const cellHeight = Math.ceil(this.terminal.charMeasure.height * this.terminal.options.lineHeight); | ||
const cursorTop = this.terminal.buffer.y * cellHeight; | ||
const cursorLeft = this.terminal.buffer.x * this.terminal.charMeasure.width; | ||
|
||
this.compositionView.style.left = cursorLeft + 'px'; | ||
this.compositionView.style.top = cursorTop + 'px'; | ||
this.compositionView.style.height = cursor.offsetHeight + 'px'; | ||
this.compositionView.style.lineHeight = cursor.offsetHeight + 'px'; | ||
this.compositionView.style.height = cellHeight + 'px'; | ||
this.compositionView.style.lineHeight = cellHeight + 'px'; | ||
// Sync the textarea to the exact position of the composition view so the IME knows where the | ||
// text is. | ||
const compositionViewBounds = this.compositionView.getBoundingClientRect(); | ||
this.textarea.style.left = cursor.offsetLeft + 'px'; | ||
this.textarea.style.left = cursorLeft + 'px'; | ||
this.textarea.style.top = cursorTop + 'px'; | ||
this.textarea.style.width = compositionViewBounds.width + 'px'; | ||
this.textarea.style.height = compositionViewBounds.height + 'px'; | ||
this.textarea.style.lineHeight = compositionViewBounds.height + 'px'; | ||
} | ||
|
||
if (!dontRecurse) { | ||
setTimeout(() => this.updateCompositionElements(true), 0); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we be a little bit more precise here?
Latest
is a moving frame, and in some terms even inaccurate because we cannot always guarantee thatxterm.js
will work after an API change on one of those engines?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breakages from going up versions are not likely to happen on browsers and they deprecate and change behavior very slowly. The main point this is trying to get across is that this is for developers which should be on updated browsers. I certainly don't go back and check my features on Chrome 48, I do make sure they work on Blink, Gecko, etc. though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But does that also imply that we can start using a browser feature (like IntersectionObserver, ResizeObserver, async / await etc.) once that feature is supported by the aforementioned list of supported browsers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and we absolutely should imo.
window.createImageBitmap
for example is implemented using progressive enhancement, falling back to a HTMLElement because Firefox and Safari are lacking here. It provides a 2x speed up when I measured it on Chrome though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Things like async/await have the potential to break an awful lot of older browsers so we should be mindful of that, we're not trying to kill old browser support but rather guarantee it works on the latest (unless it becomes a nuisance).