coolwanglu / neovim-e

Electron UI for Neovim
MIT License
271 stars 29 forks source link

Support ligatures. #49

Open jordwalke opened 8 years ago

jordwalke commented 8 years ago

I took a look at ui.coffee and it seems like supporting ligatures would be within reach. Ligatures are great because modern programming fonts are beginning to include support for awesome symbols for functional languages etc.:

For example, see https://github.com/tonsky/FiraCode

It looks like the canvas drawText API that you're using supports ligatures but it merely requires that you draw the two/three characters in one call to drawText. I saw that neovim-e draws one character at a time, however.

Should there be some intermediate representation that neovim-e keeps track of instead of just executing raw single character draw/put commands? Could neovim-e maintain an up to date representation of the entire screen so that when anything changes, something like a "mini react" can find the characters that are likely dirty and draw only those lines (and the entire lines so that ligatures will render correctly)?

coolwanglu commented 8 years ago

The current implementation with canvas was partially from Vim.js, another project of mine, and partially for performance concerns. And of course it'd be easier to support ligatures with html tags.

I think your "redrawing dirty lines" idea should work, but we need to keep track of the content on screen that way.

jordwalke commented 8 years ago

Each line may have multiple colors/weight. Does that complicate things? I think we'd want to redraw dirty "ranges" of contiguous color/weight. Either way, having an intermediate representation seems very useful. I'd urge you to avoid using the DOM at all and I commend your choice of canvas (GL is a great option too).